SUMO - Simulation of Urban MObility
ROFrame.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-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 /****************************************************************************/
19 // Sets and checks options for routing
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <iostream>
33 #include <ctime>
34 #include <stdlib.h>
36 #include <utils/options/Option.h>
40 #include <utils/common/ToString.h>
41 #include <utils/common/SUMOTime.h>
42 #include "ROFrame.h"
43 
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 void
50  // register options
51  // register I/O options
52  oc.doRegister("output-file", 'o', new Option_FileName());
53  oc.addSynonyme("output-file", "output");
54  oc.addDescription("output-file", "Output", "Write generated routes to FILE");
55 
56  oc.doRegister("vtype-output", new Option_FileName());
57  oc.addSynonyme("vtype-output", "vtype");
58  oc.addDescription("vtype-output", "Output", "Write used vehicle types into separate FILE");
59 
60  oc.doRegister("keep-vtype-distributions", new Option_Bool(false));
61  oc.addDescription("keep-vtype-distributions", "Output", "Keep vTypeDistribution ids when writing vehicles and their types");
62 
63  oc.doRegister("net-file", 'n', new Option_FileName());
64  oc.addSynonyme("net-file", "net");
65  oc.addDescription("net-file", "Input", "Use FILE as SUMO-network to route on");
66 
67  oc.doRegister("additional-files", 'a', new Option_FileName());
68  oc.addSynonyme("additional-files", "d", true);
69  oc.addSynonyme("additional-files", "additional");
70  oc.addSynonyme("additional-files", "taz-files");
71  oc.addSynonyme("additional-files", "districts", true);
72  oc.addDescription("additional-files", "Input", "Read additional network data (districts, bus stops) from FILE(s)");
73 
74  oc.doRegister("route-files", 'r', new Option_FileName());
75  oc.addSynonyme("route-files", "flow-files", true);
76  oc.addSynonyme("route-files", "flows", true);
77  oc.addSynonyme("route-files", "f", true);
78  oc.addSynonyme("route-files", "alternative-files", true);
79  oc.addSynonyme("route-files", "alternatives-files", true);
80  oc.addSynonyme("route-files", "trip-files", true);
81  oc.addSynonyme("route-files", "trips", true);
82  oc.addDescription("route-files", "Input", "Read sumo routes, alternatives, flows, and trips from FILE(s)");
83 
84  // register the time settings
85  oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
86  oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
87 
88  oc.doRegister("end", 'e', new Option_String(SUMOTIME_MAXSTRING, "TIME"));
89  oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
90 
91  // register the processing options
92  oc.doRegister("ignore-errors", new Option_Bool(false));
93  oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
94  oc.addDescription("ignore-errors", "Processing", "Continue if a route could not be build");
95 
96  oc.doRegister("unsorted-input", new Option_Bool(false));
97  oc.addSynonyme("unsorted-input", "unsorted");
98  oc.addDescription("unsorted-input", "Processing", "Assume input is unsorted");
99 
100  oc.doRegister("route-steps", 's', new Option_String("200", "TIME"));
101  oc.addDescription("route-steps", "Processing", "Load routes for the next number of seconds ahead");
102 
103  oc.doRegister("randomize-flows", new Option_Bool(false));
104  oc.addDescription("randomize-flows", "Processing", "generate random departure times for flow input");
105 
106  oc.doRegister("max-alternatives", new Option_Integer(5));
107  oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
108 
109  oc.doRegister("remove-loops", new Option_Bool(false));
110  oc.addDescription("remove-loops", "Processing", "Remove loops within the route; Remove turnarounds at start and end of the route");
111 
112  oc.doRegister("repair", new Option_Bool(false));
113  oc.addDescription("repair", "Processing", "Tries to correct a false route");
114 
115  oc.doRegister("repair.from", new Option_Bool(false));
116  oc.addDescription("repair.from", "Processing", "Tries to correct an invalid starting edge by using the first usable edge instead");
117 
118  oc.doRegister("repair.to", new Option_Bool(false));
119  oc.addDescription("repair.to", "Processing", "Tries to correct an invalid destination edge by using the last usable edge instead");
120 
121  oc.doRegister("weights.interpolate", new Option_Bool(false));
122  oc.addSynonyme("weights.interpolate", "interpolate", true);
123  oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
124 
125  oc.doRegister("with-taz", new Option_Bool(false));
126  oc.addDescription("with-taz", "Processing", "Use origin and destination zones (districts) for in- and output");
127 
128  oc.doRegister("bulk-routing", new Option_Bool(false));
129  oc.addDescription("bulk-routing", "Processing", "Aggregate routing queries with the same origin");
130 
131  oc.doRegister("routing-threads", new Option_Integer(0));
132  oc.addDescription("routing-threads", "Processing", "The number of parallel execution threads used for routing");
133 
134  // register defaults options
135  oc.doRegister("departlane", new Option_String());
136  oc.addDescription("departlane", "Defaults", "Assigns a default depart lane");
137 
138  oc.doRegister("departpos", new Option_String());
139  oc.addDescription("departpos", "Defaults", "Assigns a default depart position");
140 
141  oc.doRegister("departspeed", new Option_String());
142  oc.addDescription("departspeed", "Defaults", "Assigns a default depart speed");
143 
144  oc.doRegister("arrivallane", new Option_String());
145  oc.addDescription("arrivallane", "Defaults", "Assigns a default arrival lane");
146 
147  oc.doRegister("arrivalpos", new Option_String());
148  oc.addDescription("arrivalpos", "Defaults", "Assigns a default arrival position");
149 
150  oc.doRegister("arrivalspeed", new Option_String());
151  oc.addDescription("arrivalspeed", "Defaults", "Assigns a default arrival speed");
152 
153  oc.doRegister("defaults-override", new Option_Bool(false));
154  oc.addDescription("defaults-override", "Defaults", "Defaults will override given values");
155 
156 
157  // register report options
158  oc.doRegister("stats-period", new Option_Integer(-1));
159  oc.addDescription("stats-period", "Report", "Defines how often statistics shall be printed");
160 
161  oc.doRegister("no-step-log", new Option_Bool(false));
162  oc.addDescription("no-step-log", "Report", "Disable console output of route parsing step");
163 }
164 
165 
166 bool
168  // check whether the output is valid and can be build
169  if (!oc.isSet("output-file")) {
170  WRITE_ERROR("No output specified.");
171  return false;
172  }
173  //
174  if (oc.getInt("max-alternatives") < 2) {
175  WRITE_ERROR("At least two alternatives should be enabled.");
176  return false;
177  }
178 #ifndef HAVE_FOX
179  if (oc.getInt("routing-threads") > 1) {
180  WRITE_ERROR("Parallel routing is only possible when compiled with Fox.");
181  return false;
182  }
183 #endif
184  return true;
185 }
186 
187 
188 
189 /****************************************************************************/
190 
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:81
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
static void fillOptions(OptionsCont &oc)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:49
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:167
#define SUMOTIME_MAXSTRING
Definition: SUMOTime.h:45
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
An integer-option.
Definition: Option.h:312
A storage for options typed value containers)
Definition: OptionsCont.h:98
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.