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 ROJTRFrame.cpp
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @author Michael Behrisch
18 : /// @date Sept 2002
19 : ///
20 : // Sets and checks options for jtr-routing
21 : /****************************************************************************/
22 : #include <config.h>
23 :
24 : #include <iostream>
25 : #include <fstream>
26 : #include <ctime>
27 : #include <utils/options/OptionsCont.h>
28 : #include <utils/options/Option.h>
29 : #include <utils/common/MsgHandler.h>
30 : #include <utils/common/UtilExceptions.h>
31 : #include <utils/common/ToString.h>
32 : #include "ROJTRFrame.h"
33 : #include <router/ROFrame.h>
34 : #include <utils/common/RandHelper.h>
35 : #include <utils/common/SystemFrame.h>
36 : #include <utils/vehicle/SUMOVehicleParameter.h>
37 :
38 :
39 : // ===========================================================================
40 : // method definitions
41 : // ===========================================================================
42 : void
43 373 : ROJTRFrame::fillOptions() {
44 373 : OptionsCont& oc = OptionsCont::getOptions();
45 746 : oc.addCallExample("-c <CONFIGURATION>", "run with routing options defined in file");
46 :
47 : // insert options sub-topics
48 373 : SystemFrame::addConfigurationOptions(oc);
49 373 : oc.addOptionSubTopic("Input");
50 373 : oc.addOptionSubTopic("Output");
51 373 : oc.addOptionSubTopic("Processing");
52 373 : oc.addOptionSubTopic("Defaults");
53 373 : oc.addOptionSubTopic("Time");
54 :
55 373 : ROFrame::fillOptions(oc);
56 :
57 373 : oc.doRegister("turn-ratio-files", 't', new Option_FileName());
58 746 : oc.addSynonyme("turn-ratio-files", "turns");
59 746 : oc.addDescription("turn-ratio-files", "Input", TL("Read turning ratios from FILE(s)"));
60 :
61 373 : oc.doRegister("exit-times", new Option_Bool(false));
62 746 : oc.addDescription("exit-times", "Output", TL("Write exit times (weights) for each edge"));
63 :
64 373 : oc.doRegister("max-edges-factor", new Option_Float(2.0));
65 746 : oc.addDescription("max-edges-factor", "Processing",
66 : "Routes are cut off when the route edges to net edges ratio is larger than FLOAT");
67 :
68 2238 : oc.doRegister("turn-defaults", 'T', new Option_StringVector(StringVector({ "30", "50", "20" })));
69 746 : oc.addDescription("turn-defaults", "Processing", TL("Use STR[] as default turn definition"));
70 :
71 373 : oc.doRegister("sink-edges", new Option_StringVector());
72 746 : oc.addSynonyme("sink-edges", "sinks");
73 746 : oc.addDescription("sink-edges", "Processing", TL("Use STR[] as list of sink edges"));
74 :
75 373 : oc.doRegister("accept-all-destinations", 'A', new Option_Bool(false));
76 746 : oc.addDescription("accept-all-destinations", "Processing", TL("Whether all edges are allowed as sink edges"));
77 :
78 373 : oc.doRegister("ignore-vclasses", 'i', new Option_Bool(false));
79 746 : oc.addDescription("ignore-vclasses", "Processing", TL("Ignore road restrictions based on vehicle class"));
80 :
81 373 : oc.doRegister("allow-loops", new Option_Bool(false));
82 746 : oc.addDescription("allow-loops", "Processing", TL("Allow to re-use a road"));
83 :
84 373 : oc.doRegister("sources-are-sinks", 'S', new Option_Bool(false));
85 746 : oc.addDescription("sources-are-sinks", "Processing", TL("Use all source edges as sink edges."));
86 :
87 373 : oc.doRegister("discount-sources", 'D', new Option_Bool(false));
88 746 : oc.addDescription("discount-sources", "Processing", TL("Subtract upstream flow when inserting a new flow. When option --sources-are-sinks is set, the upstream flow is limited to the value of the source flow and the remaining part terminates."));
89 :
90 : // add rand options
91 373 : RandHelper::insertRandOptions(oc);
92 1119 : }
93 :
94 :
95 : bool
96 366 : ROJTRFrame::checkOptions() {
97 366 : OptionsCont& oc = OptionsCont::getOptions();
98 366 : bool ok = ROFrame::checkOptions(oc);
99 732 : if (oc.isDefault("no-internal-links")) {
100 732 : oc.setDefault("no-internal-links", "true");
101 : }
102 :
103 366 : SUMOVehicleParameter p;
104 : std::string error;
105 390 : if (oc.isSet("departlane") && !SUMOVehicleParameter::parseDepartLane(oc.getString("departlane"), "option", "departlane", p.departLane, p.departLaneProcedure, error)) {
106 3 : WRITE_ERROR(error);
107 : ok = false;
108 : }
109 380 : if (oc.isSet("departpos") && !SUMOVehicleParameter::parseDepartPos(oc.getString("departpos"), "option", "departpos", p.departPos, p.departPosProcedure, error)) {
110 3 : WRITE_ERROR(error);
111 : ok = false;
112 : }
113 380 : if (oc.isSet("departspeed") && !SUMOVehicleParameter::parseDepartSpeed(oc.getString("departspeed"), "option", "departspeed", p.departSpeed, p.departSpeedProcedure, error)) {
114 3 : WRITE_ERROR(error);
115 : ok = false;
116 : }
117 380 : if (oc.isSet("arrivallane") && !SUMOVehicleParameter::parseArrivalLane(oc.getString("arrivallane"), "option", "arrivallane", p.arrivalLane, p.arrivalLaneProcedure, error)) {
118 3 : WRITE_ERROR(error);
119 : ok = false;
120 : }
121 380 : if (oc.isSet("arrivalpos") && !SUMOVehicleParameter::parseArrivalPos(oc.getString("arrivalpos"), "option", "arrivalpos", p.arrivalPos, p.arrivalPosProcedure, error)) {
122 3 : WRITE_ERROR(error);
123 : ok = false;
124 : }
125 380 : if (oc.isSet("arrivalspeed") && !SUMOVehicleParameter::parseArrivalSpeed(oc.getString("arrivalspeed"), "option", "arrivalspeed", p.arrivalSpeed, p.arrivalSpeedProcedure, error)) {
126 3 : WRITE_ERROR(error);
127 : ok = false;
128 : }
129 366 : return ok;
130 366 : }
131 :
132 :
133 : /****************************************************************************/
|