Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file ROMAFrame.cpp
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @author Laura Bieker
18 : /// @author Michael Behrisch
19 : /// @date Sept 2002
20 : ///
21 : // Sets and checks options for ma-routing
22 : /****************************************************************************/
23 : #include <config.h>
24 :
25 : #include <iostream>
26 : #include <fstream>
27 : #include <ctime>
28 : #include <utils/options/OptionsCont.h>
29 : #include <utils/options/Option.h>
30 : #include <utils/common/MsgHandler.h>
31 : #include <utils/common/UtilExceptions.h>
32 : #include <utils/common/ToString.h>
33 : #include "ROMAFrame.h"
34 : #include <router/ROFrame.h>
35 : #include <utils/common/RandHelper.h>
36 : #include <utils/common/SystemFrame.h>
37 : #include <utils/vehicle/SUMOVehicleParameter.h>
38 :
39 :
40 : // ===========================================================================
41 : // method definitions
42 : // ===========================================================================
43 : void
44 100 : ROMAFrame::fillOptions() {
45 100 : OptionsCont& oc = OptionsCont::getOptions();
46 200 : oc.addCallExample("-c <CONFIGURATION>", "run routing with options from file");
47 :
48 : // insert options sub-topics
49 100 : SystemFrame::addConfigurationOptions(oc); // fill this subtopic, too
50 100 : oc.addOptionSubTopic("Input");
51 100 : oc.addOptionSubTopic("Output");
52 100 : oc.addOptionSubTopic("Processing");
53 100 : oc.addOptionSubTopic("Defaults");
54 100 : oc.addOptionSubTopic("Time");
55 :
56 : // insert options
57 100 : ROFrame::fillOptions(oc, false, true);
58 100 : addImportOptions();
59 100 : addAssignmentOptions();
60 : // add rand options
61 100 : RandHelper::insertRandOptions(oc);
62 100 : }
63 :
64 :
65 : void
66 100 : ROMAFrame::addImportOptions() {
67 100 : OptionsCont& oc = OptionsCont::getOptions();
68 : // register import options
69 100 : oc.doRegister("ignore-vehicle-type", new Option_Bool(false));
70 200 : oc.addSynonyme("ignore-vehicle-type", "no-vtype", true);
71 200 : oc.addDescription("ignore-vehicle-type", "Output", TL("Does not save vtype information"));
72 :
73 100 : oc.doRegister("netload-output", new Option_FileName());
74 200 : oc.addDescription("netload-output", "Output", TL("Writes edge loads and final costs into FILE"));
75 :
76 100 : oc.doRegister("all-pairs-output", new Option_FileName());
77 200 : oc.addDescription("all-pairs-output", "Output", TL("Writes complete distance matrix into FILE"));
78 :
79 100 : oc.doRegister("od-matrix-files", 'm', new Option_FileName());
80 200 : oc.addSynonyme("od-matrix-files", "od-files");
81 200 : oc.addDescription("od-matrix-files", "Input", TL("Loads O/D-files from FILE(s)"));
82 :
83 100 : oc.doRegister("od-amitran-files", new Option_FileName());
84 200 : oc.addSynonyme("od-amitran-files", "amitran-files");
85 200 : oc.addSynonyme("od-amitran-files", "amitran");
86 200 : oc.addDescription("od-amitran-files", "Input", TL("Loads O/D-matrix in Amitran format from FILE(s)"));
87 :
88 100 : oc.doRegister("tazrelation-files", 'z', new Option_FileName());
89 200 : oc.addDescription("tazrelation-files", "Input", TL("Loads O/D-matrix in tazRelation format from FILE(s)"));
90 :
91 200 : oc.doRegister("tazrelation-attribute", new Option_String("count"));
92 200 : oc.addSynonyme("tazrelation-attribute", "attribute");
93 200 : oc.addDescription("tazrelation-attribute", "Input", TL("Define data attribute for loading counts (default 'count')"));
94 :
95 100 : oc.doRegister("weight-adaption", new Option_Float(0.));
96 200 : oc.addDescription("weight-adaption", "Input", TL("The travel time influence of prior intervals"));
97 :
98 100 : oc.doRegister("taz-param", new Option_StringVector());
99 200 : oc.addDescription("taz-param", "Input", TL("Parameter key(s) defining source (and sink) taz"));
100 :
101 100 : oc.doRegister("ignore-taz", new Option_Bool(false));
102 200 : oc.addDescription("ignore-taz", "Input", TL("Ignore attributes 'fromTaz' and 'toTaz'"));
103 :
104 : // register the processing options
105 200 : oc.doRegister("aggregation-interval", new Option_String("3600", "TIME"));
106 200 : oc.addDescription("aggregation-interval", "Processing", TL("Defines the time interval when aggregating single vehicle input; Defaults to one hour"));
107 :
108 100 : oc.doRegister("capacities.default", new Option_Bool(false));
109 200 : oc.addDescription("capacities.default", "Processing", TL("Ignore edge priorities when calculating capacities and restraints"));
110 :
111 100 : oc.doRegister("weights.priority-factor", new Option_Float(0));
112 200 : oc.addDescription("weights.priority-factor", "Processing", TL("Consider edge priorities in addition to travel times, weighted by factor"));
113 :
114 100 : oc.doRegister("bulk-routing.vtypes", new Option_Bool(false));
115 200 : oc.addDescription("bulk-routing.vtypes", "Processing", TL("Aggregate routing queries with the same origin for different vehicle types"));
116 :
117 200 : oc.doRegister("weight-period", new Option_String("3600", "TIME"));
118 200 : oc.addDescription("weight-period", "Processing", TL("Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy"));
119 :
120 : // register defaults options
121 200 : oc.doRegister("flow-output.departlane", new Option_String("free"));
122 200 : oc.addSynonyme("flow-output.departlane", "departlane");
123 200 : oc.addDescription("flow-output.departlane", "Defaults", TL("Assigns a default depart lane"));
124 :
125 100 : oc.doRegister("flow-output.departpos", new Option_String());
126 200 : oc.addSynonyme("flow-output.departpos", "departpos");
127 200 : oc.addDescription("flow-output.departpos", "Defaults", TL("Assigns a default depart position"));
128 :
129 200 : oc.doRegister("flow-output.departspeed", new Option_String("max"));
130 200 : oc.addSynonyme("flow-output.departspeed", "departspeed");
131 200 : oc.addDescription("flow-output.departspeed", "Defaults", TL("Assigns a default depart speed"));
132 :
133 100 : oc.doRegister("flow-output.arrivallane", new Option_String());
134 200 : oc.addSynonyme("flow-output.arrivallane", "arrivallane");
135 200 : oc.addDescription("flow-output.arrivallane", "Defaults", TL("Assigns a default arrival lane"));
136 :
137 100 : oc.doRegister("flow-output.arrivalpos", new Option_String());
138 200 : oc.addSynonyme("flow-output.arrivalpos", "arrivalpos");
139 200 : oc.addDescription("flow-output.arrivalpos", "Defaults", TL("Assigns a default arrival position"));
140 :
141 100 : oc.doRegister("flow-output.arrivalspeed", new Option_String());
142 200 : oc.addSynonyme("flow-output.arrivalspeed", "arrivalspeed");
143 200 : oc.addDescription("flow-output.arrivalspeed", "Defaults", TL("Assigns a default arrival speed"));
144 :
145 100 : }
146 :
147 :
148 : void
149 100 : ROMAFrame::addAssignmentOptions() {
150 100 : OptionsCont& oc = OptionsCont::getOptions();
151 : // register the data processing options
152 100 : oc.doRegister("scale", 's', new Option_Float(1));
153 200 : oc.addDescription("scale", "Processing", TL("Scales the loaded flows by FLOAT"));
154 :
155 200 : oc.doRegister("vtype", new Option_String(""));
156 200 : oc.addDescription("vtype", "Processing", TL("Defines the name of the vehicle type to use"));
157 :
158 200 : oc.doRegister("prefix", new Option_String(""));
159 200 : oc.addDescription("prefix", "Processing", TL("Defines the prefix for vehicle flow names"));
160 :
161 100 : oc.doRegister("timeline", new Option_StringVector());
162 200 : oc.addDescription("timeline", "Processing", TL("Uses STR[] as a timeline definition"));
163 :
164 100 : oc.doRegister("timeline.day-in-hours", new Option_Bool(false));
165 200 : oc.addDescription("timeline.day-in-hours", "Processing", TL("Uses STR as a 24h-timeline definition"));
166 :
167 100 : oc.doRegister("additive-traffic", new Option_Bool(false));
168 200 : oc.addDescription("additive-traffic", "Processing", TL("Keep traffic flows of all time slots in the net"));
169 :
170 : // register macroscopic SUE-settings
171 200 : oc.doRegister("assignment-method", new Option_String("incremental"));
172 200 : oc.addDescription("assignment-method", "Processing", TL("Choose a assignment method: incremental, UE or SUE"));
173 :
174 100 : oc.doRegister("tolerance", new Option_Float(double(0.001)));
175 200 : oc.addDescription("tolerance", "Processing", TL("Use FLOAT as tolerance when checking for SUE stability"));
176 :
177 100 : oc.doRegister("left-turn-penalty", new Option_Float(0.));
178 200 : oc.addDescription("left-turn-penalty", "Processing", TL("Use left-turn penalty FLOAT to calculate link travel time when searching routes"));
179 :
180 100 : oc.doRegister("paths", new Option_Integer(1));
181 200 : oc.addDescription("paths", "Processing", TL("Use INTEGER as the number of paths needed to be searched for each OD pair at each iteration"));
182 :
183 100 : oc.doRegister("paths.penalty", new Option_Float(double(1)));
184 200 : oc.addDescription("paths.penalty", "Processing", TL("Penalize existing routes with FLOAT to find secondary routes"));
185 :
186 100 : oc.doRegister("upperbound", new Option_Float(double(0.5)));
187 200 : oc.addSynonyme("upperbound", "upper", true);
188 200 : oc.addDescription("upperbound", "Processing", TL("Use FLOAT as the upper bound to determine auxiliary link cost"));
189 :
190 100 : oc.doRegister("lowerbound", new Option_Float(double(0.15)));
191 200 : oc.addSynonyme("lowerbound", "lower", true);
192 200 : oc.addDescription("lowerbound", "Processing", TL("Use FLOAT as the lower bound to determine auxiliary link cost"));
193 :
194 100 : oc.doRegister("max-iterations", 'i', new Option_Integer(20));
195 200 : oc.addDescription("max-iterations", "Processing", TL("maximal number of iterations for new route searching in incremental and stochastic user assignment"));
196 :
197 100 : oc.doRegister("max-inner-iterations", new Option_Integer(1000));
198 200 : oc.addDescription("max-inner-iterations", "Processing", TL("maximal number of inner iterations for user equilibrium calculation in the stochastic user assignment"));
199 :
200 : // register route choice settings
201 200 : oc.doRegister("route-choice-method", new Option_String("logit"));
202 200 : oc.addDescription("route-choice-method", "Processing", TL("Choose a route choice method: gawron, logit, or lohse"));
203 :
204 100 : oc.doRegister("gawron.beta", new Option_Float(double(0.3)));
205 200 : oc.addSynonyme("gawron.beta", "gBeta", true);
206 200 : oc.addDescription("gawron.beta", "Processing", TL("Use FLOAT as Gawron's beta"));
207 :
208 100 : oc.doRegister("gawron.a", new Option_Float(double(0.05)));
209 200 : oc.addSynonyme("gawron.a", "gA", true);
210 200 : oc.addDescription("gawron.a", "Processing", TL("Use FLOAT as Gawron's a"));
211 :
212 100 : oc.doRegister("exit-times", new Option_Bool(false));
213 200 : oc.addDescription("exit-times", "Output", TL("Write exit times (weights) for each edge"));
214 :
215 100 : oc.doRegister("keep-all-routes", new Option_Bool(false));
216 200 : oc.addDescription("keep-all-routes", "Processing", TL("Save routes with near zero probability"));
217 :
218 100 : oc.doRegister("skip-new-routes", new Option_Bool(false));
219 200 : oc.addDescription("skip-new-routes", "Processing", TL("Only reuse routes from input, do not calculate new ones"));
220 :
221 100 : oc.doRegister("logit.beta", new Option_Float(double(0.15))); // check: remove the default?
222 200 : oc.addSynonyme("logit.beta", "lBeta", true);
223 200 : oc.addDescription("logit.beta", "Processing", TL("Use FLOAT as (c-)logit's beta for the commonality factor"));
224 :
225 100 : oc.doRegister("logit.gamma", new Option_Float(double(1)));
226 200 : oc.addSynonyme("logit.gamma", "lGamma", true);
227 200 : oc.addDescription("logit.gamma", "Processing", TL("Use FLOAT as (c-)logit's gamma for the commonality factor"));
228 :
229 100 : oc.doRegister("logit.theta", new Option_Float(double(0.01)));
230 200 : oc.addSynonyme("logit.theta", "lTheta", true);
231 200 : oc.addDescription("logit.theta", "Processing", TL("Use FLOAT as (c-)logit's theta"));
232 100 : }
233 :
234 :
235 : bool
236 94 : ROMAFrame::checkOptions() {
237 94 : OptionsCont& oc = OptionsCont::getOptions();
238 299 : if (oc.isSet("assignment-method") && oc.getString("assignment-method") != "incremental" && oc.getString("assignment-method") != "UE" && oc.getString("assignment-method") != "SUE") {
239 0 : WRITE_ERRORF(TL("Invalid assignment method '%'."), oc.getString("assignment-method"));
240 0 : return false;
241 : }
242 282 : if (oc.getString("route-choice-method") != "gawron" && oc.getString("route-choice-method") != "logit" && oc.getString("route-choice-method") != "lohse") {
243 0 : WRITE_ERRORF(TL("Invalid route choice method '%'."), oc.getString("route-choice-method"));
244 0 : return false;
245 : }
246 104 : if (oc.getInt("paths") > 1 && (oc.getString("routing-algorithm") == "CH" || oc.getString("routing-algorithm") == "CHWrapper")) {
247 2 : WRITE_WARNING(TL("Contraction hierarchies do not work with k shortest path search (please use a different routing algorithm)!"));
248 : }
249 : return true;
250 : }
251 :
252 :
253 : /****************************************************************************/
|