Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDevice_Routing.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2007-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/****************************************************************************/
22// A device that performs vehicle rerouting based on current edge speeds
23/****************************************************************************/
24#include <config.h>
25
26#include <microsim/MSNet.h>
27#include <microsim/MSLane.h>
28#include <microsim/MSEdge.h>
31#include <microsim/MSGlobals.h>
37#include "MSRoutingEngine.h"
38#include "MSDevice_Routing.h"
39
40
41// ===========================================================================
42// method definitions
43// ===========================================================================
44// ---------------------------------------------------------------------------
45// static initialisation methods
46// ---------------------------------------------------------------------------
47void
49 insertDefaultAssignmentOptions("rerouting", "Routing", oc);
50
51 oc.doRegister("device.rerouting.period", new Option_String("0", "TIME"));
52 oc.addSynonyme("device.rerouting.period", "device.routing.period", true);
53 oc.addDescription("device.rerouting.period", "Routing", TL("The period with which the vehicle shall be rerouted"));
54
55 oc.doRegister("device.rerouting.pre-period", new Option_String("60", "TIME"));
56 oc.addSynonyme("device.rerouting.pre-period", "device.routing.pre-period", true);
57 oc.addDescription("device.rerouting.pre-period", "Routing", TL("The rerouting period before depart"));
58
59 oc.doRegister("device.rerouting.adaptation-weight", new Option_Float(0));
60 oc.addSynonyme("device.rerouting.adaptation-weight", "device.routing.adaptation-weight", true);
61 oc.addDescription("device.rerouting.adaptation-weight", "Routing", TL("The weight of prior edge weights for exponential moving average"));
62
63 oc.doRegister("device.rerouting.adaptation-steps", new Option_Integer(180));
64 oc.addSynonyme("device.rerouting.adaptation-steps", "device.routing.adaptation-steps", true);
65 oc.addDescription("device.rerouting.adaptation-steps", "Routing", TL("The number of steps for moving average weight of prior edge weights"));
66
67 oc.doRegister("device.rerouting.adaptation-interval", new Option_String("1", "TIME"));
68 oc.addSynonyme("device.rerouting.adaptation-interval", "device.routing.adaptation-interval", true);
69 oc.addDescription("device.rerouting.adaptation-interval", "Routing", TL("The interval for updating the edge weights"));
70
71 oc.doRegister("device.rerouting.cch-update-threshold.factor", new Option_Float(1));
72 oc.addDescription("device.rerouting.cch-update-threshold.factor", "Routing", TL("Only propagate an arc weight into the CCH metric if it changed by more than the given factor"));
73
74 oc.doRegister("device.rerouting.cch-update-threshold.constant", new Option_String("0", "TIME"));
75 oc.addDescription("device.rerouting.cch-update-threshold.constant", "Routing", TL("Only propagate an arc weight into the CCH metric if it changed by more than the given TIME"));
76 oc.doRegister("device.rerouting.cch-ensemble", new Option_Integer(1));
77 oc.addDescription("device.rerouting.cch-ensemble", "Routing", TL("Keep this many frozen weights.random-factor realizations (CCH metrics) per vehicle type and assign vehicles to them by a stable id hash"));
78
79 oc.doRegister("device.rerouting.threshold.factor", new Option_Float(1));
80 oc.addDescription("device.rerouting.threshold.factor", "Routing", TL("Only reroute if the new route is faster than the current route by the given factor"));
81
82 oc.doRegister("device.rerouting.threshold.constant", new Option_String("0", "TIME"));
83 oc.addDescription("device.rerouting.threshold.constant", "Routing", TL("Only reroute if the new route is faster than the current route by the given TIME"));
84
85 oc.doRegister("device.rerouting.invalidation", new Option_Bool(false));
86 oc.addDescription("device.rerouting.invalidation", "Routing", TL("Only perform a periodic reroute when the current route's remaining cost has drifted beyond the threshold (cheap re-scoring gate before the full reroute)"));
87
88 oc.doRegister("device.rerouting.with-taz", new Option_Bool(false));
89 oc.addSynonyme("device.rerouting.with-taz", "device.routing.with-taz", true);
90 oc.addSynonyme("device.rerouting.with-taz", "with-taz");
91 oc.addDescription("device.rerouting.with-taz", "Routing", TL("Use zones (districts) as routing start- and endpoints"));
92
93 oc.doRegister("device.rerouting.mode", new Option_String("0"));
94 oc.addDescription("device.rerouting.mode", "Routing", TL("Set routing flags (8 ignores temporary blockages)"));
95
96 oc.doRegister("device.rerouting.init-with-loaded-weights", new Option_Bool(false));
97 oc.addDescription("device.rerouting.init-with-loaded-weights", "Routing", TL("Use weight files given with option --weight-files for initializing edge weights"));
98
99 oc.doRegister("device.rerouting.threads", new Option_Integer(0));
100 oc.addSynonyme("device.rerouting.threads", "routing-threads");
101 oc.addDescription("device.rerouting.threads", "Routing", TL("The number of parallel execution threads used for rerouting"));
102
103 oc.doRegister("device.rerouting.synchronize", new Option_Bool(false));
104 oc.addDescription("device.rerouting.synchronize", "Routing", TL("Let rerouting happen at the same time for all vehicles"));
105
106 oc.doRegister("device.rerouting.railsignal", new Option_Bool(false));
107 oc.addDescription("device.rerouting.railsignal", "Routing", TL("Allow rerouting triggered by rail signals."));
108
109 oc.doRegister("device.rerouting.bike-speeds", new Option_Bool(false));
110 oc.addDescription("device.rerouting.bike-speeds", "Routing", TL("Compute separate average speeds for bicycles"));
111
112 oc.doRegister("device.rerouting.output", new Option_FileName());
113 oc.addDescription("device.rerouting.output", "Routing", TL("Save adapting weights to FILE"));
114}
115
116
117bool
119 bool ok = true;
120 if (!oc.isDefault("device.rerouting.adaptation-steps") && !oc.isDefault("device.rerouting.adaptation-weight")) {
121 WRITE_ERROR(TL("Only one of the options 'device.rerouting.adaptation-steps' or 'device.rerouting.adaptation-weight' may be given."));
122 ok = false;
123 }
124 if (oc.getFloat("weights.random-factor") < 1) {
125 WRITE_ERROR(TL("weights.random-factor cannot be less than 1"));
126 ok = false;
127 }
128 if (string2time(oc.getString("device.rerouting.adaptation-interval")) < 0) {
129 WRITE_ERROR(TL("Negative value for device.rerouting.adaptation-interval!"));
130 ok = false;
131 }
132 if (oc.getFloat("device.rerouting.adaptation-weight") < 0. ||
133 oc.getFloat("device.rerouting.adaptation-weight") > 1.) {
134 WRITE_ERROR(TL("The value for device.rerouting.adaptation-weight must be between 0 and 1!"));
135 ok = false;
136 }
137#ifndef HAVE_FOX
138 if (oc.getInt("device.rerouting.threads") > 1) {
139 WRITE_ERROR(TL("Parallel routing is only possible when compiled with Fox."));
140 ok = false;
141 }
142#endif
143 if (oc.getInt("threads") > 1 && oc.getInt("device.rerouting.threads") > 1 && oc.getInt("threads") != oc.getInt("device.rerouting.threads")) {
144 WRITE_WARNING(TL("Adapting number of routing threads to number of simulation threads."));
145 }
146 return ok;
147}
148
149
150void
151MSDevice_Routing::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into) {
153 const bool equip = equippedByDefaultAssignmentOptions(oc, "rerouting", v, false);
154 if (v.getParameter().wasSet(VEHPARS_FORCE_REROUTE) || equip) {
155 // route computation is enabled
156 // for implicitly equipped vehicles (trips, flows), option probability
157 // can still be used to disable periodic rerouting after insertion for
158 // parts of the fleet
159 const SUMOTime period = (equip || (
160 oc.isDefault("device.rerouting.probability") &&
161 v.getFloatParam("device.rerouting.probability") == oc.getFloat("device.rerouting.probability"))
162 ? v.getTimeParam("device.rerouting.period") : 0);
163 const SUMOTime prePeriod = MAX2((SUMOTime)0, v.getTimeParam("device.rerouting.pre-period"));
165 // build the device
166 into.push_back(new MSDevice_Routing(v, "routing_" + v.getID(), period, prePeriod));
167 }
168}
169
170
171// ---------------------------------------------------------------------------
172// MSDevice_Routing-methods
173// ---------------------------------------------------------------------------
174MSDevice_Routing::MSDevice_Routing(SUMOVehicle& holder, const std::string& id,
175 SUMOTime period, SUMOTime preInsertionPeriod) :
176 MSVehicleDevice(holder, id),
177 myPeriod(period),
178 myPreInsertionPeriod(preInsertionPeriod),
179 myLastRouting(-1),
180 mySkipRouting(-1),
181 myRerouteCommand(nullptr),
182 myRerouteRailSignal(holder.getBoolParam("device.rerouting.railsignal", true)),
183 myLastLaneEntryTime(-1),
184 myRerouteAfterStop(false),
185 myThresholdFactor(holder.getFloatParam("device.rerouting.threshold.factor", true, 1)),
186 myThresholdTime(STEPS2TIME(holder.getTimeParam("device.rerouting.threshold.constant", true, 0))),
187 myActive(true),
188 myInvalidation(OptionsCont::getOptions().getBool("device.rerouting.invalidation")),
189 myLastRouteCost(-1.) {
191 // we do always a pre insertion reroute for trips to fill the best lanes of the vehicle with somehow meaningful values (especially for deaprtLane="best")
193 // if we don't update the edge weights, we might as well reroute now and hopefully use our threads better
194 const SUMOTime execTime = MSRoutingEngine::hasEdgeUpdates() ? holder.getParameter().depart : -1;
196 }
197}
198
199
201 // make the rerouting command invalid if there is one
202 if (myRerouteCommand != nullptr) {
204 }
205}
206
207
208bool
212 // pre-insertion rerouting was disabled. Reroute once if insertion was delayed
213 // this is happening in the run thread (not inbeginOfTimestepEvents) so we cannot safely use the threadPool
214 myHolder.reroute(MSNet::getInstance()->getCurrentTimeStep(), "device.rerouting",
216 true, MSRoutingEngine::withTaz(), false);
217 }
218 // build repetition trigger if routing shall be done more often
220 }
221 if (MSGlobals::gWeightsSeparateTurns > 0 && enteredLane != nullptr) {
223 const SUMOTime t = SIMSTEP;
224 if (myLastLaneEntryTime >= 0 && enteredLane->isInternal()) {
225 // record travel time on the previous edge but store on the internal ledge
227 }
229 }
230 return true;
231 } else {
232 return false;
233 }
234}
235
236
237void
244
245
246void
248 if (myRerouteCommand != nullptr) {
250 myRerouteCommand = nullptr;
251 }
252 if (myPeriod > 0) {
254 if (OptionsCont::getOptions().getBool("device.rerouting.synchronize")) {
255 start -= start % myPeriod;
256 }
257 // ensure stable sorting of events (for repeatable routing with randomness)
260 }
261}
262
263
266 if (mySkipRouting == currentTime) {
267 return DELTA_T;
268 }
269 if (myPreInsertionPeriod == 0) {
270 // the event will deschedule and destroy itself so it does not need to be stored
271 myRerouteCommand = nullptr;
272 }
273 const MSEdge* source = *myHolder.getRoute().begin();
274 const MSEdge* dest = myHolder.getRoute().getLastEdge();
275 if (source->isTazConnector() && dest->isTazConnector()) {
276 ConstMSRoutePtr cached = MSRoutingEngine::getCachedRoute(std::make_pair(source, dest));
277 if (cached != nullptr && cached->size() > 2) {
278 myHolder.replaceRoute(cached, "device.rerouting", true);
280 }
281 }
282 try {
283 std::string msg;
284 if (myHolder.hasValidRouteStart(msg)) {
285 reroute(currentTime, true);
286 }
287 } catch (ProcessError&) {
288 myRerouteCommand = nullptr;
289 throw;
290 }
291 // avoid repeated pre-insertion rerouting when the departure edge is fix and
292 // the departure lane does not depend on the route
294 myRerouteCommand = nullptr;
295 return 0;
296 }
298}
299
300
303 if (myHolder.isStopped()) {
304 myRerouteAfterStop = true;
305 } else {
306 reroute(currentTime);
307 }
308 return myPeriod;
309}
310
311
312void
313MSDevice_Routing::reroute(const SUMOTime currentTime, const bool onInit) {
315 //check whether the weights did change since the last reroute
317 return;
318 }
319 // Invalidation gate: even when the metric changed, skip the (expensive)
320 // reroute unless THIS vehicle's remaining route has actually degraded.
321 // recomputeCosts is O(remaining-route length) array reads, far cheaper
322 // than a shortest-path search. Only meaningful once the vehicle is on the
323 // road with a concrete route (getCurrentRouteEdge is only valid then);
324 // pre-insertion / onInit reroutes always run and don't track cost.
325 const bool canGate = myInvalidation && !onInit && myHolder.isOnRoad();
326 if (canGate && myLastRouteCost >= 0.) {
329 if (!remaining.empty()) {
330 const double costNow = router.recomputeCosts(remaining, &myHolder, currentTime);
331 if (costNow - myLastRouteCost <= myThresholdTime && costNow <= myLastRouteCost * myThresholdFactor) {
332 myLastRouting = currentTime; // route still good enough; skip the search
333 myLastRouteCost = costNow;
334 return;
335 }
336 }
337 }
338 myLastRouting = currentTime;
339 MSRoutingEngine::reroute(myHolder, currentTime, "device.rerouting", onInit);
343 myLastRouteCost = remaining.empty() ? -1. : router.recomputeCosts(remaining, &myHolder, currentTime);
344 }
345}
346
347
348bool
349MSDevice_Routing::sufficientSaving(double oldCost, double newCost) {
350 if (newCost == 0) {
351 return true;
352 }
353 return (oldCost / newCost > myThresholdFactor) && (oldCost - newCost > myThresholdTime);
354}
355
356
357std::string
358MSDevice_Routing::getParameter(const std::string& key) const {
359 if (StringUtils::startsWith(key, "edge:")) {
360 const std::string edgeID = key.substr(5);
361 const MSEdge* edge = MSEdge::dictionary(edgeID);
362 if (edge == nullptr) {
363 throw InvalidArgument("Edge '" + edgeID + "' is invalid for parameter retrieval of '" + deviceName() + "'");
364 }
366 } else if (key == "period") {
367 return time2string(myPeriod);
368 }
369 throw InvalidArgument("Parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
370}
371
372
373void
374MSDevice_Routing::setParameter(const std::string& key, const std::string& value) {
375 double doubleValue;
376 try {
377 doubleValue = StringUtils::toDouble(value);
378 } catch (NumberFormatException&) {
379 throw InvalidArgument("Setting parameter '" + key + "' requires a number for device of type '" + deviceName() + "'");
380 }
381 if (StringUtils::startsWith(key, "edge:")) {
382 const std::string edgeID = key.substr(5);
383 const MSEdge* edge = MSEdge::dictionary(edgeID);
384 if (edge == nullptr) {
385 throw InvalidArgument("Edge '" + edgeID + "' is invalid for parameter setting of '" + deviceName() + "'");
386 }
387 MSRoutingEngine::setEdgeTravelTime(edge, doubleValue);
388 } else if (key == "period") {
389 myPeriod = TIME2STEPS(doubleValue);
390 // re-schedule routing command
392 } else {
393 throw InvalidArgument("Setting parameter '" + key + "' is not supported for device of type '" + deviceName() + "'");
394 }
395}
396
397
398void
402 std::vector<std::string> internals;
403 internals.push_back(toString(myPeriod));
404 internals.push_back(toString(myLastRouting));
405 out.writeAttr(SUMO_ATTR_STATE, toString(internals));
406 out.closeTag();
407}
408
409
410void
412 std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
413 bis >> myPeriod;
414 bis >> myLastRouting;
415 if (myHolder.hasDeparted()) {
416 SUMOTime offset = myPeriod;
417 if (myPeriod > 0) {
418 offset = ((SIMSTEP - myHolder.getDeparture()) % myPeriod);
419 if (offset != 0) {
420 offset = myPeriod - offset;
421 }
422 }
424 }
425}
426
427
428/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
#define WRITE_ERROR(msg)
Definition MsgHandler.h:295
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
#define STEPS2TIME(x)
Definition SUMOTime.h:58
#define SIMSTEP
Definition SUMOTime.h:69
constexpr SUMOTime TIME2STEPS(double x)
Definition SUMOTime.h:60
const long long int VEHPARS_FORCE_REROUTE
@ BEST_FREE
The least occupied lane from best lanes.
@ SUMO_TAG_DEVICE
@ SUMO_ATTR_ID
@ SUMO_ATTR_STATE
The state of a link.
T MAX2(T a, T b)
Definition StdDefs.h:86
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
int priority
Definition Command.h:87
A device that performs vehicle rerouting based on current edge speeds.
const std::string deviceName() const
return the name for this type of device
void saveState(OutputDevice &out) const
Saves the state of the device.
void rebuildRerouteCommand(SUMOTime start)
rebuild reroute command according to period
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
bool sufficientSaving(double oldCost, double newCost)
whether the change in saving is enough to trigger rerouting
SUMOTime mySkipRouting
The time for which routing may be skipped because we cannot be inserted.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
double myLastRouteCost
remaining-route cost at the last (re)routing, -1 if unknown
bool myInvalidation
Whether to gate periodic reroutes on a cheap route-drift check.
bool myActive
Whether the equipped vehicle may perform rerouting.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
void reroute(const SUMOTime currentTime, const bool onInit=false)
initiate the rerouting, create router / thread pool on first use
static bool checkOptions(OptionsCont &oc)
checks MSDevice_Routing-options
MSDevice_Routing(SUMOVehicle &holder, const std::string &id, SUMOTime period, SUMOTime preInsertionPeriod)
Constructor.
WrappingCommand< MSDevice_Routing > * myRerouteCommand
The (optional) command responsible for rerouting.
~MSDevice_Routing()
Destructor.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
SUMOTime myLastLaneEntryTime
the previous time that a vehicle entered a lane
SUMOTime myLastRouting
The last time a routing took place.
void notifyStopEnded()
called to do the rerouting we missed whuile stopping
bool myRerouteAfterStop
Whether the equipped vehicle missed a reroute while stopping and should do so after the stop has ende...
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
SUMOTime preInsertionReroute(const SUMOTime currentTime)
Performs rerouting before insertion into the network.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
Definition MSDevice.cpp:157
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
Definition MSDevice.h:200
A road/street connecting two junctions.
Definition MSEdge.h:77
bool isTazConnector() const
Definition MSEdge.h:292
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition MSEdge.cpp:1105
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static double gWeightsSeparateTurns
Whether turning specific weights are estimated (and how much)
Definition MSGlobals.h:180
Representation of a lane in the micro simulation.
Definition MSLane.h:84
bool isInternal() const
Definition MSLane.cpp:2659
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:790
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:201
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition MSNet.h:495
MSEventControl * getInsertionEvents()
Returns the event control for insertion events.
Definition MSNet.h:515
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition MSRoute.cpp:79
const MSEdge * getLastEdge() const
returns the destination edge
Definition MSRoute.cpp:91
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition MSRoute.cpp:73
static void initEdgeWeights(SUMOVehicleClass svc, SUMOTime lastAdaption=-1, int index=-1)
initialize the edge weights if not done before
static void setEdgeTravelTime(const MSEdge *const edge, const double travelTime)
adapt the known travel time for an edge
static SUMOTime getLastAdaptation()
Information when the last edge weight adaptation occurred.
static bool withTaz()
whether taz-routing is enabled
static bool hasEdgeUpdates()
returns whether any edge weight updates will take place
static void addEdgeTravelTime(const MSEdge &edge, const SUMOTime travelTime)
record actual travel time for an edge
static ConstMSRoutePtr getCachedRoute(const std::pair< const MSEdge *, const MSEdge * > &key)
return the cached route or nullptr on miss
static void initWeightUpdate(SUMOTime lastAdaption=- 1)
intialize period edge weight update
static void reroute(SUMOVehicle &vehicle, const SUMOTime currentTime, const std::string &info, const bool onInit=false, const bool silent=false, const Prohibitions &prohibited={})
initiate the rerouting, create router / thread pool on first use
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
static MSVehicleRouter & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const Prohibitions &prohibited={})
return the vehicle router instance
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
const std::string & getID() const
Returns the id.
Definition Named.h:73
A storage for options typed value containers)
Definition OptionsCont.h:89
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
Representation of a vehicle, person, or container.
virtual NumericalID getNumericalID() const =0
return the numerical ID which is only for internal usage
virtual int getRNGIndex() const =0
SUMOTime getTimeParam(const std::string &paramName, const bool required=false, const SUMOTime deflt=SUMOTime_MIN) const
Retrieve a time parameter for the traffic object.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)=0
Replaces the current route by the given one.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
double getFloatParam(const std::string &paramName, const bool required=false, const double deflt=INVALID_DOUBLE, bool checkDist=true) const
Retrieve a floating point parameter for the traffic object.
Representation of a vehicle.
Definition SUMOVehicle.h:63
virtual bool reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false, const MSEdge *sink=nullptr)=0
Performs a rerouting using the given router.
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop and waiting for a person or container to continue.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
virtual bool hasValidRouteStart(std::string &msg)=0
checks whether the vehicle can depart on the first edge
virtual SUMOTime getDepartDelay() const =0
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual const MSRoute & getRoute() const =0
Returns the current route.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
A wrapper for a Command function.
void deschedule()
Marks this Command as being descheduled.