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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Sets and checks options for routing
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <iostream>
27 #include <ctime>
28 #include <stdlib.h>
30 #include <utils/options/Option.h>
34 #include <utils/common/ToString.h>
35 #include <utils/common/SUMOTime.h>
36 #include "ROFrame.h"
37 
38 
39 // ===========================================================================
40 // method definitions
41 // ===========================================================================
42 void
44  // register options
45  // register I/O options
46  oc.doRegister("output-file", 'o', new Option_FileName());
47  oc.addSynonyme("output-file", "output");
48  oc.addDescription("output-file", "Output", "Write generated routes to FILE");
49 
50  oc.doRegister("vtype-output", new Option_FileName());
51  oc.addSynonyme("vtype-output", "vtype");
52  oc.addDescription("vtype-output", "Output", "Write used vehicle types into separate FILE");
53 
54  oc.doRegister("keep-vtype-distributions", new Option_Bool(false));
55  oc.addDescription("keep-vtype-distributions", "Output", "Keep vTypeDistribution ids when writing vehicles and their types");
56 
57  oc.doRegister("net-file", 'n', new Option_FileName());
58  oc.addSynonyme("net-file", "net");
59  oc.addDescription("net-file", "Input", "Use FILE as SUMO-network to route on");
60 
61  oc.doRegister("additional-files", 'a', new Option_FileName());
62  oc.addSynonyme("additional-files", "d", true);
63  oc.addSynonyme("additional-files", "additional");
64  oc.addSynonyme("additional-files", "taz-files");
65  oc.addSynonyme("additional-files", "districts", true);
66  oc.addDescription("additional-files", "Input", "Read additional network data (districts, bus stops) from FILE(s)");
67 
68  oc.doRegister("route-files", 'r', new Option_FileName());
69  oc.addSynonyme("route-files", "flow-files", true);
70  oc.addSynonyme("route-files", "flows", true);
71  oc.addSynonyme("route-files", "f", true);
72  oc.addSynonyme("route-files", "alternative-files", true);
73  oc.addSynonyme("route-files", "alternatives-files", true);
74  oc.addSynonyme("route-files", "trip-files", true);
75  oc.addSynonyme("route-files", "trips", true);
76  oc.addDescription("route-files", "Input", "Read sumo routes, alternatives, flows, and trips from FILE(s)");
77 
78  // register the time settings
79  oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
80  oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
81 
82  oc.doRegister("end", 'e', new Option_String(SUMOTIME_MAXSTRING, "TIME"));
83  oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
84 
85  // register the processing options
86  oc.doRegister("ignore-errors", new Option_Bool(false));
87  oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
88  oc.addDescription("ignore-errors", "Report", "Continue if a route could not be build");
89 
90  oc.doRegister("unsorted-input", new Option_Bool(false));
91  oc.addSynonyme("unsorted-input", "unsorted");
92  oc.addDescription("unsorted-input", "Processing", "Assume input is unsorted");
93 
94  oc.doRegister("route-steps", 's', new Option_String("200", "TIME"));
95  oc.addDescription("route-steps", "Processing", "Load routes for the next number of seconds ahead");
96 
97  oc.doRegister("no-internal-links", new Option_Bool(false));
98  oc.addDescription("no-internal-links", "Processing", "Disable (junction) internal links");
99 
100  oc.doRegister("randomize-flows", new Option_Bool(false));
101  oc.addDescription("randomize-flows", "Processing", "generate random departure times for flow input");
102 
103  oc.doRegister("max-alternatives", new Option_Integer(5));
104  oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
105 
106  oc.doRegister("remove-loops", new Option_Bool(false));
107  oc.addDescription("remove-loops", "Processing", "Remove loops within the route; Remove turnarounds at start and end of the route");
108 
109  oc.doRegister("repair", new Option_Bool(false));
110  oc.addDescription("repair", "Processing", "Tries to correct a false route");
111 
112  oc.doRegister("repair.from", new Option_Bool(false));
113  oc.addDescription("repair.from", "Processing", "Tries to correct an invalid starting edge by using the first usable edge instead");
114 
115  oc.doRegister("repair.to", new Option_Bool(false));
116  oc.addDescription("repair.to", "Processing", "Tries to correct an invalid destination edge by using the last usable edge instead");
117 
118  oc.doRegister("weights.interpolate", new Option_Bool(false));
119  oc.addSynonyme("weights.interpolate", "interpolate", true);
120  oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
121 
122  oc.doRegister("with-taz", new Option_Bool(false));
123  oc.addDescription("with-taz", "Processing", "Use origin and destination zones (districts) for in- and output");
124 
125  oc.doRegister("bulk-routing", new Option_Bool(false));
126  oc.addDescription("bulk-routing", "Processing", "Aggregate routing queries with the same origin");
127 
128  oc.doRegister("routing-threads", new Option_Integer(0));
129  oc.addDescription("routing-threads", "Processing", "The number of parallel execution threads used for routing");
130 
131  // register defaults options
132  oc.doRegister("departlane", new Option_String());
133  oc.addDescription("departlane", "Defaults", "Assigns a default depart lane");
134 
135  oc.doRegister("departpos", new Option_String());
136  oc.addDescription("departpos", "Defaults", "Assigns a default depart position");
137 
138  oc.doRegister("departspeed", new Option_String());
139  oc.addDescription("departspeed", "Defaults", "Assigns a default depart speed");
140 
141  oc.doRegister("arrivallane", new Option_String());
142  oc.addDescription("arrivallane", "Defaults", "Assigns a default arrival lane");
143 
144  oc.doRegister("arrivalpos", new Option_String());
145  oc.addDescription("arrivalpos", "Defaults", "Assigns a default arrival position");
146 
147  oc.doRegister("arrivalspeed", new Option_String());
148  oc.addDescription("arrivalspeed", "Defaults", "Assigns a default arrival speed");
149 
150  oc.doRegister("defaults-override", new Option_Bool(false));
151  oc.addDescription("defaults-override", "Defaults", "Defaults will override given values");
152 
153 
154  // register report options
155  oc.doRegister("stats-period", new Option_Integer(-1));
156  oc.addDescription("stats-period", "Report", "Defines how often statistics shall be printed");
157 
158  oc.doRegister("no-step-log", new Option_Bool(false));
159  oc.addDescription("no-step-log", "Report", "Disable console output of route parsing step");
160 }
161 
162 
163 bool
165  // check whether the output is valid and can be build
166  if (!oc.isSet("output-file")) {
167  WRITE_ERROR("No output specified.");
168  return false;
169  }
170  //
171  if (oc.getInt("max-alternatives") < 2) {
172  WRITE_ERROR("At least two alternatives should be enabled.");
173  return false;
174  }
175 #ifndef HAVE_FOX
176  if (oc.getInt("routing-threads") > 1) {
177  WRITE_ERROR("Parallel routing is only possible when compiled with Fox.");
178  return false;
179  }
180 #endif
181  return true;
182 }
183 
184 
185 
186 /****************************************************************************/
187 
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:75
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
static void fillOptions(OptionsCont &oc)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:43
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
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:164
#define SUMOTIME_MAXSTRING
Definition: SUMOTime.h:39
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:247
An integer-option.
Definition: Option.h:333
A storage for options typed value containers)
Definition: OptionsCont.h:92
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.