Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-2026 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 118 : ROMAFrame::fillOptions() {
45 118 : OptionsCont& oc = OptionsCont::getOptions();
46 236 : oc.addCallExample("-c <CONFIGURATION>", TL("run routing with options from file"));
47 :
48 : // insert options sub-topics
49 118 : SystemFrame::addConfigurationOptions(oc); // fill this subtopic, too
50 118 : oc.addOptionSubTopic("Input");
51 118 : oc.addOptionSubTopic("Output");
52 118 : oc.addOptionSubTopic("Processing");
53 118 : oc.addOptionSubTopic("Defaults");
54 118 : oc.addOptionSubTopic("Time");
55 :
56 : // insert options
57 118 : ROFrame::fillOptions(oc, false, true);
58 118 : addImportOptions();
59 118 : addAssignmentOptions();
60 : // add rand options
61 118 : RandHelper::insertRandOptions(oc);
62 118 : }
63 :
64 :
65 : void
66 118 : ROMAFrame::addImportOptions() {
67 118 : OptionsCont& oc = OptionsCont::getOptions();
68 : // register import options
69 118 : oc.doRegister("ignore-vehicle-type", new Option_Bool(false));
70 236 : oc.addSynonyme("ignore-vehicle-type", "no-vtype", true);
71 236 : oc.addDescription("ignore-vehicle-type", "Output", TL("Does not save vtype information"));
72 :
73 118 : oc.doRegister("netload-output", new Option_FileName());
74 236 : oc.addDescription("netload-output", "Output", TL("Writes edge loads and final costs into FILE"));
75 :
76 118 : oc.doRegister("all-pairs-output", new Option_FileName());
77 236 : oc.addDescription("all-pairs-output", "Output", TL("Writes complete distance matrix into FILE"));
78 :
79 118 : oc.doRegister("od-matrix-files", 'm', new Option_FileName());
80 236 : oc.addSynonyme("od-matrix-files", "od-files");
81 236 : oc.addDescription("od-matrix-files", "Input", TL("Loads O/D-files from FILE(s)"));
82 :
83 118 : oc.doRegister("od-amitran-files", new Option_FileName());
84 236 : oc.addSynonyme("od-amitran-files", "amitran-files");
85 236 : oc.addSynonyme("od-amitran-files", "amitran");
86 236 : oc.addDescription("od-amitran-files", "Input", TL("Loads O/D-matrix in Amitran format from FILE(s)"));
87 :
88 118 : oc.doRegister("tazrelation-files", 'z', new Option_FileName());
89 236 : oc.addDescription("tazrelation-files", "Input", TL("Loads O/D-matrix in tazRelation format from FILE(s)"));
90 :
91 236 : oc.doRegister("tazrelation-attribute", new Option_String("count"));
92 236 : oc.addSynonyme("tazrelation-attribute", "attribute");
93 236 : oc.addDescription("tazrelation-attribute", "Input", TL("Define data attribute for loading counts (default 'count')"));
94 :
95 118 : oc.doRegister("weight-adaption", new Option_Float(0.));
96 236 : oc.addDescription("weight-adaption", "Input", TL("The travel time influence of prior intervals"));
97 :
98 118 : oc.doRegister("taz-param", new Option_StringVector());
99 236 : oc.addDescription("taz-param", "Input", TL("Parameter key(s) defining source (and sink) taz"));
100 :
101 118 : oc.doRegister("ignore-taz", new Option_Bool(false));
102 236 : oc.addDescription("ignore-taz", "Input", TL("Ignore attributes 'fromTaz' and 'toTaz'"));
103 :
104 : // register the processing options
105 236 : oc.doRegister("aggregation-interval", new Option_String("3600", "TIME"));
106 236 : oc.addDescription("aggregation-interval", "Processing", TL("Defines the time interval when aggregating single vehicle input; Defaults to one hour"));
107 :
108 118 : oc.doRegister("capacities.default", new Option_Bool(false));
109 236 : oc.addDescription("capacities.default", "Processing", TL("Ignore edge priorities when calculating capacities and restraints"));
110 :
111 118 : oc.doRegister("weights.priority-factor", new Option_Float(0));
112 236 : oc.addDescription("weights.priority-factor", "Processing", TL("Consider edge priorities in addition to travel times, weighted by factor"));
113 :
114 118 : oc.doRegister("bulk-routing.vtypes", new Option_Bool(false));
115 236 : oc.addDescription("bulk-routing.vtypes", "Processing", TL("Aggregate routing queries with the same origin for different vehicle types"));
116 :
117 236 : oc.doRegister("weight-period", new Option_String("3600", "TIME"));
118 236 : oc.addDescription("weight-period", "Processing", TL("Aggregation period for the given weight files; triggers rebuilding of Contraction Hierarchy"));
119 :
120 : // register defaults options
121 236 : oc.doRegister("flow-output.departlane", new Option_String("free"));
122 236 : oc.addSynonyme("flow-output.departlane", "departlane");
123 236 : oc.addDescription("flow-output.departlane", "Defaults", TL("Assigns a default depart lane"));
124 :
125 118 : oc.doRegister("flow-output.departpos", new Option_String());
126 236 : oc.addSynonyme("flow-output.departpos", "departpos");
127 236 : oc.addDescription("flow-output.departpos", "Defaults", TL("Assigns a default depart position"));
128 :
129 236 : oc.doRegister("flow-output.departspeed", new Option_String("max"));
130 236 : oc.addSynonyme("flow-output.departspeed", "departspeed");
131 236 : oc.addDescription("flow-output.departspeed", "Defaults", TL("Assigns a default depart speed"));
132 :
133 118 : oc.doRegister("flow-output.arrivallane", new Option_String());
134 236 : oc.addSynonyme("flow-output.arrivallane", "arrivallane");
135 236 : oc.addDescription("flow-output.arrivallane", "Defaults", TL("Assigns a default arrival lane"));
136 :
137 118 : oc.doRegister("flow-output.arrivalpos", new Option_String());
138 236 : oc.addSynonyme("flow-output.arrivalpos", "arrivalpos");
139 236 : oc.addDescription("flow-output.arrivalpos", "Defaults", TL("Assigns a default arrival position"));
140 :
141 118 : oc.doRegister("flow-output.arrivalspeed", new Option_String());
142 236 : oc.addSynonyme("flow-output.arrivalspeed", "arrivalspeed");
143 236 : oc.addDescription("flow-output.arrivalspeed", "Defaults", TL("Assigns a default arrival speed"));
144 :
145 118 : }
146 :
147 :
148 : void
149 118 : ROMAFrame::addAssignmentOptions() {
150 118 : OptionsCont& oc = OptionsCont::getOptions();
151 : // register the data processing options
152 118 : oc.doRegister("scale", 's', new Option_Float(1));
153 236 : oc.addDescription("scale", "Processing", TL("Scales the loaded flows by FLOAT"));
154 :
155 236 : oc.doRegister("vtype", new Option_String(""));
156 236 : oc.addDescription("vtype", "Processing", TL("Defines the name of the vehicle type to use"));
157 :
158 236 : oc.doRegister("prefix", new Option_String(""));
159 236 : oc.addDescription("prefix", "Processing", TL("Defines the prefix for vehicle flow names"));
160 :
161 118 : oc.doRegister("timeline", new Option_StringVector());
162 236 : oc.addDescription("timeline", "Processing", TL("Uses STR[] as a timeline definition"));
163 :
164 118 : oc.doRegister("timeline.day-in-hours", new Option_Bool(false));
165 236 : oc.addDescription("timeline.day-in-hours", "Processing", TL("Uses STR as a 24h-timeline definition"));
166 :
167 118 : oc.doRegister("additive-traffic", new Option_Bool(false));
168 236 : oc.addDescription("additive-traffic", "Processing", TL("Keep traffic flows of all time slots in the net"));
169 :
170 : // register macroscopic SUE-settings
171 236 : oc.doRegister("assignment-method", new Option_String("incremental"));
172 236 : oc.addDescription("assignment-method", "Processing", TL("Choose a assignment method: incremental, UE or SUE"));
173 :
174 118 : oc.doRegister("tolerance", new Option_Float(double(0.001)));
175 236 : oc.addDescription("tolerance", "Processing", TL("Use FLOAT as tolerance when checking for SUE stability"));
176 :
177 118 : oc.doRegister("left-turn-penalty", new Option_Float(0.));
178 236 : oc.addDescription("left-turn-penalty", "Processing", TL("Use left-turn penalty FLOAT to calculate link travel time when searching routes"));
179 :
180 118 : oc.doRegister("paths", new Option_Integer(1));
181 236 : 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 118 : oc.doRegister("paths.penalty", new Option_Float(double(1)));
184 236 : oc.addDescription("paths.penalty", "Processing", TL("Penalize existing routes with FLOAT to find secondary routes"));
185 :
186 118 : oc.doRegister("upperbound", new Option_Float(double(0.5)));
187 236 : oc.addSynonyme("upperbound", "upper", true);
188 236 : oc.addDescription("upperbound", "Processing", TL("Use FLOAT as the upper bound to determine auxiliary link cost"));
189 :
190 118 : oc.doRegister("lowerbound", new Option_Float(double(0.15)));
191 236 : oc.addSynonyme("lowerbound", "lower", true);
192 236 : oc.addDescription("lowerbound", "Processing", TL("Use FLOAT as the lower bound to determine auxiliary link cost"));
193 :
194 118 : oc.doRegister("max-iterations", 'i', new Option_Integer(20));
195 236 : oc.addDescription("max-iterations", "Processing", TL("maximal number of iterations for new route searching in incremental and stochastic user assignment"));
196 :
197 118 : oc.doRegister("max-inner-iterations", new Option_Integer(1000));
198 236 : 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 236 : oc.doRegister("route-choice-method", new Option_String("logit"));
202 236 : oc.addDescription("route-choice-method", "Processing", TL("Choose a route choice method: gawron, logit, or lohse"));
203 :
204 118 : oc.doRegister("gawron.beta", new Option_Float(double(0.3)));
205 236 : oc.addSynonyme("gawron.beta", "gBeta", true);
206 236 : oc.addDescription("gawron.beta", "Processing", TL("Use FLOAT as Gawron's beta"));
207 :
208 118 : oc.doRegister("gawron.a", new Option_Float(double(0.05)));
209 236 : oc.addSynonyme("gawron.a", "gA", true);
210 236 : oc.addDescription("gawron.a", "Processing", TL("Use FLOAT as Gawron's a"));
211 :
212 118 : oc.doRegister("exit-times", new Option_Bool(false));
213 236 : oc.addDescription("exit-times", "Output", TL("Write exit times (weights) for each edge"));
214 :
215 118 : oc.doRegister("keep-all-routes", new Option_Bool(false));
216 236 : oc.addDescription("keep-all-routes", "Processing", TL("Save routes with near zero probability"));
217 :
218 118 : oc.doRegister("skip-new-routes", new Option_Bool(false));
219 236 : oc.addDescription("skip-new-routes", "Processing", TL("Only reuse routes from input, do not calculate new ones"));
220 :
221 118 : oc.doRegister("logit.beta", new Option_Float(double(0.15))); // check: remove the default?
222 236 : oc.addSynonyme("logit.beta", "lBeta", true);
223 236 : oc.addDescription("logit.beta", "Processing", TL("Use FLOAT as (c-)logit's beta for the commonality factor"));
224 :
225 118 : oc.doRegister("logit.gamma", new Option_Float(double(1)));
226 236 : oc.addSynonyme("logit.gamma", "lGamma", true);
227 236 : oc.addDescription("logit.gamma", "Processing", TL("Use FLOAT as (c-)logit's gamma for the commonality factor"));
228 :
229 118 : oc.doRegister("logit.theta", new Option_Float(double(0.01)));
230 236 : oc.addSynonyme("logit.theta", "lTheta", true);
231 236 : oc.addDescription("logit.theta", "Processing", TL("Use FLOAT as (c-)logit's theta"));
232 118 : }
233 :
234 :
235 : bool
236 112 : ROMAFrame::checkOptions() {
237 112 : OptionsCont& oc = OptionsCont::getOptions();
238 363 : 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 336 : 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 132 : if (oc.getInt("paths") > 1 && (oc.getString("routing-algorithm") == "CH" || oc.getString("routing-algorithm") == "CHWrapper" || oc.getString("routing-algorithm") == "CCH")) {
247 4 : 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 : /****************************************************************************/
|