Eclipse 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-2022 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 /****************************************************************************/
20 // Sets and checks options for routing
21 /****************************************************************************/
22 #include <config.h>
23 
24 #include <iostream>
25 #include <ctime>
26 #include <stdlib.h>
28 #include <utils/options/Option.h>
32 #include <utils/common/ToString.h>
33 #include <utils/common/SUMOTime.h>
35 #include "ROFrame.h"
36 
37 
38 // ===========================================================================
39 // method definitions
40 // ===========================================================================
41 void
43  // register options
44  // register I/O options
45  oc.doRegister("output-file", 'o', new Option_FileName());
46  oc.addSynonyme("output-file", "output");
47  oc.addDescription("output-file", "Output", "Write generated routes to FILE");
48 
49  oc.doRegister("vtype-output", new Option_FileName());
50  oc.addSynonyme("vtype-output", "vtype");
51  oc.addDescription("vtype-output", "Output", "Write used vehicle types into separate FILE");
52 
53  oc.doRegister("keep-vtype-distributions", new Option_Bool(false));
54  oc.addDescription("keep-vtype-distributions", "Output", "Keep vTypeDistribution ids when writing vehicles and their types");
55 
56  oc.doRegister("net-file", 'n', new Option_FileName());
57  oc.addSynonyme("net-file", "net");
58  oc.addDescription("net-file", "Input", "Use FILE as SUMO-network to route on");
59 
60  oc.doRegister("named-routes", new Option_Bool(false));
61  oc.addDescription("named-routes", "Output", "Write vehicles that reference routes by their id");
62 
63  oc.doRegister("additional-files", 'a', new Option_FileName());
64  oc.addSynonyme("additional-files", "d", true);
65  oc.addSynonyme("additional-files", "additional");
66  oc.addSynonyme("additional-files", "taz-files");
67  oc.addSynonyme("additional-files", "districts", true);
68  oc.addDescription("additional-files", "Input", "Read additional network data (districts, bus stops) from FILE(s)");
69 
70  oc.doRegister("route-files", 'r', new Option_FileName());
71  oc.addSynonyme("route-files", "flow-files", true);
72  oc.addSynonyme("route-files", "flows", true);
73  oc.addSynonyme("route-files", "f", true);
74  oc.addSynonyme("route-files", "alternative-files", true);
75  oc.addSynonyme("route-files", "alternatives-files", true);
76  oc.addSynonyme("route-files", "trip-files", true);
77  oc.addSynonyme("route-files", "trips", true);
78  oc.addDescription("route-files", "Input", "Read sumo routes, alternatives, flows, and trips from FILE(s)");
79 
80  oc.doRegister("phemlight-path", new Option_FileName(StringVector({ "./PHEMlight/" })));
81  oc.addDescription("phemlight-path", "Input", "Determines where to load PHEMlight definitions from.");
82 
83  // need to do this here to be able to check for network and route input options
85 
86  // register the time settings
87  oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
88  oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
89 
90  oc.doRegister("end", 'e', new Option_String("-1", "TIME"));
91  oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
92 
93  // register the processing options
94  oc.doRegister("ignore-errors", new Option_Bool(false));
95  oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
96  oc.addDescription("ignore-errors", "Report", "Continue if a route could not be build");
97 
98  oc.doRegister("unsorted-input", new Option_Bool(false));
99  oc.addSynonyme("unsorted-input", "unsorted");
100  oc.addDescription("unsorted-input", "Processing", "Assume input is unsorted");
101 
102  oc.doRegister("route-steps", 's', new Option_String("200", "TIME"));
103  oc.addDescription("route-steps", "Processing", "Load routes for the next number of seconds ahead");
104 
105  oc.doRegister("no-internal-links", new Option_Bool(false));
106  oc.addDescription("no-internal-links", "Processing", "Disable (junction) internal links");
107 
108  oc.doRegister("randomize-flows", new Option_Bool(false));
109  oc.addDescription("randomize-flows", "Processing", "generate random departure times for flow input");
110 
111  oc.doRegister("max-alternatives", new Option_Integer(5));
112  oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
113 
114  oc.doRegister("remove-loops", new Option_Bool(false));
115  oc.addDescription("remove-loops", "Processing", "Remove loops within the route; Remove turnarounds at start and end of the route");
116 
117  oc.doRegister("repair", new Option_Bool(false));
118  oc.addDescription("repair", "Processing", "Tries to correct a false route");
119 
120  oc.doRegister("repair.from", new Option_Bool(false));
121  oc.addDescription("repair.from", "Processing", "Tries to correct an invalid starting edge by using the first usable edge instead");
122 
123  oc.doRegister("repair.to", new Option_Bool(false));
124  oc.addDescription("repair.to", "Processing", "Tries to correct an invalid destination edge by using the last usable edge instead");
125 
126  oc.doRegister("weights.interpolate", new Option_Bool(false));
127  oc.addSynonyme("weights.interpolate", "interpolate", true);
128  oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
129 
130  oc.doRegister("weights.minor-penalty", new Option_Float(1.5));
131  oc.addDescription("weights.minor-penalty", "Processing", "Apply the given time penalty when computing routing costs for minor-link internal lanes");
132 
133  oc.doRegister("with-taz", new Option_Bool(false));
134  oc.addDescription("with-taz", "Processing", "Use origin and destination zones (districts) for in- and output");
135 
136  oc.doRegister("junction-taz", new Option_Bool(false));
137  oc.addDescription("junction-taz", "Input", "Initialize a TAZ for every junction to use attributes toJunction and fromJunction");
138 
139  oc.doRegister("mapmatch.distance", new Option_Float(100));
140  oc.addDescription("mapmatch.distance", "Processing", "Maximum distance when mapping input coordinates (fromXY etc.) to the road network");
141 
142  oc.doRegister("mapmatch.junctions", new Option_Bool(false));
143  oc.addDescription("mapmatch.junctions", "Processing", "Match positions to junctions instead of edges");
144 
145  oc.doRegister("bulk-routing", new Option_Bool(false));
146  oc.addDescription("bulk-routing", "Processing", "Aggregate routing queries with the same origin");
147 
148  oc.doRegister("routing-threads", new Option_Integer(0));
149  oc.addDescription("routing-threads", "Processing", "The number of parallel execution threads used for routing");
150 
151  oc.doRegister("restriction-params", new Option_StringVector());
152  oc.addDescription("restriction-params", "Processing", "Comma separated list of param keys to compare for additional restrictions");
153 
154  // register defaults options
155  oc.doRegister("departlane", new Option_String());
156  oc.addDescription("departlane", "Defaults", "Assigns a default depart lane");
157 
158  oc.doRegister("departpos", new Option_String());
159  oc.addDescription("departpos", "Defaults", "Assigns a default depart position");
160 
161  oc.doRegister("departspeed", new Option_String());
162  oc.addDescription("departspeed", "Defaults", "Assigns a default depart speed");
163 
164  oc.doRegister("arrivallane", new Option_String());
165  oc.addDescription("arrivallane", "Defaults", "Assigns a default arrival lane");
166 
167  oc.doRegister("arrivalpos", new Option_String());
168  oc.addDescription("arrivalpos", "Defaults", "Assigns a default arrival position");
169 
170  oc.doRegister("arrivalspeed", new Option_String());
171  oc.addDescription("arrivalspeed", "Defaults", "Assigns a default arrival speed");
172 
173  oc.doRegister("defaults-override", new Option_Bool(false));
174  oc.addDescription("defaults-override", "Defaults", "Defaults will override given values");
175 
176 
177  // register report options
178  oc.doRegister("stats-period", new Option_Integer(-1));
179  oc.addDescription("stats-period", "Report", "Defines how often statistics shall be printed");
180 
181  oc.doRegister("no-step-log", new Option_Bool(false));
182  oc.addDescription("no-step-log", "Report", "Disable console output of route parsing step");
183 }
184 
185 
186 bool
188  // check whether the output is valid and can be build
189  if (!oc.isSet("output-file")) {
190  WRITE_ERROR("No output specified.");
191  return false;
192  }
193  //
194  if (oc.getInt("max-alternatives") < 1) {
195  WRITE_ERROR("A positive number of alternatives must be enabled.");
196  return false;
197  }
198 #ifndef HAVE_FOX
199  if (oc.getInt("routing-threads") > 1) {
200  WRITE_ERROR("Parallel routing is only possible when compiled with Fox.");
201  return false;
202  }
203 #endif
204  return true;
205 }
206 
207 
208 /****************************************************************************/
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
std::vector< std::string > StringVector
Definition of a vector of strings.
Definition: Option.h:43
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.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
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
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:187
static void fillOptions(OptionsCont &oc)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:42
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:63