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