Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RODUAFrame.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 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 dua-routing
21/****************************************************************************/
22#include <config.h>
23
24#include <iostream>
25#include <fstream>
26#include <ctime>
32#include "RODUAFrame.h"
33#include <router/ROFrame.h>
37
38
39// ===========================================================================
40// method definitions
41// ===========================================================================
42void
45 oc.addCallExample("-c <CONFIGURATION>", TL("run routing with options from file"));
46
47 // insert options sub-topics
48 SystemFrame::addConfigurationOptions(oc); // fill this subtopic, too
49 oc.addOptionSubTopic("Input");
50 oc.addOptionSubTopic("Output");
51 oc.addOptionSubTopic("Processing");
52 oc.addOptionSubTopic("Defaults");
53 oc.addOptionSubTopic("Time");
54
55 // insert options
56 ROFrame::fillOptions(oc, true);
59 // add rand options
61}
62
63
64void
67 oc.doRegister("alternatives-output", new Option_FileName());
68 oc.addSynonyme("alternatives-output", "alternatives");
69 oc.addDescription("alternatives-output", "Output", TL("Write generated route alternatives to FILE"));
70
71 oc.doRegister("intermodal-network-output", new Option_FileName());
72 oc.addDescription("intermodal-network-output", "Output", TL("Write edge splits and connectivity to FILE"));
73
74 oc.doRegister("intermodal-weight-output", new Option_FileName());
75 oc.addDescription("intermodal-weight-output", "Output", TL("Write intermodal edges with lengths and travel times to FILE"));
76
77 oc.doRegister("write-trips", new Option_Bool(false));
78 oc.addDescription("write-trips", "Output", TL("Write trips instead of vehicles (for validating trip input)"));
79
80 oc.doRegister("write-trips.geo", new Option_Bool(false));
81 oc.addDescription("write-trips.geo", "Output", TL("Write trips with geo-coordinates"));
82
83 oc.doRegister("write-trips.junctions", new Option_Bool(false));
84 oc.addDescription("write-trips.junctions", "Output", TL("Write trips with fromJunction and toJunction"));
85
86 oc.doRegister("write-costs", new Option_Bool(false));
87 oc.addDescription("write-costs", "Output", TL("Include the cost attribute in route output"));
88
89 // register further processing options
90 // ! The subtopic "Processing" must be initialised earlier !
91 oc.doRegister("weights.random-factor", new Option_Float(1.));
92 oc.addDescription("weights.random-factor", "Processing", TL("Edge weights for routing are dynamically disturbed by a random factor drawn uniformly from [1,FLOAT)"));
93
94 oc.doRegister("weight-period", new Option_String("3600", "TIME"));
95 oc.addDescription("weight-period", "Processing", TL("Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy"));
96
97 oc.doRegister("weights.priority-factor", new Option_Float(0));
98 oc.addDescription("weights.priority-factor", "Processing", TL("Consider edge priorities in addition to travel times, weighted by factor"));
99
100 oc.doRegister("astar.all-distances", new Option_FileName());
101 oc.addDescription("astar.all-distances", "Processing", TL("Initialize lookup table for astar from the given file (generated by marouter --all-pairs-output)"));
102
103 oc.doRegister("astar.landmark-distances", new Option_FileName());
104 oc.addDescription("astar.landmark-distances", "Processing", TL("Initialize lookup table for astar ALT-variant from the given file"));
105
106 oc.doRegister("astar.save-landmark-distances", new Option_FileName());
107 oc.addDescription("astar.save-landmark-distances", "Processing", TL("Save lookup table for astar ALT-variant to the given file"));
108
109 oc.doRegister("scale", new Option_Float(1.));
110 oc.addDescription("scale", "Processing", TL("Scale demand by the given factor (by discarding or duplicating vehicles)"));
111
112 oc.doRegister("scale-suffix", new Option_String("."));
113 oc.addDescription("scale-suffix", "Processing", TL("Suffix to be added when creating ids for cloned vehicles"));
114
115 oc.doRegister("taxi.vclasses", new Option_StringVector({"taxi"}));
116 oc.addSynonyme("taxi.vclasses", "device.taxi.vclasses");
117 oc.addDescription("taxi.vclasses", "Processing", TL("Network permissions that can be accessed by taxis"));
118}
119
120
121void
124 // register Gawron's DUE-settings
125 oc.doRegister("gawron.beta", new Option_Float(double(0.9)));
126 oc.addSynonyme("gawron.beta", "gBeta", true);
127 oc.addDescription("gawron.beta", "Processing", TL("Use FLOAT as Gawron's beta"));
128
129 oc.doRegister("gawron.a", new Option_Float(double(0.5)));
130 oc.addSynonyme("gawron.a", "gA", true);
131 oc.addDescription("gawron.a", "Processing", TL("Use FLOAT as Gawron's a"));
132
133 oc.doRegister("exit-times", new Option_Bool(false));
134 oc.addDescription("exit-times", "Output", TL("Write exit times (weights) for each edge"));
135
136 oc.doRegister("route-length", new Option_Bool(false));
137 oc.addDescription("route-length", "Output", TL("Include total route length in the output"));
138
139 oc.doRegister("keep-all-routes", new Option_Bool(false));
140 oc.addDescription("keep-all-routes", "Processing", TL("Save routes with near zero probability"));
141
142 oc.doRegister("skip-new-routes", new Option_Bool(false));
143 oc.addDescription("skip-new-routes", "Processing", TL("Only reuse routes from input, do not calculate new ones"));
144
145 oc.doRegister("keep-route-probability", new Option_Float(0));
146 oc.addDescription("keep-route-probability", "Processing", TL("The probability of keeping the old route"));
147
148 oc.doRegister("ptline-routing", new Option_Bool(false));
149 oc.addDescription("ptline-routing", "Processing", TL("Route all public transport input"));
150
151 oc.doRegister("keep-flows", new Option_Bool(false));
152 oc.addDescription("keep-flows", "Processing", TL("Write flows instead of expanding them into vehicles"));
153
154 oc.doRegister("route-choice-method", new Option_String("gawron"));
155 oc.addDescription("route-choice-method", "Processing", TL("Choose a route choice method: gawron, logit, or lohse"));
156
157 oc.doRegister("logit", new Option_Bool(false)); // deprecated
158 oc.addDescription("logit", "Processing", TL("Use c-logit model (deprecated in favor of --route-choice-method logit)"));
159
160 oc.doRegister("logit.beta", new Option_Float(double(-1)));
161 oc.addSynonyme("logit.beta", "lBeta", true);
162 oc.addDescription("logit.beta", "Processing", TL("Use FLOAT as logit's beta"));
163
164 oc.doRegister("logit.gamma", new Option_Float(double(1)));
165 oc.addSynonyme("logit.gamma", "lGamma", true);
166 oc.addDescription("logit.gamma", "Processing", TL("Use FLOAT as logit's gamma"));
167
168 oc.doRegister("logit.theta", new Option_Float(double(-1)));
169 oc.addSynonyme("logit.theta", "lTheta", true);
170 oc.addDescription("logit.theta", "Processing", TL("Use FLOAT as logit's theta (negative values mean auto-estimation)"));
171
172 oc.doRegister("persontrip.walkfactor", new Option_Float(double(0.75)));
173 oc.addDescription("persontrip.walkfactor", "Processing", TL("Use FLOAT as a factor on pedestrian maximum speed during intermodal routing"));
174
175 oc.doRegister("persontrip.walk-opposite-factor", new Option_Float(1.0));
176 oc.addDescription("persontrip.walk-opposite-factor", "Processing", TL("Use FLOAT as a factor on walking speed against vehicle traffic direction"));
177
178 oc.doRegister("persontrip.transfer.car-walk", new Option_StringVector(StringVector({ "parkingAreas" })));
179 oc.addDescription("persontrip.transfer.car-walk", "Processing",
180 "Where are mode changes from car to walking allowed (possible values: 'parkingAreas', 'ptStops', 'allJunctions' and combinations)");
181
182 oc.doRegister("persontrip.transfer.taxi-walk", new Option_StringVector());
183 oc.addDescription("persontrip.transfer.taxi-walk", "Processing", TL("Where taxis can drop off customers ('allJunctions, 'ptStops')"));
184
185 oc.doRegister("persontrip.transfer.walk-taxi", new Option_StringVector());
186 oc.addDescription("persontrip.transfer.walk-taxi", "Processing", TL("Where taxis can pick up customers ('allJunctions, 'ptStops')"));
187
188 oc.doRegister("persontrip.taxi.waiting-time", new Option_String("300", "TIME"));
189 oc.addDescription("persontrip.taxi.waiting-time", "Processing", TL("Estimated time for taxi pickup"));
190
191 oc.doRegister("persontrip.ride-public-line", new Option_Bool(false));
192 oc.addDescription("persontrip.ride-public-line", "Processing", TL("Only use the intended public transport line rather than any alternative line that stops at the destination"));
193
194 oc.doRegister("railway.max-train-length", new Option_Float(1000.0));
195 oc.addDescription("railway.max-train-length", "Processing", TL("Use FLOAT as a maximum train length when initializing the railway router"));
196
197 oc.doRegister("max-traveltime", new Option_String("-1", "TIME"));
198 oc.addDescription("max-traveltime", "Processing", TL("Declare routing failure if traveltime exceeds the given positive TIME"));
199}
200
201
202bool
205 bool ok = ROFrame::checkOptions(oc);
206
208 std::string error;
209 if (oc.isSet("departlane") && !SUMOVehicleParameter::parseDepartLane(oc.getString("departlane"), "option", "departlane", p.departLane, p.departLaneProcedure, error)) {
210 WRITE_ERROR(error);
211 ok = false;
212 }
213 if (oc.isSet("departpos") && !SUMOVehicleParameter::parseDepartPos(oc.getString("departpos"), "option", "departpos", p.departPos, p.departPosProcedure, error)) {
214 WRITE_ERROR(error);
215 ok = false;
216 }
217 if (oc.isSet("departspeed") && !SUMOVehicleParameter::parseDepartSpeed(oc.getString("departspeed"), "option", "departspeed", p.departSpeed, p.departSpeedProcedure, error)) {
218 WRITE_ERROR(error);
219 ok = false;
220 }
221 if (oc.isSet("arrivallane") && !SUMOVehicleParameter::parseArrivalLane(oc.getString("arrivallane"), "option", "arrivallane", p.arrivalLane, p.arrivalLaneProcedure, error)) {
222 WRITE_ERROR(error);
223 ok = false;
224 }
225 if (oc.isSet("arrivalpos") && !SUMOVehicleParameter::parseArrivalPos(oc.getString("arrivalpos"), "option", "arrivalpos", p.arrivalPos, p.arrivalPosProcedure, error)) {
226 WRITE_ERROR(error);
227 ok = false;
228 }
229 if (oc.isSet("arrivalspeed") && !SUMOVehicleParameter::parseArrivalSpeed(oc.getString("arrivalspeed"), "option", "arrivalspeed", p.arrivalSpeed, p.arrivalSpeedProcedure, error)) {
230 WRITE_ERROR(error);
231 ok = false;
232 }
233
234 if (oc.getString("routing-algorithm") != "dijkstra" && oc.getString("weight-attribute") != "traveltime") {
235 WRITE_ERRORF(TL("Routing algorithm '%' does not support weight-attribute '%'."), oc.getString("routing-algorithm"), oc.getString("weight-attribute"));
236 return false;
237 }
238 if (oc.getBool("bulk-routing") && (oc.getString("routing-algorithm") == "CH" || oc.getString("routing-algorithm") == "CHWrapper")) {
239 WRITE_ERRORF(TL("Routing algorithm '%' does not support bulk routing."), oc.getString("routing-algorithm"));
240 return false;
241 }
242 if (oc.isDefault("routing-algorithm") && (oc.isSet("astar.all-distances") || oc.isSet("astar.landmark-distances") || oc.isSet("astar.save-landmark-distances"))) {
243 oc.setDefault("routing-algorithm", "astar");
244 }
245 if (!oc.isDefault("weights.random-factor") && (oc.isSet("astar.all-distances") || oc.isSet("astar.landmark-distances") || oc.isSet("astar.save-landmark-distances"))) {
246 WRITE_WARNING(TL("The option --weights.random-factor should not be used together with astar and precomputed distances."));
247 }
248
249 if (oc.getString("route-choice-method") != "gawron" && oc.getString("route-choice-method") != "logit") {
250 WRITE_ERRORF(TL("Invalid route choice method '%'."), oc.getString("route-choice-method"));
251 return false;
252 }
253 if (oc.getBool("logit")) {
254 WRITE_WARNING(TL("The --logit option is deprecated, please use --route-choice-method logit."));
255 oc.set("route-choice-method", "logit");
256 }
257
258 if (oc.isSet("output-file") && !oc.isSet("alternatives-output")) {
259 const std::string& filename = oc.getString("output-file");
260 const int len = (int)filename.length();
261 if (len > 4 && filename.substr(len - 4) == ".xml") {
262 oc.setDefault("alternatives-output", filename.substr(0, len - 4) + ".alt.xml");
263 } else if (len > 7 && filename.substr(len - 7) == ".xml.gz") {
264 oc.setDefault("alternatives-output", filename.substr(0, len - 7) + ".alt.xml.gz");
265 } else if (len > 3 && filename.substr(len - 3) == ".gz") {
266 oc.setDefault("alternatives-output", filename.substr(0, len - 3) + ".alt.gz");
267 } else {
268 WRITE_WARNING(TL("Cannot derive file name for alternatives output, skipping it."));
269 }
270 }
271 if (oc.getBool("write-trips.junctions")) {
272 if (oc.isDefault("write-trips")) {
273 oc.setDefault("write-trips", "true");
274 } else if (!oc.getBool("write-trips")) {
275 WRITE_WARNING(TL("Option --write-trips.junctions takes no affect when --write-trips is disabled."));
276 }
277 }
278 gTaxiClasses = 0;
279 for (const std::string& vClassName : oc.getStringVector("device.taxi.vclasses")) {
280 gTaxiClasses |= parseVehicleClasses(vClassName);
281 }
282 return ok;
283}
284
285
286/****************************************************************************/
#define WRITE_ERRORF(...)
Definition MsgHandler.h:296
#define WRITE_ERROR(msg)
Definition MsgHandler.h:295
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
std::vector< std::string > StringVector
Definition of a vector of strings.
Definition Option.h:42
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
int gTaxiClasses
Definition StdDefs.cpp:38
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.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool setDefault(const std::string &name, const std::string &value)
Sets the given value for the named option as new default value.
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
bool set(const std::string &name, const std::string &value, const bool append=false)
Sets the given value for the named option.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
static void addImportOptions()
Inserts import options used by duarouter into the OptionsCont-singleton.
static void addDUAOptions()
Inserts dua options used by duarouter into the OptionsCont-singleton.
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter.
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition ROFrame.cpp:245
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 insertRandOptions(OptionsCont &oc)
Initialises the given options container with random number options.
Structure representing possible vehicle parameter.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
double arrivalPos
(optional) The position the vehicle shall arrive on
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.