SUMO - Simulation of Urban MObility
ROMAFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Sets and checks options for ma-routing
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <iostream>
35 #include <fstream>
36 #include <ctime>
38 #include <utils/options/Option.h>
41 #include <utils/common/ToString.h>
42 #include "ROMAFrame.h"
43 #include <router/ROFrame.h>
47 
48 #ifdef CHECK_MEMORY_LEAKS
49 #include <foreign/nvwa/debug_new.h>
50 #endif // CHECK_MEMORY_LEAKS
51 
52 
53 // ===========================================================================
54 // method definitions
55 // ===========================================================================
56 void
59  oc.addCallExample("-c <CONFIGURATION>", "run routing with options from file");
60 
61  // insert options sub-topics
62  SystemFrame::addConfigurationOptions(oc); // fill this subtopic, too
63  oc.addOptionSubTopic("Input");
64  oc.addOptionSubTopic("Output");
65  oc.addOptionSubTopic("Processing");
66  oc.addOptionSubTopic("Defaults");
67  oc.addOptionSubTopic("Time");
68  SystemFrame::addReportOptions(oc); // fill this subtopic, too
69 
70  // insert options
73  // add rand options
75 }
76 
77 
78 void
81  // register import options
82  oc.doRegister("output-file", 'o', new Option_FileName());
83  oc.addSynonyme("output-file", "output");
84  oc.addDescription("output-file", "Output", "Write flow definitions with route distributions to FILE");
85 
86  oc.doRegister("ignore-vehicle-type", new Option_Bool(false));
87  oc.addSynonyme("ignore-vehicle-type", "no-vtype", true);
88  oc.addDescription("ignore-vehicle-type", "Output", "Does not save vtype information");
89 
90  oc.doRegister("netload-output", new Option_FileName());
91  oc.addDescription("netload-output", "Output", "Writes edge loads and final costs into FILE");
92 
93  oc.doRegister("all-pairs-output", new Option_FileName());
94  oc.addDescription("all-pairs-output", "Output", "Writes complete distance matrix into FILE");
95 
96  oc.doRegister("net-file", 'n', new Option_FileName());
97  oc.addSynonyme("net-file", "net");
98  oc.addDescription("net-file", "Input", "Use FILE as SUMO-network to route on");
99 
100  oc.doRegister("additional-files", 'd', new Option_FileName());
101  oc.addSynonyme("additional-files", "additional");
102  oc.addSynonyme("additional-files", "taz-files");
103  oc.addSynonyme("additional-files", "districts", true);
104  oc.addDescription("additional-files", "Input", "Read additional network data (districts, bus stops) from FILE");
105 
106  oc.doRegister("od-matrix-files", 'm', new Option_FileName());
107  oc.addSynonyme("od-matrix-files", "od-files");
108  oc.addDescription("od-matrix-files", "Input", "Loads O/D-files from FILE(s)");
109 
110  oc.doRegister("od-amitran-files", new Option_FileName());
111  oc.addSynonyme("od-amitran-files", "amitran-files");
112  oc.addSynonyme("od-amitran-files", "amitran");
113  oc.addDescription("od-amitran-files", "Input", "Loads O/D-matrix in Amitran format from FILE(s)");
114 
115  oc.doRegister("route-files", 'r', new Option_FileName());
116  oc.addSynonyme("route-files", "routes");
117  oc.addSynonyme("route-files", "trips");
118  oc.addSynonyme("route-files", "trip-files");
119  oc.addDescription("route-files", "Input", "Read sumo-routes or trips from FILE(s)");
120 
121  oc.doRegister("weight-files", 'w', new Option_FileName());
122  oc.addSynonyme("weight-files", "weights");
123  oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)");
124 
125  oc.doRegister("lane-weight-files", new Option_FileName());
126  oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)");
127 
128  oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
129  oc.addSynonyme("weight-attribute", "measure", true);
130  oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
131 
132  oc.doRegister("weight-adaption", new Option_Float(0.));
133  oc.addDescription("weight-adaption", "Input", "The travel time influence of prior intervals");
134 
135  // register the time settings
136  oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
137  oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
138 
139  oc.doRegister("end", 'e', new Option_String(SUMOTIME_MAXSTRING, "TIME"));
140  oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
141 
142  // register the processing options
143  oc.doRegister("aggregation-interval", new Option_String("3600", "TIME"));
144  oc.addDescription("aggregation-interval", "Processing", "Defines the time interval when aggregating single vehicle input; Defaults to one hour");
145 
146  oc.doRegister("ignore-errors", new Option_Bool(false));
147  oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
148  oc.addSynonyme("ignore-errors", "dismiss-loading-errors", true);
149  oc.addDescription("ignore-errors", "Processing", "Continue if a route could not be build");
150 
151  oc.doRegister("max-alternatives", new Option_Integer(5));
152  oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
153 
154  oc.doRegister("weights.interpolate", new Option_Bool(false));
155  oc.addSynonyme("weights.interpolate", "interpolate", true);
156  oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
157 
158  oc.doRegister("weights.expand", new Option_Bool(false));
159  oc.addSynonyme("weights.expand", "expand-weights", true);
160  oc.addDescription("weights.expand", "Processing", "Expand weights behind the simulation's end");
161 
162  oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
163  oc.addDescription("routing-algorithm", "Processing", "Select among routing algorithms ['dijkstra', 'astar', 'CH', 'CHWrapper']");
164 
165  oc.doRegister("weight-period", new Option_String("3600", "TIME"));
166  oc.addDescription("weight-period", "Processing", "Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy");
167 
168  // register defaults options
169  oc.doRegister("flow-output.departlane", new Option_String("free"));
170  oc.addSynonyme("flow-output.departlane", "departlane");
171  oc.addDescription("flow-output.departlane", "Defaults", "Assigns a default depart lane");
172 
173  oc.doRegister("flow-output.departpos", new Option_String());
174  oc.addSynonyme("flow-output.departpos", "departpos");
175  oc.addDescription("flow-output.departpos", "Defaults", "Assigns a default depart position");
176 
177  oc.doRegister("flow-output.departspeed", new Option_String("max"));
178  oc.addSynonyme("flow-output.departspeed", "departspeed");
179  oc.addDescription("flow-output.departspeed", "Defaults", "Assigns a default depart speed");
180 
181  oc.doRegister("flow-output.arrivallane", new Option_String());
182  oc.addSynonyme("flow-output.arrivallane", "arrivallane");
183  oc.addDescription("flow-output.arrivallane", "Defaults", "Assigns a default arrival lane");
184 
185  oc.doRegister("flow-output.arrivalpos", new Option_String());
186  oc.addSynonyme("flow-output.arrivalpos", "arrivalpos");
187  oc.addDescription("flow-output.arrivalpos", "Defaults", "Assigns a default arrival position");
188 
189  oc.doRegister("flow-output.arrivalspeed", new Option_String());
190  oc.addSynonyme("flow-output.arrivalspeed", "arrivalspeed");
191  oc.addDescription("flow-output.arrivalspeed", "Defaults", "Assigns a default arrival speed");
192 
193 }
194 
195 
196 void
199  // register the data processing options
200  oc.doRegister("scale", 's', new Option_Float(1));
201  oc.addDescription("scale", "Processing", "Scales the loaded flows by FLOAT");
202 
203  oc.doRegister("vtype", new Option_String(""));
204  oc.addDescription("vtype", "Processing", "Defines the name of the vehicle type to use");
205 
206  oc.doRegister("prefix", new Option_String(""));
207  oc.addDescription("prefix", "Processing", "Defines the prefix for vehicle flow names");
208 
209  oc.doRegister("timeline", new Option_String());
210  oc.addDescription("timeline", "Processing", "Uses STR as a timeline definition");
211 
212  oc.doRegister("timeline.day-in-hours", new Option_Bool(false));
213  oc.addDescription("timeline.day-in-hours", "Processing", "Uses STR as a 24h-timeline definition");
214 
215  oc.doRegister("additive-traffic", new Option_Bool(false));
216  oc.addDescription("additive-traffic", "Processing", "Keep traffic flows of all time slots in the net");
217 
218  // register macroscopic SUE-settings
219  oc.doRegister("assignment-method", new Option_String("incremental"));
220  oc.addDescription("assignment-method", "Processing", "Choose a assignment method: incremental, UE or SUE");
221 
222  oc.doRegister("tolerance", new Option_Float(SUMOReal(0.001)));
223  oc.addDescription("tolerance", "Processing", "Use FLOAT as tolerance when checking for SUE stability");
224 
225  oc.doRegister("left-turn-penalty", new Option_Float(SUMOReal(0)));
226  oc.addDescription("left-turn-penalty", "Processing", "Use left-turn penalty FLOAT to calculate link travel time when searching routes");
227 
228  oc.doRegister("paths", new Option_Integer(1));
229  oc.addDescription("paths", "Processing", "Use INTEGER as the number of paths needed to be searched for each OD pair at each iteration");
230 
231  oc.doRegister("paths.penalty", new Option_Float(SUMOReal(1)));
232  oc.addDescription("paths.penalty", "Processing", "Penalize existing routes with FLOAT to find secondary routes");
233 
234  oc.doRegister("upperbound", new Option_Float(SUMOReal(0.5)));
235  oc.addSynonyme("upperbound", "upper", true);
236  oc.addDescription("upperbound", "Processing", "Use FLOAT as the upper bound to determine auxiliary link cost");
237 
238  oc.doRegister("lowerbound", new Option_Float(SUMOReal(0.15)));
239  oc.addSynonyme("lowerbound", "lower", true);
240  oc.addDescription("lowerbound", "Processing", "Use FLOAT as the lower bound to determine auxiliary link cost");
241 
242  oc.doRegister("max-iterations", 'i', new Option_Integer(20));
243  oc.addDescription("max-iterations", "Processing", "maximal number of iterations for new route searching in incremental and stochastic user assignment");
244 
245  oc.doRegister("max-inner-iterations", new Option_Integer(1000));
246  oc.addDescription("max-inner-iterations", "Processing", "maximal number of inner iterations for user equilibrium calcuation in the stochastic user assignment");
247 
248  // register route choice settings
249  oc.doRegister("route-choice-method", new Option_String("logit"));
250  oc.addDescription("route-choice-method", "Processing", "Choose a route choice method: gawron, logit, or lohse");
251 
252  oc.doRegister("gawron.beta", new Option_Float(SUMOReal(0.3)));
253  oc.addSynonyme("gawron.beta", "gBeta", true);
254  oc.addDescription("gawron.beta", "Processing", "Use FLOAT as Gawron's beta");
255 
256  oc.doRegister("gawron.a", new Option_Float(SUMOReal(0.05)));
257  oc.addSynonyme("gawron.a", "gA", true);
258  oc.addDescription("gawron.a", "Processing", "Use FLOAT as Gawron's a");
259 
260  oc.doRegister("exit-times", new Option_Bool(false));
261  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
262 
263  oc.doRegister("keep-all-routes", new Option_Bool(false));
264  oc.addDescription("keep-all-routes", "Processing", "Save routes with near zero probability");
265 
266  oc.doRegister("skip-new-routes", new Option_Bool(false));
267  oc.addDescription("skip-new-routes", "Processing", "Only reuse routes from input, do not calculate new ones");
268 
269  oc.doRegister("logit.beta", new Option_Float(SUMOReal(0.15))); // check: remove the default?
270  oc.addSynonyme("logit.beta", "lBeta", true);
271  oc.addDescription("logit.beta", "Processing", "Use FLOAT as (c-)logit's beta for the commonality factor");
272 
273  oc.doRegister("logit.gamma", new Option_Float(SUMOReal(1)));
274  oc.addSynonyme("logit.gamma", "lGamma", true);
275  oc.addDescription("logit.gamma", "Processing", "Use FLOAT as (c-)logit's gamma for the commonality factor");
276 
277  oc.doRegister("logit.theta", new Option_Float(SUMOReal(0.01)));
278  oc.addSynonyme("logit.theta", "lTheta", true);
279  oc.addDescription("logit.theta", "Processing", "Use FLOAT as (c-)logit's theta");
280 }
281 
282 
283 bool
286  if (oc.isSet("assignment-method") && oc.getString("assignment-method") != "incremental" && oc.getString("assignment-method") != "UE" && oc.getString("assignment-method") != "SUE") {
287  WRITE_ERROR("invalid assignment method");
288  return false;
289  }
290  if (oc.getString("route-choice-method") != "gawron" && oc.getString("route-choice-method") != "logit" && oc.getString("route-choice-method") != "lohse") {
291  WRITE_ERROR("invalid route choice method");
292  return false;
293  }
294  return true;
295 }
296 
297 
298 
299 /****************************************************************************/
300 
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:86
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:53
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:74
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
static void addAssignmentOptions()
Inserts dua options used by duarouter into the OptionsCont-singleton.
Definition: ROMAFrame.cpp:197
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter...
Definition: ROMAFrame.cpp:284
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:50
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static void addImportOptions()
Inserts import options used by duarouter into the OptionsCont-singleton.
Definition: ROMAFrame.cpp:79
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
#define SUMOTIME_MAXSTRING
Definition: SUMOTime.h:46
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
Definition: ROMAFrame.cpp:57
An integer-option.
Definition: Option.h:309
A storage for options typed value containers)
Definition: OptionsCont.h:108
#define SUMOReal
Definition: config.h:214
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.