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-2020 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("route-files", 'r', new Option_FileName());
105  oc.addSynonyme("route-files", "routes");
106  oc.addSynonyme("route-files", "trips");
107  oc.addSynonyme("route-files", "trip-files");
108  oc.addDescription("route-files", "Input", "Read sumo-routes or trips from FILE(s)");
109 
110  oc.doRegister("weight-files", 'w', new Option_FileName());
111  oc.addSynonyme("weight-files", "weights");
112  oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)");
113 
114  oc.doRegister("lane-weight-files", new Option_FileName());
115  oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)");
116 
117  oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
118  oc.addSynonyme("weight-attribute", "measure", true);
119  oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
120 
121  oc.doRegister("weight-adaption", new Option_Float(0.));
122  oc.addDescription("weight-adaption", "Input", "The travel time influence of prior intervals");
123 
124  oc.doRegister("taz-param", new Option_StringVector());
125  oc.addDescription("taz-param", "Input", "Parameter key(s) defining source (and sink) taz");
126 
127  oc.doRegister("junction-taz", new Option_Bool(false));
128  oc.addDescription("junction-taz", "Input", "Initialize a TAZ for every junction to use attributes toJunction and fromJunction");
129 
130  // need to do this here to be able to check for network and route input options
132 
133  // register the time settings
134  oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
135  oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
136 
137  oc.doRegister("end", 'e', new Option_String(SUMOTIME_MAXSTRING, "TIME"));
138  oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
139 
140  // register the processing options
141  oc.doRegister("aggregation-interval", new Option_String("3600", "TIME"));
142  oc.addDescription("aggregation-interval", "Processing", "Defines the time interval when aggregating single vehicle input; Defaults to one hour");
143 
144  oc.doRegister("ignore-errors", new Option_Bool(false));
145  oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
146  oc.addSynonyme("ignore-errors", "dismiss-loading-errors", true);
147  oc.addDescription("ignore-errors", "Report", "Continue if a route could not be build");
148 
149  oc.doRegister("max-alternatives", new Option_Integer(5));
150  oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
151 
152  oc.doRegister("weights.interpolate", new Option_Bool(false));
153  oc.addSynonyme("weights.interpolate", "interpolate", true);
154  oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
155 
156  oc.doRegister("weights.expand", new Option_Bool(false));
157  oc.addSynonyme("weights.expand", "expand-weights", true);
158  oc.addDescription("weights.expand", "Processing", "Expand weights behind the simulation's end");
159 
160  oc.doRegister("weights.priority-factor", new Option_Float(0));
161  oc.addDescription("weights.priority-factor", "Processing", "Consider edge priorities in addition to travel times, weighted by factor");
162 
163  oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
164  oc.addDescription("routing-algorithm", "Processing", "Select among routing algorithms ['dijkstra', 'astar', 'CH', 'CHWrapper']");
165 
166  oc.doRegister("bulk-routing.vtypes", new Option_Bool(false));
167  oc.addDescription("bulk-routing.vtypes", "Processing", "Aggregate routing queries with the same origin for different vehicle types");
168 
169  oc.doRegister("routing-threads", new Option_Integer(0));
170  oc.addDescription("routing-threads", "Processing", "The number of parallel execution threads used for routing");
171 
172  oc.doRegister("weight-period", new Option_String("3600", "TIME"));
173  oc.addDescription("weight-period", "Processing", "Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy");
174 
175  // register defaults options
176  oc.doRegister("flow-output.departlane", new Option_String("free"));
177  oc.addSynonyme("flow-output.departlane", "departlane");
178  oc.addDescription("flow-output.departlane", "Defaults", "Assigns a default depart lane");
179 
180  oc.doRegister("flow-output.departpos", new Option_String());
181  oc.addSynonyme("flow-output.departpos", "departpos");
182  oc.addDescription("flow-output.departpos", "Defaults", "Assigns a default depart position");
183 
184  oc.doRegister("flow-output.departspeed", new Option_String("max"));
185  oc.addSynonyme("flow-output.departspeed", "departspeed");
186  oc.addDescription("flow-output.departspeed", "Defaults", "Assigns a default depart speed");
187 
188  oc.doRegister("flow-output.arrivallane", new Option_String());
189  oc.addSynonyme("flow-output.arrivallane", "arrivallane");
190  oc.addDescription("flow-output.arrivallane", "Defaults", "Assigns a default arrival lane");
191 
192  oc.doRegister("flow-output.arrivalpos", new Option_String());
193  oc.addSynonyme("flow-output.arrivalpos", "arrivalpos");
194  oc.addDescription("flow-output.arrivalpos", "Defaults", "Assigns a default arrival position");
195 
196  oc.doRegister("flow-output.arrivalspeed", new Option_String());
197  oc.addSynonyme("flow-output.arrivalspeed", "arrivalspeed");
198  oc.addDescription("flow-output.arrivalspeed", "Defaults", "Assigns a default arrival speed");
199 
200 }
201 
202 
203 void
206  // register the data processing options
207  oc.doRegister("scale", 's', new Option_Float(1));
208  oc.addDescription("scale", "Processing", "Scales the loaded flows by FLOAT");
209 
210  oc.doRegister("vtype", new Option_String(""));
211  oc.addDescription("vtype", "Processing", "Defines the name of the vehicle type to use");
212 
213  oc.doRegister("prefix", new Option_String(""));
214  oc.addDescription("prefix", "Processing", "Defines the prefix for vehicle flow names");
215 
216  oc.doRegister("timeline", new Option_StringVector());
217  oc.addDescription("timeline", "Processing", "Uses STR[] as a timeline definition");
218 
219  oc.doRegister("timeline.day-in-hours", new Option_Bool(false));
220  oc.addDescription("timeline.day-in-hours", "Processing", "Uses STR as a 24h-timeline definition");
221 
222  oc.doRegister("additive-traffic", new Option_Bool(false));
223  oc.addDescription("additive-traffic", "Processing", "Keep traffic flows of all time slots in the net");
224 
225  // register macroscopic SUE-settings
226  oc.doRegister("assignment-method", new Option_String("incremental"));
227  oc.addDescription("assignment-method", "Processing", "Choose a assignment method: incremental, UE or SUE");
228 
229  oc.doRegister("tolerance", new Option_Float(double(0.001)));
230  oc.addDescription("tolerance", "Processing", "Use FLOAT as tolerance when checking for SUE stability");
231 
232  oc.doRegister("left-turn-penalty", new Option_Float(0.));
233  oc.addDescription("left-turn-penalty", "Processing", "Use left-turn penalty FLOAT to calculate link travel time when searching routes");
234 
235  oc.doRegister("paths", new Option_Integer(1));
236  oc.addDescription("paths", "Processing", "Use INTEGER as the number of paths needed to be searched for each OD pair at each iteration");
237 
238  oc.doRegister("paths.penalty", new Option_Float(double(1)));
239  oc.addDescription("paths.penalty", "Processing", "Penalize existing routes with FLOAT to find secondary routes");
240 
241  oc.doRegister("upperbound", new Option_Float(double(0.5)));
242  oc.addSynonyme("upperbound", "upper", true);
243  oc.addDescription("upperbound", "Processing", "Use FLOAT as the upper bound to determine auxiliary link cost");
244 
245  oc.doRegister("lowerbound", new Option_Float(double(0.15)));
246  oc.addSynonyme("lowerbound", "lower", true);
247  oc.addDescription("lowerbound", "Processing", "Use FLOAT as the lower bound to determine auxiliary link cost");
248 
249  oc.doRegister("max-iterations", 'i', new Option_Integer(20));
250  oc.addDescription("max-iterations", "Processing", "maximal number of iterations for new route searching in incremental and stochastic user assignment");
251 
252  oc.doRegister("max-inner-iterations", new Option_Integer(1000));
253  oc.addDescription("max-inner-iterations", "Processing", "maximal number of inner iterations for user equilibrium calculation in the stochastic user assignment");
254 
255  // register route choice settings
256  oc.doRegister("route-choice-method", new Option_String("logit"));
257  oc.addDescription("route-choice-method", "Processing", "Choose a route choice method: gawron, logit, or lohse");
258 
259  oc.doRegister("gawron.beta", new Option_Float(double(0.3)));
260  oc.addSynonyme("gawron.beta", "gBeta", true);
261  oc.addDescription("gawron.beta", "Processing", "Use FLOAT as Gawron's beta");
262 
263  oc.doRegister("gawron.a", new Option_Float(double(0.05)));
264  oc.addSynonyme("gawron.a", "gA", true);
265  oc.addDescription("gawron.a", "Processing", "Use FLOAT as Gawron's a");
266 
267  oc.doRegister("exit-times", new Option_Bool(false));
268  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
269 
270  oc.doRegister("keep-all-routes", new Option_Bool(false));
271  oc.addDescription("keep-all-routes", "Processing", "Save routes with near zero probability");
272 
273  oc.doRegister("skip-new-routes", new Option_Bool(false));
274  oc.addDescription("skip-new-routes", "Processing", "Only reuse routes from input, do not calculate new ones");
275 
276  oc.doRegister("logit.beta", new Option_Float(double(0.15))); // check: remove the default?
277  oc.addSynonyme("logit.beta", "lBeta", true);
278  oc.addDescription("logit.beta", "Processing", "Use FLOAT as (c-)logit's beta for the commonality factor");
279 
280  oc.doRegister("logit.gamma", new Option_Float(double(1)));
281  oc.addSynonyme("logit.gamma", "lGamma", true);
282  oc.addDescription("logit.gamma", "Processing", "Use FLOAT as (c-)logit's gamma for the commonality factor");
283 
284  oc.doRegister("logit.theta", new Option_Float(double(0.01)));
285  oc.addSynonyme("logit.theta", "lTheta", true);
286  oc.addDescription("logit.theta", "Processing", "Use FLOAT as (c-)logit's theta");
287 }
288 
289 
290 bool
293  if (oc.isSet("assignment-method") && oc.getString("assignment-method") != "incremental" && oc.getString("assignment-method") != "UE" && oc.getString("assignment-method") != "SUE") {
294  WRITE_ERROR("invalid assignment method");
295  return false;
296  }
297  if (oc.getString("route-choice-method") != "gawron" && oc.getString("route-choice-method") != "logit" && oc.getString("route-choice-method") != "lohse") {
298  WRITE_ERROR("invalid route choice method");
299  return false;
300  }
301  return true;
302 }
303 
304 
305 /****************************************************************************/
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
#define SUMOTIME_MAXSTRING
Definition: SUMOTime.h:34
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.
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:291
static void addAssignmentOptions()
Inserts dua options used by duarouter into the OptionsCont-singleton.
Definition: ROMAFrame.cpp:204
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:44
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