SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ROMAFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Sets and checks options for dua-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 route distributions to FILE");
85 
86  oc.doRegister("flow-output", new Option_FileName());
87  oc.addDescription("flow-output", "Output", "Writes flow definitions into 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("weight-files", 'w', new Option_FileName());
119  oc.addSynonyme("weight-files", "weights");
120  oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)");
121 
122  oc.doRegister("lane-weight-files", new Option_FileName());
123  oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)");
124 
125  oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
126  oc.addSynonyme("weight-attribute", "measure", true);
127  oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
128 
129  // register the time settings
130  oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
131  oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
132 
133  oc.doRegister("end", 'e', new Option_String(SUMOTIME_MAXSTRING, "TIME"));
134  oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
135 
136  // register the processing options
137  oc.doRegister("ignore-errors", new Option_Bool(false));
138  oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
139  oc.addSynonyme("ignore-errors", "dismiss-loading-errors", true);
140  oc.addDescription("ignore-errors", "Processing", "Continue if a route could not be build");
141 
142  oc.doRegister("max-alternatives", new Option_Integer(5));
143  oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
144 
145  oc.doRegister("weights.interpolate", new Option_Bool(false));
146  oc.addSynonyme("weights.interpolate", "interpolate", true);
147  oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
148 
149  oc.doRegister("weights.expand", new Option_Bool(false));
150  oc.addSynonyme("weights.expand", "expand-weights", true);
151  oc.addDescription("weights.expand", "Processing", "Expand weights behind the simulation's end");
152 
153  oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
154  oc.addDescription("routing-algorithm", "Processing", "Select among routing algorithms ['dijkstra', 'astar', 'bulkstar', 'CH', 'CHWrapper']");
155 
156  oc.doRegister("weight-period", new Option_String("3600", "TIME"));
157  oc.addDescription("weight-period", "Processing", "Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy");
158 
159  // register defaults options
160  oc.doRegister("flow-output.departlane", new Option_String("free"));
161  oc.addSynonyme("flow-output.departlane", "departlane");
162  oc.addDescription("flow-output.departlane", "Defaults", "Assigns a default depart lane");
163 
164  oc.doRegister("flow-output.departpos", new Option_String());
165  oc.addSynonyme("flow-output.departpos", "departpos");
166  oc.addDescription("flow-output.departpos", "Defaults", "Assigns a default depart position");
167 
168  oc.doRegister("flow-output.departspeed", new Option_String("max"));
169  oc.addSynonyme("flow-output.departspeed", "departspeed");
170  oc.addDescription("flow-output.departspeed", "Defaults", "Assigns a default depart speed");
171 
172  oc.doRegister("flow-output.arrivallane", new Option_String());
173  oc.addSynonyme("flow-output.arrivallane", "arrivallane");
174  oc.addDescription("flow-output.arrivallane", "Defaults", "Assigns a default arrival lane");
175 
176  oc.doRegister("flow-output.arrivalpos", new Option_String());
177  oc.addSynonyme("flow-output.arrivalpos", "arrivalpos");
178  oc.addDescription("flow-output.arrivalpos", "Defaults", "Assigns a default arrival position");
179 
180  oc.doRegister("flow-output.arrivalspeed", new Option_String());
181  oc.addSynonyme("flow-output.arrivalspeed", "arrivalspeed");
182  oc.addDescription("flow-output.arrivalspeed", "Defaults", "Assigns a default arrival speed");
183 
184 }
185 
186 
187 void
190  // register the data processing options
191  oc.doRegister("scale", 's', new Option_Float(1));
192  oc.addDescription("scale", "Processing", "Scales the loaded flows by FLOAT");
193 
194  oc.doRegister("vtype", new Option_String(""));
195  oc.addDescription("vtype", "Processing", "Defines the name of the vehicle type to use");
196 
197  oc.doRegister("prefix", new Option_String(""));
198  oc.addDescription("prefix", "Processing", "Defines the prefix for vehicle flow names");
199 
200  oc.doRegister("timeline", new Option_String());
201  oc.addDescription("timeline", "Processing", "Uses STR as a timeline definition");
202 
203  oc.doRegister("timeline.day-in-hours", new Option_Bool(false));
204  oc.addDescription("timeline.day-in-hours", "Processing", "Uses STR as a 24h-timeline definition");
205 
206  // register macroscopic SUE-settings
207  oc.doRegister("assignment-method", new Option_String("incremental"));
208  oc.addDescription("assignment-method", "Processing", "Choose a assignment method: incremental, UE or SUE");
209 
210  oc.doRegister("tolerance", new Option_Float(SUMOReal(0.001)));
211  oc.addDescription("tolerance", "Processing", "Use FLOAT as tolerance when checking for SUE stability");
212 
213  oc.doRegister("left-turn-penalty", new Option_Float(SUMOReal(0)));
214  oc.addDescription("left-turn-penalty", "Processing", "Use left-turn penalty FLOAT to calculate link travel time when searching routes");
215 
216  oc.doRegister("paths", new Option_Integer(1));
217  oc.addDescription("paths", "Processing", "Use INTEGER as the number of paths needed to be searched for each OD pair at each iteration");
218 
219  oc.doRegister("paths.penalty", new Option_Float(SUMOReal(1)));
220  oc.addDescription("paths.penalty", "Processing", "Penalize existing routes with FLOAT to find secondary routes");
221 
222  oc.doRegister("upperbound", new Option_Float(SUMOReal(0.5)));
223  oc.addSynonyme("upperbound", "upper", true);
224  oc.addDescription("upperbound", "Processing", "Use FLOAT as the upper bound to determine auxiliary link cost");
225 
226  oc.doRegister("lowerbound", new Option_Float(SUMOReal(0.15)));
227  oc.addSynonyme("lowerbound", "lower", true);
228  oc.addDescription("lowerbound", "Processing", "Use FLOAT as the lower bound to determine auxiliary link cost");
229 
230  oc.doRegister("max-iterations", 'i', new Option_Integer(20));
231  oc.addDescription("max-iterations", "Processing", "maximal number of iterations for new route searching in incremental and stochastic user assignment");
232 
233  oc.doRegister("max-inner-iterations", new Option_Integer(1000));
234  oc.addDescription("max-inner-iterations", "Processing", "maximal number of inner iterations for user equilibrium calcuation in the stochastic user assignment");
235 
236  // register route choice settings
237  oc.doRegister("route-choice-method", new Option_String("logit"));
238  oc.addDescription("route-choice-method", "Processing", "Choose a route choice method: gawron, logit, or lohse");
239 
240  oc.doRegister("gawron.beta", new Option_Float(SUMOReal(0.3)));
241  oc.addSynonyme("gawron.beta", "gBeta", true);
242  oc.addDescription("gawron.beta", "Processing", "Use FLOAT as Gawron's beta");
243 
244  oc.doRegister("gawron.a", new Option_Float(SUMOReal(0.05)));
245  oc.addSynonyme("gawron.a", "gA", true);
246  oc.addDescription("gawron.a", "Processing", "Use FLOAT as Gawron's a");
247 
248  oc.doRegister("exit-times", new Option_Bool(false));
249  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
250 
251  oc.doRegister("keep-all-routes", new Option_Bool(false));
252  oc.addDescription("keep-all-routes", "Processing", "Save routes with near zero probability");
253 
254  oc.doRegister("skip-new-routes", new Option_Bool(false));
255  oc.addDescription("skip-new-routes", "Processing", "Only reuse routes from input, do not calculate new ones");
256 
257  oc.doRegister("logit.beta", new Option_Float(SUMOReal(0.15))); // check: remove the default?
258  oc.addSynonyme("logit.beta", "lBeta", true);
259  oc.addDescription("logit.beta", "Processing", "Use FLOAT as (c-)logit's beta for the commonality factor");
260 
261  oc.doRegister("logit.gamma", new Option_Float(SUMOReal(1)));
262  oc.addSynonyme("logit.gamma", "lGamma", true);
263  oc.addDescription("logit.gamma", "Processing", "Use FLOAT as (c-)logit's gamma for the commonality factor");
264 
265  oc.doRegister("logit.theta", new Option_Float(SUMOReal(0.01)));
266  oc.addSynonyme("logit.theta", "lTheta", true);
267  oc.addDescription("logit.theta", "Processing", "Use FLOAT as (c-)logit's theta");
268 }
269 
270 
271 bool
274  if (oc.isSet("assignment-method") && oc.getString("assignment-method") != "incremental" && oc.getString("assignment-method") != "UE" && oc.getString("assignment-method") != "SUE") {
275  WRITE_ERROR("invalid assignment method");
276  return false;
277  }
278  if (oc.getString("route-choice-method") != "gawron" && oc.getString("route-choice-method") != "logit" && oc.getString("route-choice-methods") != "lohse") {
279  WRITE_ERROR("invalid route choice method");
280  return false;
281  }
282  return true;
283 }
284 
285 
286 
287 /****************************************************************************/
288 
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:84
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:188
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter...
Definition: ROMAFrame.cpp:272
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:67
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:218
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.