SUMO - Simulation of Urban MObility
MSFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
23 // Sets and checks options for microsim; inits global outputs and settings
24 /****************************************************************************/
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <iostream>
37 #include <iomanip>
38 #include <fstream>
39 #include <ctime>
41 #include <utils/options/Option.h>
44 #include <utils/common/ToString.h>
48 #include <microsim/MSBaseVehicle.h>
49 #include <microsim/MSJunction.h>
50 #include <microsim/MSRoute.h>
51 #include <microsim/MSNet.h>
52 #include <microsim/MSGlobals.h>
58 #include "MSFrame.h"
60 
61 
62 // ===========================================================================
63 // method definitions
64 // ===========================================================================
65 void
68  oc.addCallExample("-b 0 -e 1000 -n net.xml -r routes.xml", "start a simulation from time 0 to 1000 with given net and routes");
69  oc.addCallExample("-c munich_config.cfg", "start with a configuration file");
70  oc.addCallExample("--help", "print help");
71 
72  // insert options sub-topics
73  SystemFrame::addConfigurationOptions(oc); // fill this subtopic, too
74  oc.addOptionSubTopic("Input");
75  oc.addOptionSubTopic("Output");
76  oc.addOptionSubTopic("Time");
77  oc.addOptionSubTopic("Processing");
78  oc.addOptionSubTopic("Routing");
79  SystemFrame::addReportOptions(oc); // fill this subtopic, too
80 
81 
82  // register configuration options
83  // register input options
84  oc.doRegister("net-file", 'n', new Option_FileName());
85  oc.addSynonyme("net-file", "net");
86  oc.addDescription("net-file", "Input", "Load road network description from FILE");
87  oc.addXMLDefault("net-file", "net");
88 
89  oc.doRegister("route-files", 'r', new Option_FileName());
90  oc.addSynonyme("route-files", "routes");
91  oc.addDescription("route-files", "Input", "Load routes descriptions from FILE(s)");
92 
93  oc.doRegister("additional-files", 'a', new Option_FileName());
94  oc.addSynonyme("additional-files", "additional");
95  oc.addDescription("additional-files", "Input", "Load further descriptions from FILE(s)");
96 
97  oc.doRegister("weight-files", 'w', new Option_FileName());
98  oc.addSynonyme("weight-files", "weights");
99  oc.addDescription("weight-files", "Input", "Load edge/lane weights for online rerouting from FILE");
100  oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
101  oc.addSynonyme("weight-attribute", "measure", true);
102  oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
103 
104  oc.doRegister("load-state", new Option_FileName());
105  oc.addDescription("load-state", "Input", "Loads a network state from FILE");
106  oc.doRegister("load-state.offset", new Option_String("0", "TIME"));
107  oc.addDescription("load-state.offset", "Input", "Shifts all times loaded from a saved state by the given offset");
108  oc.doRegister("load-state.remove-vehicles", new Option_String(""));
109  oc.addDescription("load-state.remove-vehicles", "Input", "Removes vehicles with the given IDs from the loaded state");
110 
111  // register output options
112  oc.doRegister("netstate-dump", new Option_FileName());
113  oc.addSynonyme("netstate-dump", "ndump");
114  oc.addSynonyme("netstate-dump", "netstate");
115  oc.addSynonyme("netstate-dump", "netstate-output");
116  oc.addDescription("netstate-dump", "Output", "Save complete network states into FILE");
117  oc.doRegister("netstate-dump.empty-edges", new Option_Bool(false));
118  oc.addSynonyme("netstate-dump.empty-edges", "netstate.empty-edges");
119  oc.addSynonyme("netstate-dump.empty-edges", "netstate-output.empty-edges");
120  oc.addSynonyme("netstate-dump.empty-edges", "dump-empty-edges", true);
121  oc.addDescription("netstate-dump.empty-edges", "Output", "Write also empty edges completely when dumping");
122  oc.doRegister("netstate-dump.precision", new Option_Integer(2));
123  oc.addSynonyme("netstate-dump.precision", "netstate.precision");
124  oc.addSynonyme("netstate-dump.precision", "netstate-output.precision");
125  oc.addSynonyme("netstate-dump.precision", "dump-precision", true);
126  oc.addDescription("netstate-dump.precision", "Output", "Write positions and speeds with the given precision (default 2)");
127 
128 
129  oc.doRegister("emission-output", new Option_FileName());
130  oc.addDescription("emission-output", "Output", "Save the emission values of each vehicle");
131  oc.doRegister("emission-output.precision", new Option_Integer(2));
132  oc.addDescription("emission-output.precision", "Output", "Write emission values with the given precision (default 2)");
133 
134  oc.doRegister("battery-output", new Option_FileName());
135  oc.addDescription("battery-output", "Output", "Save the battery values of each vehicle");
136  oc.doRegister("battery-output.precision", new Option_Integer(2));
137  oc.addDescription("battery-output.precision", "Output", "Write battery values with the given precision (default 2)");
138 
139  oc.doRegister("chargingstations-output", new Option_FileName());
140  oc.addDescription("chargingstations-output", "Output", "Write data of charging stations");
141 
142  oc.doRegister("fcd-output", new Option_FileName());
143  oc.addDescription("fcd-output", "Output", "Save the Floating Car Data");
144  oc.doRegister("fcd-output.geo", new Option_Bool(false));
145  oc.addDescription("fcd-output.geo", "Output", "Save the Floating Car Data using geo-coordinates (lon/lat)");
146  oc.doRegister("fcd-output.signals", new Option_Bool(false));
147  oc.addDescription("fcd-output.signals", "Output", "Add the vehicle signal state to the FCD output (brake lights etc.)");
148  oc.doRegister("full-output", new Option_FileName());
149  oc.addDescription("full-output", "Output", "Save a lot of information for each timestep (very redundant)");
150  oc.doRegister("queue-output", new Option_FileName());
151  oc.addDescription("queue-output", "Output", "Save the vehicle queues at the junctions (experimental)");
152  oc.doRegister("vtk-output", new Option_FileName());
153  oc.addDescription("vtk-output", "Output", "Save complete vehicle positions inclusive speed values in the VTK Format (usage: /path/out will produce /path/out_$TIMESTEP$.vtp files)");
154  oc.doRegister("amitran-output", new Option_FileName());
155  oc.addDescription("amitran-output", "Output", "Save the vehicle trajectories in the Amitran format");
156 
157 
158  oc.doRegister("summary-output", new Option_FileName());
159  oc.addSynonyme("summary-output", "summary");
160  oc.addDescription("summary-output", "Output", "Save aggregated vehicle departure info into FILE");
161 
162  oc.doRegister("tripinfo-output", new Option_FileName());
163  oc.addSynonyme("tripinfo-output", "tripinfo");
164  oc.addDescription("tripinfo-output", "Output", "Save single vehicle trip info into FILE");
165 
166  oc.doRegister("tripinfo-output.write-unfinished", new Option_Bool(false));
167  oc.addDescription("tripinfo-output.write-unfinished", "Output", "Write tripinfo output for vehicles which have not arrived at simulation end");
168 
169  oc.doRegister("vehroute-output", new Option_FileName());
170  oc.addSynonyme("vehroute-output", "vehroutes");
171  oc.addDescription("vehroute-output", "Output", "Save single vehicle route info into FILE");
172 
173  oc.doRegister("vehroute-output.exit-times", new Option_Bool(false));
174  oc.addSynonyme("vehroute-output.exit-times", "vehroutes.exit-times");
175  oc.addDescription("vehroute-output.exit-times", "Output", "Write the exit times for all edges");
176 
177  oc.doRegister("vehroute-output.last-route", new Option_Bool(false));
178  oc.addSynonyme("vehroute-output.last-route", "vehroutes.last-route");
179  oc.addDescription("vehroute-output.last-route", "Output", "Write the last route only");
180 
181  oc.doRegister("vehroute-output.sorted", new Option_Bool(false));
182  oc.addSynonyme("vehroute-output.sorted", "vehroutes.sorted");
183  oc.addDescription("vehroute-output.sorted", "Output", "Sorts the output by departure time");
184 
185  oc.doRegister("vehroute-output.dua", new Option_Bool(false));
186  oc.addSynonyme("vehroute-output.dua", "vehroutes.dua");
187  oc.addDescription("vehroute-output.dua", "Output", "Write the output in the duarouter alternatives style");
188 
189  oc.doRegister("vehroute-output.intended-depart", new Option_Bool(false));
190  oc.addSynonyme("vehroute-output.intended-depart", "vehroutes.intended-depart");
191  oc.addDescription("vehroute-output.intended-depart", "Output", "Write the output with the intended instead of the real departure time");
192 
193  oc.doRegister("vehroute-output.route-length", new Option_Bool(false));
194  oc.addSynonyme("vehroute-output.route-length", "vehroutes.route-length");
195  oc.addDescription("vehroute-output.route-length", "Output", "Include total route length in the output");
196 
197  oc.doRegister("vehroute-output.write-unfinished", new Option_Bool(false));
198  oc.addDescription("vehroute-output.write-unfinished", "Output", "Write vehroute output for vehicles which have not arrived at simulation end");
199 
200  oc.doRegister("vehroute-output.skip-ptlines", new Option_Bool(false));
201  oc.addDescription("vehroute-output.skip-ptlines", "Output", "Skip vehroute output for public transport vehicles");
202 
203  oc.doRegister("link-output", new Option_FileName());
204  oc.addDescription("link-output", "Output", "Save links states into FILE");
205 
206  oc.doRegister("bt-output", new Option_FileName());
207  oc.addDescription("bt-output", "Output", "Save bluetooth visibilities into FILE (in conjunction with device.btreceiver and device.btsender)");
208 
209  oc.doRegister("lanechange-output", new Option_FileName());
210  oc.addDescription("lanechange-output", "Output", "Record lane changes and their motivations for all vehicles into FILE");
211 
212  oc.doRegister("lanechange-output.started", new Option_Bool(false));
213  oc.addDescription("lanechange-output.started", "Output", "Record start of lane change manoeuvres");
214 
215  oc.doRegister("lanechange-output.ended", new Option_Bool(false));
216  oc.addDescription("lanechange-output.ended", "Output", "Record end of lane change manoeuvres");
217 
218  oc.doRegister("stop-output", new Option_FileName());
219  oc.addDescription("stop-output", "Output", "Record stops and loading/unloading of passenger and containers for all vehicles into FILE");
220 
221 #ifdef _DEBUG
222  oc.doRegister("movereminder-output", new Option_FileName());
223  oc.addDescription("movereminder-output", "Output", "Save movereminder states of selected vehicles into FILE");
224  oc.doRegister("movereminder-output.vehicles", new Option_String());
225  oc.addDescription("movereminder-output.vehicles", "Output", "List of vehicle ids which shall save their movereminder states");
226 #endif
227 
228  oc.doRegister("save-state.times", new Option_IntVector(IntVector()));
229  oc.addDescription("save-state.times", "Output", "Use INT[] as times at which a network state written");
230  oc.doRegister("save-state.period", new Option_String("-1", "TIME"));
231  oc.addDescription("save-state.period", "Output", "save state repeatedly after TIME period");
232  oc.doRegister("save-state.prefix", new Option_FileName("state"));
233  oc.addDescription("save-state.prefix", "Output", "Prefix for network states");
234  oc.doRegister("save-state.suffix", new Option_String(".sbx"));
235  oc.addDescription("save-state.suffix", "Output", "Suffix for network states (.sbx or .xml)");
236  oc.doRegister("save-state.files", new Option_FileName());//
237  oc.addDescription("save-state.files", "Output", "Files for network states");
238 
239  // register the simulation settings
240  oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
241  oc.addDescription("begin", "Time", "Defines the begin time in seconds; The simulation starts at this time");
242 
243  oc.doRegister("end", 'e', new Option_String("-1", "TIME"));
244  oc.addDescription("end", "Time", "Defines the end time in seconds; The simulation ends at this time");
245 
246  oc.doRegister("step-length", new Option_String("1", "TIME"));
247  oc.addDescription("step-length", "Time", "Defines the step duration in seconds");
248 
249  oc.doRegister("step-method.ballistic", new Option_Bool(false));
250  oc.addDescription("step-method.ballistic", "Processing", "Whether to use ballistic method for the positional update of vehicles (default is a semi-implicit Euler method).");
251 
252  oc.doRegister("lateral-resolution", new Option_Float(-1));
253  oc.addDescription("lateral-resolution", "Processing", "Defines the resolution in m when handling lateral positioning within a lane (with -1 all vehicles drive at the center of their lane");
254 
255  oc.doRegister("carfollow.model", new Option_String("Krauss"));
256  oc.addDescription("carfollow.model", "Processing", "Select default car following model (Krauss, IDM, ...)");
257  oc.addSynonyme("carfollow.model", "carfollowing.model", false);
258 
259  // register the processing options
260  oc.doRegister("route-steps", 's', new Option_String("200", "TIME"));
261  oc.addDescription("route-steps", "Processing", "Load routes for the next number of seconds ahead");
262 
263  oc.doRegister("no-internal-links", new Option_Bool(false));
264  oc.addDescription("no-internal-links", "Processing", "Disable (junction) internal links");
265 
266  oc.doRegister("ignore-junction-blocker", new Option_String("-1", "TIME"));
267  oc.addDescription("ignore-junction-blocker", "Processing", "Ignore vehicles which block the junction after they have been standing for SECONDS (-1 means never ignore)");
268 
269  oc.doRegister("ignore-route-errors", new Option_Bool(false));
270  oc.addDescription("ignore-route-errors", "Processing", "Do not check whether routes are connected");
271 
272  oc.doRegister("ignore-accidents", new Option_Bool(false));
273  oc.addDescription("ignore-accidents", "Processing", "Do not check whether accidents occur");
274 
275  oc.doRegister("collision.action", new Option_String("teleport"));
276  oc.addDescription("collision.action", "Processing", "How to deal with collisions: [none,warn,teleport,remove]");
277 
278  oc.doRegister("collision.stoptime", new Option_String("0", "TIME"));
279  oc.addDescription("collision.stoptime", "Processing", "Let vehicle stop for TIME before performing collision.action (except for action 'none')");
280 
281  oc.doRegister("collision.check-junctions", new Option_Bool(false));
282  oc.addDescription("collision.check-junctions", "Processing", "Enables collisions checks on junctions");
283 
284  oc.doRegister("collision.mingap-factor", new Option_Float(1.0));
285  oc.addDescription("collision.mingap-factor", "Processing", "Sets the fraction of minGap that must be maintained to avoid collision detection.");
286 
287  oc.doRegister("max-num-vehicles", new Option_Integer(-1));
288  oc.addDescription("max-num-vehicles", "Processing", "Delay vehicle insertion to stay within the given maximum number");
289 
290  oc.doRegister("max-num-teleports", new Option_Integer(-1));
291  oc.addDescription("max-num-teleports", "Processing", "Abort the simulation if the given maximum number of teleports is exceeded");
292 
293  oc.doRegister("scale", new Option_Float(1.));
294  oc.addDescription("scale", "Processing", "Scale demand by the given factor (by discarding or duplicating vehicles)");
295 
296  oc.doRegister("time-to-teleport", new Option_String("300", "TIME"));
297  oc.addDescription("time-to-teleport", "Processing", "Specify how long a vehicle may wait until being teleported, defaults to 300, non-positive values disable teleporting");
298 
299  oc.doRegister("time-to-teleport.highways", new Option_String("0", "TIME"));
300  oc.addDescription("time-to-teleport.highways", "Processing", "The waiting time after which vehicles on a fast road (speed > 69m/s) are teleported if they are on a non-continuing lane");
301 
302  oc.doRegister("waiting-time-memory", new Option_String("100", "TIME"));
303  oc.addDescription("waiting-time-memory", "Processing", "Length of time interval, over which accumulated waiting time is taken into account (default is 100s.)");
304 
305  oc.doRegister("max-depart-delay", new Option_String("-1", "TIME"));
306  oc.addDescription("max-depart-delay", "Processing", "How long vehicles wait for departure before being skipped, defaults to -1 which means vehicles are never skipped");
307 
308  oc.doRegister("sloppy-insert", new Option_Bool(false));
309  oc.addDescription("sloppy-insert", "Processing", "Whether insertion on an edge shall not be repeated in same step once failed");
310 
311  oc.doRegister("eager-insert", new Option_Bool(false));
312  oc.addDescription("eager-insert", "Processing", "Whether each vehicle is checked separately for insertion on an edge");
313 
314  oc.doRegister("random-depart-offset", new Option_String("0", "TIME"));
315  oc.addDescription("random-depart-offset", "Processing", "Each vehicle receives a random offset to its depart value drawn uniformly from [0, TIME]");
316 
317  oc.doRegister("lanechange.duration", new Option_String("0", "TIME"));
318  oc.addDescription("lanechange.duration", "Processing", "Duration of a lane change maneuver (default 0)");
319 
320  oc.doRegister("lanechange.overtake-right", new Option_Bool(false));
321  oc.addDescription("lanechange.overtake-right", "Processing", "Whether overtaking on the right on motorways is permitted");
322 
323  oc.doRegister("tls.all-off", new Option_Bool(false));
324  oc.addDescription("tls.all-off", "Processing", "Switches off all traffic lights.");
325 
326  oc.doRegister("time-to-impatience", new Option_String("300", "TIME"));
327  oc.addDescription("time-to-impatience", "Processing", "Specify how long a vehicle may wait until impatience grows from 0 to 1, defaults to 300, non-positive values disable impatience growth");
328 
329  oc.doRegister("default.action-step-length", new Option_Float(0.0));
330  oc.addDescription("default.action-step-length", "Processing", "Length of the default interval length between action points for the car-following and lane-change models (in seconds). If not specified, the simulation step-length is used per default. Vehicle- or VType-specific settings override the default. Must be a multiple of the simulation step-length.");
331 
332  // pedestrian model
333  oc.doRegister("pedestrian.model", new Option_String("striping"));
334  oc.addDescription("pedestrian.model", "Processing", "Select among pedestrian models ['nonInteracting', 'striping', 'remote']");
335 
336  oc.doRegister("pedestrian.striping.stripe-width", new Option_Float(0.64));
337  oc.addDescription("pedestrian.striping.stripe-width", "Processing", "Width of parallel stripes for segmenting a sidewalk (meters) for use with model 'striping'");
338 
339  oc.doRegister("pedestrian.striping.dawdling", new Option_Float(0.2));
340  oc.addDescription("pedestrian.striping.dawdling", "Processing", "factor for random slow-downs [0,1] for use with model 'striping'");
341 
342  oc.doRegister("pedestrian.striping.jamtime", new Option_String("300", "TIME"));
343  oc.addDescription("pedestrian.striping.jamtime", "Processing", "Time in seconds after which pedestrians start squeezing through a jam when using model 'striping' (non-positive values disable squeezing)");
344 
345  oc.doRegister("pedestrian.remote.address", new Option_String("localhost:9000"));
346  oc.addDescription("pedestrian.remote.address", "Processing", "The address (host:port) of the external simulation");
347 
348  // generic routing options
349  oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
350  oc.addDescription("routing-algorithm", "Routing",
351  "Select among routing algorithms ['dijkstra', 'astar', 'CH', 'CHWrapper']");
352  oc.doRegister("weights.random-factor", new Option_Float(1.));
353  oc.addDescription("weights.random-factor", "Routing", "Edge weights for routing are dynamically disturbed by a random factor drawn uniformly from [1,FLOAT)");
354 
355  oc.doRegister("astar.all-distances", new Option_FileName());
356  oc.addDescription("astar.all-distances", "Routing", "Initialize lookup table for astar from the given file (generated by marouter --all-pairs-output)");
357 
358  oc.doRegister("astar.landmark-distances", new Option_FileName());
359  oc.addDescription("astar.landmark-distances", "Routing", "Initialize lookup table for astar ALT-variant from the given file");
360 
361  oc.doRegister("persontrip.walkfactor", new Option_Float(double(0.75)));
362  oc.addDescription("persontrip.walkfactor", "Routing", "Use FLOAT as a factor on pedestrian maximum speed during intermodal routing");
363 
364  oc.doRegister("persontrip.transfer.car-walk", new Option_String("parkingAreas"));
365  oc.addDescription("persontrip.transfer.car-walk", "Routing", "Where are mode changes from car to walking allowed (possible values: 'parkingAreas', 'ptStops', 'allJunctions' and combinations)");
366 
367  // devices
368  oc.addOptionSubTopic("Emissions");
369  oc.doRegister("phemlight-path", new Option_FileName("./PHEMlight/"));
370  oc.addDescription("phemlight-path", "Emissions", "Determines where to load PHEMlight definitions from.");
371 
372  oc.addOptionSubTopic("Communication");
373  oc.addOptionSubTopic("Battery");
375 
376  // register report options
377  oc.doRegister("duration-log.disable", new Option_Bool(false));
378  oc.addSynonyme("duration-log.disable", "no-duration-log", false);
379  oc.addDescription("duration-log.disable", "Report", "Disable performance reports for individual simulation steps");
380 
381  oc.doRegister("duration-log.statistics", new Option_Bool(false));
382  oc.addDescription("duration-log.statistics", "Report", "Enable statistics on vehicle trips");
383 
384  oc.doRegister("no-step-log", new Option_Bool(false));
385  oc.addDescription("no-step-log", "Report", "Disable console output of current simulation step");
386 
387 
388 #ifndef NO_TRACI
389  //remote port 0 if not used
390  oc.addOptionSubTopic("TraCI Server");
391  oc.doRegister("remote-port", new Option_Integer(0));
392  oc.addDescription("remote-port", "TraCI Server", "Enables TraCI Server if set");
393  oc.doRegister("num-clients", new Option_Integer(1));
394  oc.addDescription("num-clients", "TraCI Server", "Expected number of connecting clients");
395 #ifdef HAVE_PYTHON
396  oc.doRegister("python-script", new Option_String());
397  oc.addDescription("python-script", "TraCI Server", "Runs TraCI script with embedded python");
398 #endif
399 #endif
400  //
401  oc.addOptionSubTopic("Mesoscopic");
402  oc.doRegister("mesosim", new Option_Bool(false));
403  oc.addDescription("mesosim", "Mesoscopic", "Enables mesoscopic simulation");
404  oc.doRegister("meso-edgelength", new Option_Float(98.0f));
405  oc.addDescription("meso-edgelength", "Mesoscopic", "Length of an edge segment in mesoscopic simulation");
406  oc.doRegister("meso-tauff", new Option_String("1.13", "TIME"));
407  oc.addDescription("meso-tauff", "Mesoscopic", "Factor for calculating the net free-free headway time");
408  oc.doRegister("meso-taufj", new Option_String("1.13", "TIME"));
409  oc.addDescription("meso-taufj", "Mesoscopic", "Factor for calculating the net free-jam headway time");
410  oc.doRegister("meso-taujf", new Option_String("1.73", "TIME"));
411  oc.addDescription("meso-taujf", "Mesoscopic", "Factor for calculating the jam-free headway time");
412  oc.doRegister("meso-taujj", new Option_String("1.4", "TIME"));
413  oc.addDescription("meso-taujj", "Mesoscopic", "Factor for calculating the jam-jam headway time");
414  oc.doRegister("meso-jam-threshold", new Option_Float(-1));
415  oc.addDescription("meso-jam-threshold", "Mesoscopic",
416  "Minimum percentage of occupied space to consider a segment jammed. A negative argument causes thresholds to be computed based on edge speed and tauff (default)");
417  oc.doRegister("meso-multi-queue", new Option_Bool(true));
418  oc.addDescription("meso-multi-queue", "Mesoscopic", "Enable multiple queues at edge ends");
419  oc.doRegister("meso-junction-control", new Option_Bool(false));
420  oc.addDescription("meso-junction-control", "Mesoscopic", "Enable mesoscopic traffic light and priority junction handling");
421  oc.doRegister("meso-junction-control.limited", new Option_Bool(false));
422  oc.addDescription("meso-junction-control.limited", "Mesoscopic",
423  "Enable mesoscopic traffic light and priority junction handling for saturated links. This prevents faulty traffic lights from hindering flow in low-traffic situations");
424  oc.doRegister("meso-tls-penalty", new Option_Float(0));
425  oc.addDescription("meso-tls-penalty", "Mesoscopic",
426  "Apply scaled time penalties when driving across tls controlled junctions based on green split instead of checking actual phases");
427  oc.doRegister("meso-minor-penalty", new Option_String("0", "TIME"));
428  oc.addDescription("meso-minor-penalty", "Mesoscopic",
429  "Apply fixed time penalty when driving across a minor link. When using --meso-junction-control.limited, the penalty is not applied whenever limited control is active.");
430  oc.doRegister("meso-overtaking", new Option_Bool(false));
431  oc.addDescription("meso-overtaking", "Mesoscopic", "Enable mesoscopic overtaking");
432  oc.doRegister("meso-recheck", new Option_String("0", "TIME"));
433  oc.addDescription("meso-recheck", "Mesoscopic", "Time interval for rechecking insertion into the next segment after failure");
434 
435  // add rand options
437 
438  // add GUI options
439  // the reason that we include them in vanilla sumo as well is to make reusing config files easy
440  oc.addOptionSubTopic("GUI Only");
441  oc.doRegister("gui-settings-file", new Option_FileName());
442  oc.addDescription("gui-settings-file", "GUI Only", "Load visualisation settings from FILE");
443 
444  oc.doRegister("quit-on-end", 'Q', new Option_Bool(false));
445  oc.addDescription("quit-on-end", "GUI Only", "Quits the GUI when the simulation stops");
446 
447  oc.doRegister("game", 'G', new Option_Bool(false));
448  oc.addDescription("game", "GUI Only", "Start the GUI in gaming mode");
449 
450  oc.doRegister("start", 'S', new Option_Bool(false));
451  oc.addDescription("start", "GUI Only", "Start the simulation after loading");
452 
453  oc.doRegister("demo", 'D', new Option_Bool(false));
454  oc.addDescription("demo", "GUI Only", "Restart the simulation after ending (demo mode)");
455 
456  oc.doRegister("disable-textures", 'T', new Option_Bool(false));
457  oc.addDescription("disable-textures", "GUI Only", "Do not load background pictures");
458 
459  oc.doRegister("window-size", new Option_String());
460  oc.addDescription("window-size", "GUI Only", "Create initial window with the given x,y size");
461 
462  oc.doRegister("window-pos", new Option_String());
463  oc.addDescription("window-pos", "GUI Only", "Create initial window at the given x,y position");
464 
465  oc.doRegister("tracker-interval", new Option_Float(1.0));
466  oc.addDescription("tracker-interval", "GUI Only", "The aggregation period for value tracker windows");
467 
468 #ifdef HAVE_OSG
469  oc.doRegister("osg-view", new Option_Bool(false));
470  oc.addDescription("osg-view", "GUI Only", "Start with an OpenSceneGraph view instead of the regular 2D view");
471 #endif
472 
473  // gui testing
474  oc.doRegister("gui-testing", new Option_Bool(false));
475  oc.addDescription("gui-testing", "GUI Only", "Enable ovelay for screen recognition");
476 
477  // gui testing - debug
478  oc.doRegister("gui-testing-debug", new Option_Bool(false));
479  oc.addDescription("gui-testing-debug", "GUI Only", "Enable output messages during GUI-Testing");
480 }
481 
482 
483 void
485  // standard outputs
486  OutputDevice::createDeviceByOption("netstate-dump", "netstate", "netstate_file.xsd");
487  OutputDevice::createDeviceByOption("summary-output", "summary", "summary_file.xsd");
488  OutputDevice::createDeviceByOption("tripinfo-output", "tripinfos", "tripinfo_file.xsd");
489 
490  //extended
491  OutputDevice::createDeviceByOption("fcd-output", "fcd-export", "fcd_file.xsd");
492  OutputDevice::createDeviceByOption("emission-output", "emission-export", "emission_file.xsd");
493  OutputDevice::createDeviceByOption("battery-output", "battery-export");
494  OutputDevice::createDeviceByOption("chargingstations-output", "chargingstations-export");
495  OutputDevice::createDeviceByOption("full-output", "full-export", "full_file.xsd");
496  OutputDevice::createDeviceByOption("queue-output", "queue-export", "queue_file.xsd");
497  OutputDevice::createDeviceByOption("amitran-output", "trajectories", "amitran/trajectories.xsd\" timeStepSize=\"" + toString(STEPS2MS(DELTA_T)));
498 
499  //OutputDevice::createDeviceByOption("vtk-output", "vtk-export");
500  OutputDevice::createDeviceByOption("link-output", "link-output");
501  OutputDevice::createDeviceByOption("bt-output", "bt-output");
502  OutputDevice::createDeviceByOption("lanechange-output", "lanechanges");
503  OutputDevice::createDeviceByOption("stop-output", "stops", "stopinfo_file.xsd");
504 
505 #ifdef _DEBUG
506  OutputDevice::createDeviceByOption("movereminder-output", "movereminder-output");
507 #endif
508 
510  MSStopOut::init();
511 }
512 
513 
514 bool
517  bool ok = true;
518  if (!oc.isSet("net-file")) {
519  WRITE_ERROR("No network file (-n) specified.");
520  ok = false;
521  }
522  if (oc.getFloat("scale") < 0.) {
523  WRITE_ERROR("Invalid scaling factor.");
524  ok = false;
525  }
526  if (oc.getBool("vehroute-output.exit-times") && !oc.isSet("vehroute-output")) {
527  WRITE_ERROR("A vehroute-output file is needed for exit times.");
528  ok = false;
529  }
530  if (oc.isSet("gui-settings-file") &&
531  oc.getString("gui-settings-file") != "" &&
532  !oc.isUsableFileList("gui-settings-file")) {
533  ok = false;
534  }
535  if (oc.getBool("demo") && oc.isDefault("start")) {
536  oc.set("start", "true");
537  }
538  if (oc.getBool("demo") && oc.getBool("quit-on-end")) {
539  WRITE_ERROR("You can either restart or quit on end.");
540  ok = false;
541  }
542  if (oc.getBool("meso-junction-control.limited") && !oc.getBool("meso-junction-control")) {
543  oc.set("meso-junction-control", "true");
544  }
545  const SUMOTime begin = string2time(oc.getString("begin"));
546  const SUMOTime end = string2time(oc.getString("end"));
547  if (begin < 0) {
548  WRITE_ERROR("The begin time should not be negative.");
549  ok = false;
550  }
551  if (end != string2time("-1")) {
552  if (end < begin) {
553  WRITE_ERROR("The end time should be after the begin time.");
554  ok = false;
555  }
556  }
557  if (string2time(oc.getString("step-length")) <= 0) {
558  WRITE_ERROR("the minimum step-length is 0.001");
559  ok = false;
560  }
561 #ifdef _DEBUG
562  if (oc.isSet("movereminder-output.vehicles") && !oc.isSet("movereminder-output")) {
563  WRITE_ERROR("option movereminder-output.vehicles requires option movereminder-output to be set");
564  ok = false;
565  }
566 #endif
567  if (oc.getBool("sloppy-insert")) {
568  WRITE_WARNING("The option 'sloppy-insert' is deprecated, because it is now activated by default, see the new option 'eager-insert'.");
569  }
570  if (string2time(oc.getString("lanechange.duration")) > 0 && oc.getFloat("lateral-resolution") > 0) {
571  WRITE_ERROR("Only one of the options 'lanechange.duration' or 'lateral-resolution' may be given.");
572  }
573  if (oc.getBool("ignore-accidents")) {
574  WRITE_WARNING("The option 'ignore-accidents' is deprecated. Use 'collision.action none' instead.");
575  }
576 #ifndef NO_TRACI
577 #ifdef HAVE_PYTHON
578  if (oc.isSet("python-script")) {
579  WRITE_WARNING("The option 'python-script' is deprecated. Use libsumo or TraCI instead.");
580  }
581 #endif
582 #endif
583  if (oc.getBool("duration-log.statistics") && oc.isDefault("verbose")) {
584  oc.set("verbose", "true");
585  }
586  if (oc.isDefault("precision") && string2time(oc.getString("step-length")) < 10) {
587  oc.set("precision", "3");
588  }
589  if (oc.isDefault("tracker-interval") && !oc.isDefault("step-length")) {
590  oc.set("tracker-interval", oc.getString("step-length"));
591  }
592  if (oc.getInt("precision") > 2) {
593  if (oc.isDefault("netstate-dump.precision")) {
594  oc.set("netstate-dump.precision", toString(oc.getInt("precision")));
595  }
596  if (oc.isDefault("emission-output.precision")) {
597  oc.set("emission-output.precision", toString(oc.getInt("precision")));
598  }
599  if (oc.isDefault("battery-output.precision")) {
600  oc.set("battery-output.precision", toString(oc.getInt("precision")));
601  }
602  }
603  if (!SUMOXMLDefinitions::CarFollowModels.hasString(oc.getString("carfollow.model"))) {
604  WRITE_ERROR("Unknown model '" + oc.getString("carfollow.model") + "' for option 'carfollow.model'.");
605  ok = false;
606  }
607  ok &= MSDevice::checkOptions(oc);
609 
610  return ok;
611 }
612 
613 
614 void
616  // pre-initialise the network
617  // set whether empty edges shall be printed on dump
618  MSGlobals::gOmitEmptyEdgesOnDump = !oc.getBool("netstate-dump.empty-edges");
619  // set whether internal lanes shall be used
620  MSGlobals::gUsingInternalLanes = !oc.getBool("no-internal-links");
621  MSGlobals::gIgnoreJunctionBlocker = string2time(oc.getString("ignore-junction-blocker")) < 0 ?
622  std::numeric_limits<SUMOTime>::max() : string2time(oc.getString("ignore-junction-blocker"));
623  // set the grid lock time
624  MSGlobals::gTimeToGridlock = string2time(oc.getString("time-to-teleport")) < 0 ? 0 : string2time(oc.getString("time-to-teleport"));
625  MSGlobals::gTimeToImpatience = string2time(oc.getString("time-to-impatience"));
626  MSGlobals::gTimeToGridlockHighways = string2time(oc.getString("time-to-teleport.highways")) < 0 ? 0 : string2time(oc.getString("time-to-teleport.highways"));
627  MSGlobals::gCheck4Accidents = !oc.getBool("ignore-accidents");
628  MSGlobals::gCheckRoutes = !oc.getBool("ignore-route-errors");
629  MSGlobals::gLaneChangeDuration = string2time(oc.getString("lanechange.duration"));
630  MSGlobals::gLateralResolution = oc.getFloat("lateral-resolution");
631  MSGlobals::gStateLoaded = oc.isSet("load-state");
632  MSGlobals::gUseMesoSim = oc.getBool("mesosim");
633  MSGlobals::gMesoLimitedJunctionControl = oc.getBool("meso-junction-control.limited");
634  MSGlobals::gMesoOvertaking = oc.getBool("meso-overtaking");
635  MSGlobals::gMesoTLSPenalty = oc.getFloat("meso-tls-penalty");
636  MSGlobals::gMesoMinorPenalty = string2time(oc.getString("meso-minor-penalty"));
639  }
640  MSGlobals::gWaitingTimeMemory = string2time(oc.getString("waiting-time-memory"));
643 
644  DELTA_T = string2time(oc.getString("step-length"));
645 
646 
647  bool integrationMethodSet = !oc.isDefault("step-method.ballistic");
648  bool actionStepLengthSet = !oc.isDefault("default.action-step-length");
649  MSGlobals::gSemiImplicitEulerUpdate = !oc.getBool("step-method.ballistic");
650  // Init default value for gActionStepLength
651  if (MSGlobals::gSemiImplicitEulerUpdate && actionStepLengthSet && !integrationMethodSet) {
652  WRITE_MESSAGE("Integration method was set to 'ballistic', since a default action step length was specified.");
654  }
655  double givenDefaultActionStepLength = oc.getFloat("default.action-step-length");
657 
658 #ifdef _DEBUG
659  if (oc.isSet("movereminder-output")) {
660  MSBaseVehicle::initMoveReminderOutput(oc);
661  }
662 #endif
663 }
664 
665 
666 
667 /****************************************************************************/
668 
static bool gOmitEmptyEdgesOnDump
Information whether empty edges shall be written on dump.
Definition: MSGlobals.h:58
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:81
static double gLateralResolution
Definition: MSGlobals.h:91
static StringBijection< SumoXMLTag > CarFollowModels
car following models
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:47
static void init()
Static intialization.
Definition: MSStopOut.cpp:45
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:71
static double gMesoTLSPenalty
Definition: MSGlobals.h:106
static void buildStreams()
Builds the streams used possibly by the simulation.
Definition: MSFrame.cpp:484
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
static bool gStateLoaded
Information whether a state has been loaded.
Definition: MSGlobals.h:94
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
static void initCollisionOptions(const OptionsCont &oc)
Definition: MSLane.cpp:3099
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
static bool gMesoOvertaking
Definition: MSGlobals.h:103
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:46
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
static bool gCheck4Accidents
Definition: MSGlobals.h:82
static void fillOptions()
Inserts options used by the simulation into the OptionsCont-singleton.
Definition: MSFrame.cpp:66
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
static void init()
Static intialization.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static SUMOTime gTimeToImpatience
Definition: MSGlobals.h:72
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
std::vector< int > IntVector
Definition of a vector of ints.
Definition: Option.h:47
bool isUsableFileList(const std::string &name) const
Checks whether the named option is usable as a file list (with at least a single file) ...
static bool gCheckRoutes
Definition: MSGlobals.h:85
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:46
static SUMOTime gMesoMinorPenalty
Definition: MSGlobals.h:109
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static bool checkOptions()
checks shared options and sets StdDefs
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:75
static void initGlobalOptions(const OptionsCont &oc)
init global model parameters
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static bool checkOptions(OptionsCont &oc)
check device-specific options
Definition: MSDevice.cpp:73
static bool checkOptions()
Checks the set options.
Definition: MSFrame.cpp:515
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
static SUMOTime gActionStepLength
default value for the interval between two action points for MSVehicle (defaults to DELTA_T) ...
Definition: MSGlobals.h:118
static SUMOTime gTimeToGridlockHighways
Definition: MSGlobals.h:69
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
An integer-option.
Definition: Option.h:312
void addXMLDefault(const std::string &name, const std::string &xmlRoot="")
Adds an XML root element to handle by default. The special root "" denotes the default handler...
A storage for options typed value containers)
Definition: OptionsCont.h:98
static SUMOTime gTimeToGridlock
Definition: MSGlobals.h:66
static void insertOptions(OptionsCont &oc)
Inserts options for building devices.
Definition: MSDevice.cpp:60
static SUMOTime gWaitingTimeMemory
length of memory for waiting times (in millisecs)
Definition: MSGlobals.h:115
static SUMOTime gIgnoreJunctionBlocker
Definition: MSGlobals.h:79
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
static bool gSemiImplicitEulerUpdate
Definition: MSGlobals.h:62
static void setMSGlobals(OptionsCont &oc)
Sets the global microsim-options.
Definition: MSFrame.cpp:615
long long int SUMOTime
Definition: TraCIDefs.h:51
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:200
static SUMOTime gLaneChangeDuration
Definition: MSGlobals.h:88
static bool gUseMesoSim
Definition: MSGlobals.h:97
static bool gMesoLimitedJunctionControl
Definition: MSGlobals.h:100
#define STEPS2MS(x)
Definition: SUMOTime.h:68