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