SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-sim.org/
12 // Copyright (C) 2001-2013 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>
36 #include <utils/options/Option.h>
40 #include <utils/common/ToString.h>
41 #include <utils/common/SUMOTime.h>
42 #include "ROFrame.h"
43 
44 #ifdef CHECK_MEMORY_LEAKS
45 #include <foreign/nvwa/debug_new.h>
46 #endif // CHECK_MEMORY_LEAKS
47 
48 
49 // ===========================================================================
50 // method definitions
51 // ===========================================================================
52 void
53 ROFrame::fillOptions(OptionsCont& oc, bool forDuarouter) {
54  // register options
55  // register I/O options
56  oc.doRegister("output-file", 'o', new Option_FileName());
57  oc.addSynonyme("output-file", "output");
58  oc.addDescription("output-file", "Output", "Write generated routes to FILE");
59 
60  oc.doRegister("vtype-output", new Option_FileName(""));
61  oc.addSynonyme("vtype-output", "vtype");
62  oc.addDescription("vtype-output", "Output", "Write used vehicle types into separate FILE");
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", 'd', new Option_FileName());
69  oc.addSynonyme("additional-files", "additional");
70  oc.addSynonyme("additional-files", "taz-files");
71  oc.addSynonyme("additional-files", "districts", true);
72  oc.addDescription("additional-files", "Input", "Read additional network data (districts, bus stops) from FILE");
73 
74  oc.doRegister("alternative-files", 'a', new Option_FileName());
75  oc.addSynonyme("alternative-files", "alternatives-files");
76  oc.addSynonyme("alternative-files", "alternatives", true);
77  oc.addDescription("alternative-files", "Input", "Read alternatives from FILE");
78 
79  oc.doRegister("flow-files", 'f', new Option_FileName());
80  oc.addSynonyme("flow-files", "flows");
81  oc.addSynonyme("flow-files", "flow-definition", true);
82  oc.addDescription("flow-files", "Input", "Read flow-definitions from FILE(s)");
83 
84  if (forDuarouter) {
85  oc.doRegister("weight-files", 'w', new Option_FileName());
86  oc.addSynonyme("weight-files", "weights");
87  oc.addDescription("weight-files", "Input", "Read network weights from FILE(s)");
88 
89  oc.doRegister("lane-weight-files", new Option_FileName());
90  oc.addDescription("lane-weight-files", "Input", "Read lane-based network weights from FILE(s)");
91 
92  oc.doRegister("weight-attribute", 'x', new Option_String("traveltime"));
93  oc.addSynonyme("weight-attribute", "measure", true);
94  oc.addDescription("weight-attribute", "Input", "Name of the xml attribute which gives the edge weight");
95  }
96 
97  // register the time settings
98  oc.doRegister("begin", 'b', new Option_String("0", "TIME"));
99  oc.addDescription("begin", "Time", "Defines the begin time; Previous trips will be discarded");
100 
101  oc.doRegister("end", 'e', new Option_String(SUMOTIME_MAXSTRING, "TIME"));
102  oc.addDescription("end", "Time", "Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
103 
104  // register the processing options
105  oc.doRegister("ignore-errors", new Option_Bool(false));
106  oc.addSynonyme("ignore-errors", "continue-on-unbuild", true);
107  oc.addDescription("ignore-errors", "Processing", "Continue if a route could not be build");
108 
109  oc.doRegister("unsorted-input", new Option_Bool(false));
110  oc.addSynonyme("unsorted-input", "unsorted");
111  oc.addDescription("unsorted-input", "Processing", "Assume input is unsorted");
112 
113  oc.doRegister("randomize-flows", new Option_Bool(false));
114  oc.addDescription("randomize-flows", "Processing", "generate random departure times for flow input");
115 
116  oc.doRegister("max-alternatives", new Option_Integer(5));
117  oc.addDescription("max-alternatives", "Processing", "Prune the number of alternatives to INT");
118 
119  oc.doRegister("remove-loops", new Option_Bool(false));
120  oc.addDescription("remove-loops", "Processing", "Remove loops within the route; Remove turnarounds at start and end of the route");
121 
122  oc.doRegister("repair", new Option_Bool(false));
123  oc.addDescription("repair", "Processing", "Tries to correct a false route");
124 
125  oc.doRegister("weights.interpolate", new Option_Bool(false));
126  oc.addSynonyme("weights.interpolate", "interpolate", true);
127  oc.addDescription("weights.interpolate", "Processing", "Interpolate edge weights at interval boundaries");
128 
129  oc.doRegister("with-taz", new Option_Bool(false));
130  oc.addDescription("with-taz", "Processing", "Use origin and destination zones (districts) for in- and output");
131 
132  if (forDuarouter) {
133  oc.doRegister("routing-algorithm", new Option_String("dijkstra"));
134  oc.addDescription("routing-algorithm", "Processing",
135 #ifndef HAVE_INTERNAL // catchall for internal stuff
136  "Select among routing algorithms ['dijkstra', 'astar']"
137 #else
138  "Select among routing algorithms ['dijkstra', 'astar', 'bulkstar', 'CH', 'CHWrapper']"
139 #endif
140  );
141 
142 #ifdef HAVE_INTERNAL // catchall for internal stuff
143  oc.doRegister("weight-period", new Option_String("3600", "TIME"));
144  oc.addDescription("weight-period", "Processing", "Aggregation period for the given weight files; triggers rebuilding of Contraction Hirarchy");
145 #endif
146  }
147 
148  // register defaults options
149  oc.doRegister("departlane", new Option_String());
150  oc.addDescription("departlane", "Defaults", "Assigns a default depart lane");
151 
152  oc.doRegister("departpos", new Option_String());
153  oc.addDescription("departpos", "Defaults", "Assigns a default depart position");
154 
155  oc.doRegister("departspeed", new Option_String());
156  oc.addDescription("departspeed", "Defaults", "Assigns a default depart speed");
157 
158  oc.doRegister("arrivallane", new Option_String());
159  oc.addDescription("arrivallane", "Defaults", "Assigns a default arrival lane");
160 
161  oc.doRegister("arrivalpos", new Option_String());
162  oc.addDescription("arrivalpos", "Defaults", "Assigns a default arrival position");
163 
164  oc.doRegister("arrivalspeed", new Option_String());
165  oc.addDescription("arrivalspeed", "Defaults", "Assigns a default arrival speed");
166 
167  oc.doRegister("defaults-override", new Option_Bool(false));
168  oc.addDescription("defaults-override", "Defaults", "Defaults will override given values");
169 
170 
171  // register report options
172  oc.doRegister("stats-period", new Option_Integer(-1));
173  oc.addDescription("stats-period", "Report", "Defines how often statistics shall be printed");
174 
175  oc.doRegister("no-step-log", new Option_Bool(false));
176  oc.addDescription("no-step-log", "Report", "Disable console output of route parsing step");
177 }
178 
179 
180 bool
182  // check whether the output is valid and can be build
183  if (!oc.isSet("output-file")) {
184  WRITE_ERROR("No output specified.");
185  return false;
186  }
187  //
188  if (oc.getInt("max-alternatives") < 2) {
189  WRITE_ERROR("At least two alternatives should be enabled");
190  return false;
191  }
192  return true;
193 }
194 
195 
196 
197 /****************************************************************************/
198 
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
Definition: OptionsCont.cpp:84
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
static void fillOptions(OptionsCont &oc, bool forDuarouter)
Inserts options used by routing applications into the OptionsCont-singleton.
Definition: ROFrame.cpp:53
static bool checkOptions(OptionsCont &oc)
Checks whether options are valid.
Definition: ROFrame.cpp:181
#define SUMOTIME_MAXSTRING
Definition: SUMOTime.h:46
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:201
An integer-option.
Definition: Option.h:308
A storage for options typed value containers)
Definition: OptionsCont.h:108
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.