Eclipse SUMO - Simulation of Urban MObility
ROMAFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Sets and checks options for ma-routing
22 /****************************************************************************/
23 #include <config.h>
24 
25 #include <iostream>
26 #include <fstream>
27 #include <ctime>
29 #include <utils/options/Option.h>
32 #include <utils/common/ToString.h>
33 #include "ROMAFrame.h"
34 #include <router/ROFrame.h>
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
43 void
46  oc.addCallExample("-c <CONFIGURATION>", "run routing with options from file");
47 
48  // insert options sub-topics
49  SystemFrame::addConfigurationOptions(oc); // fill this subtopic, too
50  oc.addOptionSubTopic("Input");
51  oc.addOptionSubTopic("Output");
52  oc.addOptionSubTopic("Processing");
53  oc.addOptionSubTopic("Defaults");
54  oc.addOptionSubTopic("Time");
55 
56  // insert options
59  // add rand options
61 }
62 
63 
64 void
67  // register import options
68  oc.doRegister("output-file", 'o', new Option_FileName());
69  oc.addSynonyme("output-file", "output");
70  oc.addDescription("output-file", "Output", "Write flow definitions with route distributions to FILE");
71 
72  oc.doRegister("vtype-output", new Option_FileName());
73  oc.addDescription("vtype-output", "Output", "Write used vehicle types into separate FILE");
74 
75  oc.doRegister("ignore-vehicle-type", new Option_Bool(false));
76  oc.addSynonyme("ignore-vehicle-type", "no-vtype", true);
77  oc.addDescription("ignore-vehicle-type", "Output", "Does not save vtype information");
78 
79  oc.doRegister("netload-output", new Option_FileName());
80  oc.addDescription("netload-output", "Output", "Writes edge loads and final costs into FILE");
81 
82  oc.doRegister("all-pairs-output", new Option_FileName());
83  oc.addDescription("all-pairs-output", "Output", "Writes complete distance matrix into FILE");
84 
85  oc.doRegister("net-file", 'n', new Option_FileName());
86  oc.addSynonyme("net-file", "net");
87  oc.addDescription("net-file", "Input", "Use FILE as SUMO-network to route on");
88 
89  oc.doRegister("additional-files", 'd', new Option_FileName());
90  oc.addSynonyme("additional-files", "additional");
91  oc.addSynonyme("additional-files", "taz-files");
92  oc.addSynonyme("additional-files", "districts", true);
93  oc.addDescription("additional-files", "Input", "Read additional network data (districts, bus stops) from FILE");
94 
95  oc.doRegister("od-matrix-files", 'm', new Option_FileName());
96  oc.addSynonyme("od-matrix-files", "od-files");
97  oc.addDescription("od-matrix-files", "Input", "Loads O/D-files from FILE(s)");
98 
99  oc.doRegister("od-amitran-files", new Option_FileName());
100  oc.addSynonyme("od-amitran-files", "amitran-files");
101  oc.addSynonyme("od-amitran-files", "amitran");
102  oc.addDescription("od-amitran-files", "Input", "Loads O/D-matrix in Amitran format from FILE(s)");
103 
104  oc.doRegister("tazrelation-files", 'z', new Option_FileName());
105  oc.addDescription("tazrelation-files", "Input", "Loads O/D-matrix in tazRelation format from FILE(s)");
106 
107  oc.doRegister("tazrelation-attribute", new Option_String("count"));
108  oc.addSynonyme("tazrelation-attribute", "attribute");
109  oc.addDescription("tazrelation-attribute", "Input", "Define data attribute for loading counts (default 'count')");
110 
111  oc.doRegister("route-files", 'r', new Option_FileName());
112  oc.addSynonyme("route-files", "routes");
113  oc.addSynonyme("route-files", "trips");
114  oc.addSynonyme("route-files", "trip-files");
115  oc.addDescription("route-files", "Input", "Read sumo-routes or trips from FILE(s)");
116 
117  oc.doRegister("weight-files", 'w', new Option_FileName());
118  oc.addSynonyme("weight-files", "weights");
119  oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)");
120 
121  oc.doRegister("lane-weight-files", new Option_FileName());
122  oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)");
123 
124  oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
125  oc.addSynonyme("weight-attribute", "measure", true);
126  oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
127 
128  oc.doRegister("weight-adaption", new Option_Float(0.));
129  oc.addDescription("weight-adaption", "Input", "The travel time influence of prior intervals");
130 
131  oc.doRegister("taz-param", new Option_StringVector());
132  oc.addDescription("taz-param", "Input", "Parameter key(s) defining source (and sink) taz");
133 
134  oc.doRegister("junction-taz", new Option_Bool(false));
135  oc.addDescription("junction-taz", "Input", "Initialize a TAZ for every junction to use attributes toJunction and fromJunction");
136 
137  oc.doRegister("ignore-taz", new Option_Bool(false));
138  oc.addDescription("ignore-taz", "Input", "Ignore attributes 'fromTaz' and 'toTaz'");
139 
140  // need to do this here to be able to check for network and route input options
142 
143  // register the time settings
144  oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
145  oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
146 
147  oc.doRegister("end", 'e', new Option_String("-1", "TIME"));
148  oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
149 
150  // register the processing options
151  oc.doRegister("aggregation-interval", new Option_String("3600", "TIME"));
152  oc.addDescription("aggregation-interval", "Processing", "Defines the time interval when aggregating single vehicle input; Defaults to one hour");
153 
154  oc.doRegister("ignore-errors", new Option_Bool(false));
155  oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
156  oc.addSynonyme("ignore-errors", "dismiss-loading-errors", true);
157  oc.addDescription("ignore-errors", "Report", "Continue if a route could not be build");
158 
159  oc.doRegister("max-alternatives", new Option_Integer(5));
160  oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
161 
162  oc.doRegister("capacities.default", new Option_Bool(false));
163  oc.addDescription("capacities.default", "Processing", "Ignore edge priorities when calculating capacities and restraints");
164 
165  oc.doRegister("weights.interpolate", new Option_Bool(false));
166  oc.addSynonyme("weights.interpolate", "interpolate", true);
167  oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
168 
169  oc.doRegister("weights.expand", new Option_Bool(false));
170  oc.addSynonyme("weights.expand", "expand-weights", true);
171  oc.addDescription("weights.expand", "Processing", "Expand weights behind the simulation's end");
172 
173  oc.doRegister("weights.priority-factor", new Option_Float(0));
174  oc.addDescription("weights.priority-factor", "Processing", "Consider edge priorities in addition to travel times, weighted by factor");
175 
176  oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
177  oc.addDescription("routing-algorithm", "Processing", "Select among routing algorithms ['dijkstra', 'astar', 'CH', 'CHWrapper']");
178 
179  oc.doRegister("bulk-routing.vtypes", new Option_Bool(false));
180  oc.addDescription("bulk-routing.vtypes", "Processing", "Aggregate routing queries with the same origin for different vehicle types");
181 
182  oc.doRegister("routing-threads", new Option_Integer(0));
183  oc.addDescription("routing-threads", "Processing", "The number of parallel execution threads used for routing");
184 
185  oc.doRegister("weight-period", new Option_String("3600", "TIME"));
186  oc.addDescription("weight-period", "Processing", "Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy");
187 
188  // register defaults options
189  oc.doRegister("flow-output.departlane", new Option_String("free"));
190  oc.addSynonyme("flow-output.departlane", "departlane");
191  oc.addDescription("flow-output.departlane", "Defaults", "Assigns a default depart lane");
192 
193  oc.doRegister("flow-output.departpos", new Option_String());
194  oc.addSynonyme("flow-output.departpos", "departpos");
195  oc.addDescription("flow-output.departpos", "Defaults", "Assigns a default depart position");
196 
197  oc.doRegister("flow-output.departspeed", new Option_String("max"));
198  oc.addSynonyme("flow-output.departspeed", "departspeed");
199  oc.addDescription("flow-output.departspeed", "Defaults", "Assigns a default depart speed");
200 
201  oc.doRegister("flow-output.arrivallane", new Option_String());
202  oc.addSynonyme("flow-output.arrivallane", "arrivallane");
203  oc.addDescription("flow-output.arrivallane", "Defaults", "Assigns a default arrival lane");
204 
205  oc.doRegister("flow-output.arrivalpos", new Option_String());
206  oc.addSynonyme("flow-output.arrivalpos", "arrivalpos");
207  oc.addDescription("flow-output.arrivalpos", "Defaults", "Assigns a default arrival position");
208 
209  oc.doRegister("flow-output.arrivalspeed", new Option_String());
210  oc.addSynonyme("flow-output.arrivalspeed", "arrivalspeed");
211  oc.addDescription("flow-output.arrivalspeed", "Defaults", "Assigns a default arrival speed");
212 
213 }
214 
215 
216 void
219  // register the data processing options
220  oc.doRegister("scale", 's', new Option_Float(1));
221  oc.addDescription("scale", "Processing", "Scales the loaded flows by FLOAT");
222 
223  oc.doRegister("vtype", new Option_String(""));
224  oc.addDescription("vtype", "Processing", "Defines the name of the vehicle type to use");
225 
226  oc.doRegister("prefix", new Option_String(""));
227  oc.addDescription("prefix", "Processing", "Defines the prefix for vehicle flow names");
228 
229  oc.doRegister("timeline", new Option_StringVector());
230  oc.addDescription("timeline", "Processing", "Uses STR[] as a timeline definition");
231 
232  oc.doRegister("timeline.day-in-hours", new Option_Bool(false));
233  oc.addDescription("timeline.day-in-hours", "Processing", "Uses STR as a 24h-timeline definition");
234 
235  oc.doRegister("additive-traffic", new Option_Bool(false));
236  oc.addDescription("additive-traffic", "Processing", "Keep traffic flows of all time slots in the net");
237 
238  // register macroscopic SUE-settings
239  oc.doRegister("assignment-method", new Option_String("incremental"));
240  oc.addDescription("assignment-method", "Processing", "Choose a assignment method: incremental, UE or SUE");
241 
242  oc.doRegister("tolerance", new Option_Float(double(0.001)));
243  oc.addDescription("tolerance", "Processing", "Use FLOAT as tolerance when checking for SUE stability");
244 
245  oc.doRegister("left-turn-penalty", new Option_Float(0.));
246  oc.addDescription("left-turn-penalty", "Processing", "Use left-turn penalty FLOAT to calculate link travel time when searching routes");
247 
248  oc.doRegister("paths", new Option_Integer(1));
249  oc.addDescription("paths", "Processing", "Use INTEGER as the number of paths needed to be searched for each OD pair at each iteration");
250 
251  oc.doRegister("paths.penalty", new Option_Float(double(1)));
252  oc.addDescription("paths.penalty", "Processing", "Penalize existing routes with FLOAT to find secondary routes");
253 
254  oc.doRegister("upperbound", new Option_Float(double(0.5)));
255  oc.addSynonyme("upperbound", "upper", true);
256  oc.addDescription("upperbound", "Processing", "Use FLOAT as the upper bound to determine auxiliary link cost");
257 
258  oc.doRegister("lowerbound", new Option_Float(double(0.15)));
259  oc.addSynonyme("lowerbound", "lower", true);
260  oc.addDescription("lowerbound", "Processing", "Use FLOAT as the lower bound to determine auxiliary link cost");
261 
262  oc.doRegister("max-iterations", 'i', new Option_Integer(20));
263  oc.addDescription("max-iterations", "Processing", "maximal number of iterations for new route searching in incremental and stochastic user assignment");
264 
265  oc.doRegister("max-inner-iterations", new Option_Integer(1000));
266  oc.addDescription("max-inner-iterations", "Processing", "maximal number of inner iterations for user equilibrium calculation in the stochastic user assignment");
267 
268  // register route choice settings
269  oc.doRegister("route-choice-method", new Option_String("logit"));
270  oc.addDescription("route-choice-method", "Processing", "Choose a route choice method: gawron, logit, or lohse");
271 
272  oc.doRegister("gawron.beta", new Option_Float(double(0.3)));
273  oc.addSynonyme("gawron.beta", "gBeta", true);
274  oc.addDescription("gawron.beta", "Processing", "Use FLOAT as Gawron's beta");
275 
276  oc.doRegister("gawron.a", new Option_Float(double(0.05)));
277  oc.addSynonyme("gawron.a", "gA", true);
278  oc.addDescription("gawron.a", "Processing", "Use FLOAT as Gawron's a");
279 
280  oc.doRegister("exit-times", new Option_Bool(false));
281  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
282 
283  oc.doRegister("keep-all-routes", new Option_Bool(false));
284  oc.addDescription("keep-all-routes", "Processing", "Save routes with near zero probability");
285 
286  oc.doRegister("skip-new-routes", new Option_Bool(false));
287  oc.addDescription("skip-new-routes", "Processing", "Only reuse routes from input, do not calculate new ones");
288 
289  oc.doRegister("logit.beta", new Option_Float(double(0.15))); // check: remove the default?
290  oc.addSynonyme("logit.beta", "lBeta", true);
291  oc.addDescription("logit.beta", "Processing", "Use FLOAT as (c-)logit's beta for the commonality factor");
292 
293  oc.doRegister("logit.gamma", new Option_Float(double(1)));
294  oc.addSynonyme("logit.gamma", "lGamma", true);
295  oc.addDescription("logit.gamma", "Processing", "Use FLOAT as (c-)logit's gamma for the commonality factor");
296 
297  oc.doRegister("logit.theta", new Option_Float(double(0.01)));
298  oc.addSynonyme("logit.theta", "lTheta", true);
299  oc.addDescription("logit.theta", "Processing", "Use FLOAT as (c-)logit's theta");
300 }
301 
302 
303 bool
306  if (oc.isSet("assignment-method") && oc.getString("assignment-method") != "incremental" && oc.getString("assignment-method") != "UE" && oc.getString("assignment-method") != "SUE") {
307  WRITE_ERROR("Invalid assignment method '" + oc.getString("assignment-method") + "'.");
308  return false;
309  }
310  if (oc.getString("route-choice-method") != "gawron" && oc.getString("route-choice-method") != "logit" && oc.getString("route-choice-method") != "lohse") {
311  WRITE_ERROR("Invalid route choice method '" + oc.getString("route-choice-method") + "'.");
312  return false;
313  }
314  if (oc.getInt("paths") > 1 && (oc.getString("routing-algorithm") == "CH" || oc.getString("routing-algorithm") == "CHWrapper")) {
315  WRITE_WARNING("Contraction hierarchies do not work with k shortest path search (please use a different routing algorithm)!");
316  }
317  return true;
318 }
319 
320 
321 /****************************************************************************/
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
An integer-option.
Definition: Option.h:329
A storage for options typed value containers)
Definition: OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:75
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
Definition: OptionsCont.cpp:96
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
Definition: ROMAFrame.cpp:44
static void addImportOptions()
Inserts import options used by duarouter into the OptionsCont-singleton.
Definition: ROMAFrame.cpp:65
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter.
Definition: ROMAFrame.cpp:304
static void addAssignmentOptions()
Inserts dua options used by duarouter into the OptionsCont-singleton.
Definition: ROMAFrame.cpp:217
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:43
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:38
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:63