SUMO - Simulation of Urban MObility
RODUAFrame.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Sets and checks options for dua-routing
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <iostream>
34 #include <fstream>
35 #include <ctime>
37 #include <utils/options/Option.h>
40 #include <utils/common/ToString.h>
41 #include "RODUAFrame.h"
42 #include <router/ROFrame.h>
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
51 void
54  oc.addCallExample("-c <CONFIGURATION>", "run routing with options from file");
55 
56  // insert options sub-topics
57  SystemFrame::addConfigurationOptions(oc); // fill this subtopic, too
58  oc.addOptionSubTopic("Input");
59  oc.addOptionSubTopic("Output");
60  oc.addOptionSubTopic("Processing");
61  oc.addOptionSubTopic("Defaults");
62  oc.addOptionSubTopic("Time");
63  SystemFrame::addReportOptions(oc); // fill this subtopic, too
64 
65  // insert options
67  // to make the transition from --trip-files easier, but has a conflict with jtrrouter
68  oc.addSynonyme("route-files", "t", true);
70  addDUAOptions();
71  // add rand options
73 }
74 
75 
76 void
79  // register import options
80  oc.doRegister("weight-files", 'w', new Option_FileName());
81  oc.addSynonyme("weight-files", "weights");
82  oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)");
83 
84  oc.doRegister("lane-weight-files", new Option_FileName());
85  oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)");
86 
87  oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
88  oc.addSynonyme("weight-attribute", "measure", true);
89  oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
90 
91  oc.doRegister("phemlight-path", new Option_FileName("./PHEMlight/"));
92  oc.addDescription("phemlight-path", "Input", "Determines where to load PHEMlight definitions from.");
93 
94  // register further processing options
95  // ! The subtopic "Processing" must be initialised earlier !
96  oc.doRegister("weights.expand", new Option_Bool(false));
97  oc.addSynonyme("weights.expand", "expand-weights", true);
98  oc.addDescription("weights.expand", "Processing", "Expand weights behind the simulation's end");
99 
100  oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
101  oc.addDescription("routing-algorithm", "Processing", "Select among routing algorithms ['dijkstra', 'astar', 'CH', 'CHWrapper']");
102 
103  oc.doRegister("weight-period", new Option_String("3600", "TIME"));
104  oc.addDescription("weight-period", "Processing", "Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy");
105 
106  oc.doRegister("astar.all-distances", new Option_FileName());
107  oc.addDescription("astar.all-distances", "Processing", "Initialize lookup table for astar from the given file (generated by marouter --all-pairs-output)");
108 
109  oc.doRegister("astar.landmark-distances", new Option_FileName());
110  oc.addDescription("astar.landmark-distances", "Processing", "Initialize lookup table for astar ALT-variant from the given file");
111 
112  oc.doRegister("astar.save-landmark-distances", new Option_FileName());
113  oc.addDescription("astar.save-landmark-distances", "Processing", "Save lookup table for astar ALT-variant to the given file");
114 }
115 
116 
117 void
120  // register Gawron's DUE-settings
121  oc.doRegister("gawron.beta", new Option_Float(double(0.3)));
122  oc.addSynonyme("gawron.beta", "gBeta", true);
123  oc.addDescription("gawron.beta", "Processing", "Use FLOAT as Gawron's beta");
124 
125  oc.doRegister("gawron.a", new Option_Float(double(0.05)));
126  oc.addSynonyme("gawron.a", "gA", true);
127  oc.addDescription("gawron.a", "Processing", "Use FLOAT as Gawron's a");
128 
129  oc.doRegister("exit-times", new Option_Bool(false));
130  oc.addDescription("exit-times", "Output", "Write exit times (weights) for each edge");
131 
132  oc.doRegister("keep-all-routes", new Option_Bool(false));
133  oc.addDescription("keep-all-routes", "Processing", "Save routes with near zero probability");
134 
135  oc.doRegister("skip-new-routes", new Option_Bool(false));
136  oc.addDescription("skip-new-routes", "Processing", "Only reuse routes from input, do not calculate new ones");
137 
138  oc.doRegister("logit", new Option_Bool(false)); // deprecated
139  oc.addDescription("logit", "Processing", "Use c-logit model (deprecated in favor of --route-choice-method logit)");
140 
141  oc.doRegister("route-choice-method", new Option_String("gawron"));
142  oc.addDescription("route-choice-method", "Processing", "Choose a route choice method: gawron, logit, or lohse");
143 
144  oc.doRegister("logit.beta", new Option_Float(double(-1)));
145  oc.addSynonyme("logit.beta", "lBeta", true);
146  oc.addDescription("logit.beta", "Processing", "Use FLOAT as logit's beta");
147 
148  oc.doRegister("logit.gamma", new Option_Float(double(1)));
149  oc.addSynonyme("logit.gamma", "lGamma", true);
150  oc.addDescription("logit.gamma", "Processing", "Use FLOAT as logit's gamma");
151 
152  oc.doRegister("logit.theta", new Option_Float(double(-1)));
153  oc.addSynonyme("logit.theta", "lTheta", true);
154  oc.addDescription("logit.theta", "Processing", "Use FLOAT as logit's theta (negative values mean auto-estimation)");
155 
156  oc.doRegister("persontrip.walkfactor", new Option_Float(double(0.9)));
157  oc.addDescription("persontrip.walkfactor", "Processing", "Use FLOAT as a factor on pedestrian maximum speed during intermodal routing");
158 
159 }
160 
161 
162 bool
165  bool ok = ROFrame::checkOptions(oc);
166 
168  std::string error;
169  if (oc.isSet("departlane") && !SUMOVehicleParameter::parseDepartLane(oc.getString("departlane"), "option", "departlane", p.departLane, p.departLaneProcedure, error)) {
170  WRITE_ERROR(error);
171  ok = false;
172  }
173  if (oc.isSet("departpos") && !SUMOVehicleParameter::parseDepartPos(oc.getString("departpos"), "option", "departpos", p.departPos, p.departPosProcedure, error)) {
174  WRITE_ERROR(error);
175  ok = false;
176  }
177  if (oc.isSet("departspeed") && !SUMOVehicleParameter::parseDepartSpeed(oc.getString("departspeed"), "option", "departspeed", p.departSpeed, p.departSpeedProcedure, error)) {
178  WRITE_ERROR(error);
179  ok = false;
180  }
181  if (oc.isSet("arrivallane") && !SUMOVehicleParameter::parseArrivalLane(oc.getString("arrivallane"), "option", "arrivallane", p.arrivalLane, p.arrivalLaneProcedure, error)) {
182  WRITE_ERROR(error);
183  ok = false;
184  }
185  if (oc.isSet("arrivalpos") && !SUMOVehicleParameter::parseArrivalPos(oc.getString("arrivalpos"), "option", "arrivalpos", p.arrivalPos, p.arrivalPosProcedure, error)) {
186  WRITE_ERROR(error);
187  ok = false;
188  }
189  if (oc.isSet("arrivalspeed") && !SUMOVehicleParameter::parseArrivalSpeed(oc.getString("arrivalspeed"), "option", "arrivalspeed", p.arrivalSpeed, p.arrivalSpeedProcedure, error)) {
190  WRITE_ERROR(error);
191  ok = false;
192  }
193 
194  if (oc.getString("routing-algorithm") != "dijkstra" && oc.getString("weight-attribute") != "traveltime") {
195  WRITE_ERROR("Routing algorithm '" + oc.getString("routing-algorithm") + "' does not support weight-attribute '" + oc.getString("weight-attribute") + "'.");
196  return false;
197  }
198 
199  if (oc.getBool("bulk-routing") && (oc.getString("routing-algorithm") == "CH" || oc.getString("routing-algorithm") == "CHWrapper")) {
200  WRITE_ERROR("Routing algorithm '" + oc.getString("routing-algorithm") + "' does not support bulk routing.");
201  return false;
202  }
203 
204  if (oc.isDefault("routing-algorithm") && (oc.isSet("astar.all-distances") || oc.isSet("astar.landmark-distances") || oc.isSet("astar.save-landmark-distances"))) {
205  oc.set("routing-algorithm", "astar");
206  }
207 
208  if (oc.getString("route-choice-method") != "gawron" && oc.getString("route-choice-method") != "logit") {
209  WRITE_ERROR("Invalid route choice method '" + oc.getString("route-choice-method") + "'.");
210  return false;
211  }
212 
213  if (oc.getBool("logit")) {
214  WRITE_WARNING("The --logit option is deprecated, please use --route-choice-method logit.");
215  oc.set("route-choice-method", "logit");
216  }
217  return ok;
218 }
219 
220 
221 
222 /****************************************************************************/
223 
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:82
static void insertRandOptions()
Initialises the given options container with random number options.
Definition: RandHelper.cpp:48
static void addReportOptions(OptionsCont &oc)
Adds reporting options to the given container.
Definition: SystemFrame.cpp:72
static void addImportOptions()
Inserts import options used by duarouter into the OptionsCont-singleton.
Definition: RODUAFrame.cpp:77
static void fillOptions(OptionsCont &oc)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:50
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:163
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.
static void addConfigurationOptions(OptionsCont &oc)
Adds configuration options to the given container.
Definition: SystemFrame.cpp:47
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
double departSpeed
(optional) The initial speed of the vehicle
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
Definition: RODUAFrame.cpp:52
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:168
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.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default 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:206
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:99
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:118
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
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.