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>
35#include "ROFrame.h"
36
37
38// ===========================================================================
39// method definitions
40// ===========================================================================
41void
42ROFrame::fillOptions(OptionsCont& oc, const bool isDUA, const bool isMA) {
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 if (!isMA) {
51 oc.addSynonyme("vtype-output", "vtype");
52 }
53 oc.addDescription("vtype-output", "Output", "Write used vehicle types into separate FILE");
54
55 oc.doRegister("keep-vtype-distributions", new Option_Bool(false));
56 oc.addDescription("keep-vtype-distributions", "Output", "Keep vTypeDistribution ids when writing vehicles and their types");
57
58 oc.doRegister("emissions.volumetric-fuel", new Option_Bool(false));
59 oc.addDescription("emissions.volumetric-fuel", "Output", "Return fuel consumption values in (legacy) unit l instead of mg");
60
61 oc.doRegister("net-file", 'n', new Option_FileName());
62 oc.addSynonyme("net-file", "net");
63 oc.addDescription("net-file", "Input", "Use FILE as SUMO-network to route on");
64
65 oc.doRegister("named-routes", new Option_Bool(false));
66 oc.addDescription("named-routes", "Output", "Write vehicles that reference routes by their id");
67
68 oc.doRegister("additional-files", 'a', new Option_FileName());
69 oc.addSynonyme("additional-files", "d", true);
70 oc.addSynonyme("additional-files", "additional");
71 oc.addSynonyme("additional-files", "taz-files");
72 oc.addSynonyme("additional-files", "districts", true);
73 oc.addDescription("additional-files", "Input", "Read additional network data (districts, bus stops) from FILE(s)");
74
75 oc.doRegister("route-files", 'r', new Option_FileName());
76 oc.addSynonyme("route-files", "flow-files", true);
77 oc.addSynonyme("route-files", "flows", true);
78 oc.addSynonyme("route-files", "f", true);
79 oc.addSynonyme("route-files", "alternative-files", true);
80 oc.addSynonyme("route-files", "alternatives-files", true);
81 oc.addSynonyme("route-files", "trip-files", true);
82 oc.addSynonyme("route-files", "trips", true);
83 if (isDUA) {
84 // to make the transition from --trip-files easier, but has a conflict with jtrrouter
85 oc.addSynonyme("route-files", "t", true);
86 }
87 oc.addDescription("route-files", "Input", "Read sumo routes, alternatives, flows, and trips from FILE(s)");
88
89 oc.doRegister("phemlight-path", new Option_FileName(StringVector({ "./PHEMlight/" })));
90 oc.addDescription("phemlight-path", "Input", "Determines where to load PHEMlight definitions from");
91
92 oc.doRegister("phemlight-year", new Option_Integer(0));
93 oc.addDescription("phemlight-year", "Input", "Enable fleet age modelling with the given reference year in PHEMlight5");
94
95 oc.doRegister("phemlight-temperature", new Option_Float(INVALID_DOUBLE));
96 oc.addDescription("phemlight-temperature", "Input", "Set ambient temperature to correct NOx emissions in PHEMlight5");
97
98 if (isDUA || isMA) {
99 oc.doRegister("weight-files", 'w', new Option_FileName());
100 oc.addSynonyme("weight-files", "weights");
101 oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)");
102
103 oc.doRegister("lane-weight-files", new Option_FileName());
104 oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)");
105
106 oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
107 oc.addSynonyme("weight-attribute", "measure", true);
108 oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
109 }
110
111 // need to do this here to be able to check for network and route input options
113
114 // register the time settings
115 oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
116 oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
117
118 oc.doRegister("end", 'e', new Option_String("-1", "TIME"));
119 oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
120
121 // register the processing options
122 oc.doRegister("ignore-errors", new Option_Bool(false));
123 oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
124 oc.addSynonyme("ignore-errors", "dismiss-loading-errors", true);
125 oc.addDescription("ignore-errors", "Report", "Continue if a route could not be build");
126
127 oc.doRegister("max-alternatives", new Option_Integer(5));
128 oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
129
130 oc.doRegister("with-taz", new Option_Bool(false));
131 oc.addDescription("with-taz", "Processing", "Use origin and destination zones (districts) for in- and output");
132
133 oc.doRegister("junction-taz", new Option_Bool(false));
134 oc.addDescription("junction-taz", "Input", "Initialize a TAZ for every junction to use attributes toJunction and fromJunction");
135
136 if (!isMA) {
137 oc.doRegister("unsorted-input", new Option_Bool(false));
138 oc.addSynonyme("unsorted-input", "unsorted");
139 oc.addDescription("unsorted-input", "Processing", "Assume input is unsorted");
140
141 oc.doRegister("route-steps", 's', new Option_String("200", "TIME"));
142 oc.addDescription("route-steps", "Processing", "Load routes for the next number of seconds ahead");
143
144 oc.doRegister("no-internal-links", new Option_Bool(false));
145 oc.addDescription("no-internal-links", "Processing", "Disable (junction) internal links");
146
147 oc.doRegister("randomize-flows", new Option_Bool(false));
148 oc.addDescription("randomize-flows", "Processing", "generate random departure times for flow input");
149
150 oc.doRegister("remove-loops", new Option_Bool(false));
151 oc.addDescription("remove-loops", "Processing", "Remove loops within the route; Remove turnarounds at start and end of the route");
152
153 oc.doRegister("repair", new Option_Bool(false));
154 oc.addDescription("repair", "Processing", "Tries to correct a false route");
155
156 oc.doRegister("repair.from", new Option_Bool(false));
157 oc.addDescription("repair.from", "Processing", "Tries to correct an invalid starting edge by using the first usable edge instead");
158
159 oc.doRegister("repair.to", new Option_Bool(false));
160 oc.addDescription("repair.to", "Processing", "Tries to correct an invalid destination edge by using the last usable edge instead");
161
162 oc.doRegister("mapmatch.distance", new Option_Float(100));
163 oc.addDescription("mapmatch.distance", "Processing", "Maximum distance when mapping input coordinates (fromXY etc.) to the road network");
164
165 oc.doRegister("mapmatch.junctions", new Option_Bool(false));
166 oc.addDescription("mapmatch.junctions", "Processing", "Match positions to junctions instead of edges");
167
168 oc.doRegister("bulk-routing", new Option_Bool(false));
169 oc.addDescription("bulk-routing", "Processing", "Aggregate routing queries with the same origin");
170 }
171
172 oc.doRegister("routing-threads", new Option_Integer(0));
173 oc.addDescription("routing-threads", "Processing", "The number of parallel execution threads used for routing");
174
175 if (isDUA || isMA) {
176 oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
177 oc.addDescription("routing-algorithm", "Processing", "Select among routing algorithms ['dijkstra', 'astar', 'CH', 'CHWrapper']");
178 }
179
180 oc.doRegister("restriction-params", new Option_StringVector());
181 oc.addDescription("restriction-params", "Processing", "Comma separated list of param keys to compare for additional restrictions");
182
183 if (isDUA || isMA) {
184 oc.doRegister("weights.interpolate", new Option_Bool(false));
185 oc.addSynonyme("weights.interpolate", "interpolate", true);
186 oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
187
188 oc.doRegister("weights.expand", new Option_Bool(false));
189 oc.addSynonyme("weights.expand", "expand-weights", true);
190 oc.addDescription("weights.expand", "Processing", "Expand the end of the last loaded weight interval to infinity");
191 }
192
193 oc.doRegister("weights.minor-penalty", new Option_Float(1.5));
194 oc.addDescription("weights.minor-penalty", "Processing", "Apply the given time penalty when computing routing costs for minor-link internal lanes");
195
196 if (!isMA) {
197 // register defaults options
198 oc.doRegister("departlane", new Option_String());
199 oc.addDescription("departlane", "Defaults", "Assigns a default depart lane");
200
201 oc.doRegister("departpos", new Option_String());
202 oc.addDescription("departpos", "Defaults", "Assigns a default depart position");
203
204 oc.doRegister("departspeed", new Option_String());
205 oc.addDescription("departspeed", "Defaults", "Assigns a default depart speed");
206
207 oc.doRegister("arrivallane", new Option_String());
208 oc.addDescription("arrivallane", "Defaults", "Assigns a default arrival lane");
209
210 oc.doRegister("arrivalpos", new Option_String());
211 oc.addDescription("arrivalpos", "Defaults", "Assigns a default arrival position");
212
213 oc.doRegister("arrivalspeed", new Option_String());
214 oc.addDescription("arrivalspeed", "Defaults", "Assigns a default arrival speed");
215
216 oc.doRegister("defaults-override", new Option_Bool(false));
217 oc.addDescription("defaults-override", "Defaults", "Defaults will override given values");
218 }
219
220 // register report options
221 oc.doRegister("stats-period", new Option_Integer(-1));
222 oc.addDescription("stats-period", "Report", "Defines how often statistics shall be printed");
223
224 oc.doRegister("no-step-log", new Option_Bool(false));
225 oc.addDescription("no-step-log", "Report", "Disable console output of route parsing step");
226}
227
228
229bool
231 // check whether the output is valid and can be build
232 if (!oc.isSet("output-file")) {
233 WRITE_ERROR(TL("No output specified."));
234 return false;
235 }
236 //
237 if (oc.getInt("max-alternatives") < 1) {
238 WRITE_ERROR(TL("A positive number of alternatives must be enabled."));
239 return false;
240 }
241#ifndef HAVE_FOX
242 if (oc.getInt("routing-threads") > 1) {
243 WRITE_ERROR(TL("Parallel routing is only possible when compiled with Fox."));
244 return false;
245 }
246#endif
247 return true;
248}
249
250
251/****************************************************************************/
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:274
#define TL(string)
Definition: MsgHandler.h:282
std::vector< std::string > StringVector
Definition of a vector of strings.
Definition: Option.h:43
const double INVALID_DOUBLE
Definition: StdDefs.h:60
An integer-option.
Definition: Option.h:289
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:76
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:97
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:230
static void fillOptions(OptionsCont &oc, const bool isDUA=false, const bool isMA=false)
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:67