SUMO - Simulation of Urban MObility
RODUAFrame.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 dua-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 <fstream>
34 #include <ctime>
36 #include <utils/options/Option.h>
39 #include <utils/common/ToString.h>
40 #include "RODUAFrame.h"
41 #include <router/ROFrame.h>
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 void
53  oc.addCallExample("-c <CONFIGURATION>", "run routing with options from file");
54 
55  // insert options sub-topics
56  SystemFrame::addConfigurationOptions(oc); // fill this subtopic, too
57  oc.addOptionSubTopic("Input");
58  oc.addOptionSubTopic("Output");
59  oc.addOptionSubTopic("Processing");
60  oc.addOptionSubTopic("Defaults");
61  oc.addOptionSubTopic("Time");
62  SystemFrame::addReportOptions(oc); // fill this subtopic, too
63 
64  // insert options
66  // to make the transition from --trip-files easier, but has a conflict with jtrrouter
67  oc.addSynonyme("route-files", "t", true);
69  addDUAOptions();
70  // add rand options
72 }
73 
74 
75 void
78  oc.doRegister("alternatives-output", new Option_FileName());
79  oc.addSynonyme("alternatives-output", "alternatives");
80  oc.addDescription("alternatives-output", "Output", "Write generated route alternatives to FILE");
81 
82  oc.doRegister("intermodal-network-output", new Option_FileName());
83  oc.addDescription("intermodal-network-output", "Output", "Write edge splits and connectivity to FILE");
84 
85  oc.doRegister("intermodal-weight-output", new Option_FileName());
86  oc.addDescription("intermodal-weight-output", "Output", "Write intermodal edges with lengths and travel times to FILE");
87 
88  // register import options
89  oc.doRegister("weight-files", 'w', new Option_FileName());
90  oc.addSynonyme("weight-files", "weights");
91  oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)");
92 
93  oc.doRegister("lane-weight-files", new Option_FileName());
94  oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)");
95 
96  oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
97  oc.addSynonyme("weight-attribute", "measure", true);
98  oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
99 
100  oc.doRegister("phemlight-path", new Option_FileName("./PHEMlight/"));
101  oc.addDescription("phemlight-path", "Input", "Determines where to load PHEMlight definitions from.");
102 
103  // register further processing options
104  // ! The subtopic "Processing" must be initialised earlier !
105  oc.doRegister("weights.expand", new Option_Bool(false));
106  oc.addSynonyme("weights.expand", "expand-weights", true);
107  oc.addDescription("weights.expand", "Processing", "Expand weights behind the simulation's end");
108 
109  oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
110  oc.addDescription("routing-algorithm", "Processing", "Select among routing algorithms ['dijkstra', 'astar', 'CH', 'CHWrapper']");
111 
112  oc.doRegister("weight-period", new Option_String("3600", "TIME"));
113  oc.addDescription("weight-period", "Processing", "Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy");
114 
115  oc.doRegister("astar.all-distances", new Option_FileName());
116  oc.addDescription("astar.all-distances", "Processing", "Initialize lookup table for astar from the given file (generated by marouter --all-pairs-output)");
117 
118  oc.doRegister("astar.landmark-distances", new Option_FileName());
119  oc.addDescription("astar.landmark-distances", "Processing", "Initialize lookup table for astar ALT-variant from the given file");
120 
121  oc.doRegister("astar.save-landmark-distances", new Option_FileName());
122  oc.addDescription("astar.save-landmark-distances", "Processing", "Save lookup table for astar ALT-variant to the given file");
123 }
124 
125 
126 void
129  // register Gawron's DUE-settings
130  oc.doRegister("gawron.beta", new Option_Float(double(0.3)));
131  oc.addSynonyme("gawron.beta", "gBeta", true);
132  oc.addDescription("gawron.beta", "Processing", "Use FLOAT as Gawron's beta");
133 
134  oc.doRegister("gawron.a", new Option_Float(double(0.05)));
135  oc.addSynonyme("gawron.a", "gA", true);
136  oc.addDescription("gawron.a", "Processing", "Use FLOAT as Gawron's a");
137 
138  oc.doRegister("exit-times", new Option_Bool(false));
139  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
140 
141  oc.doRegister("keep-all-routes", new Option_Bool(false));
142  oc.addDescription("keep-all-routes", "Processing", "Save routes with near zero probability");
143 
144  oc.doRegister("skip-new-routes", new Option_Bool(false));
145  oc.addDescription("skip-new-routes", "Processing", "Only reuse routes from input, do not calculate new ones");
146 
147  oc.doRegister("ptline-routing", new Option_Bool(false));
148  oc.addDescription("ptline-routing", "Processing", "Route all public transport input");
149 
150  oc.doRegister("logit", new Option_Bool(false)); // deprecated
151  oc.addDescription("logit", "Processing", "Use c-logit model (deprecated in favor of --route-choice-method logit)");
152 
153  oc.doRegister("route-choice-method", new Option_String("gawron"));
154  oc.addDescription("route-choice-method", "Processing", "Choose a route choice method: gawron, logit, or lohse");
155 
156  oc.doRegister("logit.beta", new Option_Float(double(-1)));
157  oc.addSynonyme("logit.beta", "lBeta", true);
158  oc.addDescription("logit.beta", "Processing", "Use FLOAT as logit's beta");
159 
160  oc.doRegister("logit.gamma", new Option_Float(double(1)));
161  oc.addSynonyme("logit.gamma", "lGamma", true);
162  oc.addDescription("logit.gamma", "Processing", "Use FLOAT as logit's gamma");
163 
164  oc.doRegister("logit.theta", new Option_Float(double(-1)));
165  oc.addSynonyme("logit.theta", "lTheta", true);
166  oc.addDescription("logit.theta", "Processing", "Use FLOAT as logit's theta (negative values mean auto-estimation)");
167 
168  oc.doRegister("persontrip.walkfactor", new Option_Float(double(0.75)));
169  oc.addDescription("persontrip.walkfactor", "Processing", "Use FLOAT as a factor on pedestrian maximum speed during intermodal routing");
170 
171  oc.doRegister("persontrip.transfer.car-walk", new Option_String("parkingAreas"));
172  oc.addDescription("persontrip.transfer.car-walk", "Processing", "Where are mode changes from car to walking allowed (possible values: 'parkingAreas', 'ptStops', 'allJunctions' and combinations)");
173 
174 }
175 
176 
177 bool
180  bool ok = ROFrame::checkOptions(oc);
181 
183  std::string error;
184  if (oc.isSet("departlane") && !SUMOVehicleParameter::parseDepartLane(oc.getString("departlane"), "option", "departlane", p.departLane, p.departLaneProcedure, error)) {
185  WRITE_ERROR(error);
186  ok = false;
187  }
188  if (oc.isSet("departpos") && !SUMOVehicleParameter::parseDepartPos(oc.getString("departpos"), "option", "departpos", p.departPos, p.departPosProcedure, error)) {
189  WRITE_ERROR(error);
190  ok = false;
191  }
192  if (oc.isSet("departspeed") && !SUMOVehicleParameter::parseDepartSpeed(oc.getString("departspeed"), "option", "departspeed", p.departSpeed, p.departSpeedProcedure, error)) {
193  WRITE_ERROR(error);
194  ok = false;
195  }
196  if (oc.isSet("arrivallane") && !SUMOVehicleParameter::parseArrivalLane(oc.getString("arrivallane"), "option", "arrivallane", p.arrivalLane, p.arrivalLaneProcedure, error)) {
197  WRITE_ERROR(error);
198  ok = false;
199  }
200  if (oc.isSet("arrivalpos") && !SUMOVehicleParameter::parseArrivalPos(oc.getString("arrivalpos"), "option", "arrivalpos", p.arrivalPos, p.arrivalPosProcedure, error)) {
201  WRITE_ERROR(error);
202  ok = false;
203  }
204  if (oc.isSet("arrivalspeed") && !SUMOVehicleParameter::parseArrivalSpeed(oc.getString("arrivalspeed"), "option", "arrivalspeed", p.arrivalSpeed, p.arrivalSpeedProcedure, error)) {
205  WRITE_ERROR(error);
206  ok = false;
207  }
208 
209  if (oc.getString("routing-algorithm") != "dijkstra" && oc.getString("weight-attribute") != "traveltime") {
210  WRITE_ERROR("Routing algorithm '" + oc.getString("routing-algorithm") + "' does not support weight-attribute '" + oc.getString("weight-attribute") + "'.");
211  return false;
212  }
213  if (oc.getBool("bulk-routing") && (oc.getString("routing-algorithm") == "CH" || oc.getString("routing-algorithm") == "CHWrapper")) {
214  WRITE_ERROR("Routing algorithm '" + oc.getString("routing-algorithm") + "' does not support bulk routing.");
215  return false;
216  }
217  if (oc.isDefault("routing-algorithm") && (oc.isSet("astar.all-distances") || oc.isSet("astar.landmark-distances") || oc.isSet("astar.save-landmark-distances"))) {
218  oc.set("routing-algorithm", "astar");
219  }
220 
221  if (oc.getString("route-choice-method") != "gawron" && oc.getString("route-choice-method") != "logit") {
222  WRITE_ERROR("Invalid route choice method '" + oc.getString("route-choice-method") + "'.");
223  return false;
224  }
225  if (oc.getBool("logit")) {
226  WRITE_WARNING("The --logit option is deprecated, please use --route-choice-method logit.");
227  oc.set("route-choice-method", "logit");
228  }
229 
230  if (oc.isSet("output-file") && !oc.isSet("alternatives-output")) {
231  const std::string& filename = oc.getString("output-file");
232  const int len = (int)filename.length();
233  if (len > 4 && filename.substr(len - 4) == ".xml") {
234  oc.set("alternatives-output", filename.substr(0, len - 4) + ".alt.xml");
235  } else if (len > 4 && filename.substr(len - 4) == ".sbx") {
236  oc.set("alternatives-output", filename.substr(0, len - 4) + ".alt.sbx");
237  } else {
238  WRITE_WARNING("Cannot derive file name for alternatives output, skipping it.");
239  }
240  }
241  return ok;
242 }
243 
244 
245 
246 /****************************************************************************/
247 
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:81
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:47
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:71
static void addImportOptions()
Inserts import options used by duarouter into the OptionsCont-singleton.
Definition: RODUAFrame.cpp:76
static void fillOptions(OptionsCont &oc)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:49
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter...
Definition: RODUAFrame.cpp:178
void addCallExample(const std::string &example, const std::string &desc)
Add a call example.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle&#39;s end speed shall be chosen.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
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
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
double departSpeed
(optional) The initial speed of the vehicle
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
Definition: RODUAFrame.cpp:51
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:167
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
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.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
double arrivalPos
(optional) The position the vehicle shall arrive on
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
double departPos
(optional) The position the vehicle shall depart from
Structure representing possible vehicle parameter.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
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.
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.
A storage for options typed value containers)
Definition: OptionsCont.h:98
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 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.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
static void addDUAOptions()
Inserts dua options used by duarouter into the OptionsCont-singleton.
Definition: RODUAFrame.cpp:127
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
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.