Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSInsertionControl.cpp
Go to the documentation of this file.
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/****************************************************************************/
23// Inserts vehicles into the network when their departure time is reached
24/****************************************************************************/
25#include <config.h>
26
27#include <iostream>
28#include <algorithm>
29#include <cassert>
30#include <iterator>
35#include "MSGlobals.h"
36#include "MSVehicle.h"
37#include "MSVehicleControl.h"
38#include "MSLane.h"
39#include "MSEdge.h"
40#include "MSNet.h"
41#include "MSRouteHandler.h"
42#include "MSInsertionControl.h"
43
44
45// ===========================================================================
46// member method definitions
47// ===========================================================================
49 SUMOTime maxDepartDelay,
50 bool eagerInsertionCheck,
51 int maxVehicleNumber,
52 SUMOTime randomDepartOffset) :
53 myVehicleControl(vc),
54 myMaxDepartDelay(maxDepartDelay),
55 myEagerInsertionCheck(eagerInsertionCheck),
56 myMaxVehicleNumber(maxVehicleNumber),
57 myPendingEmitsUpdateTime(SUMOTime_MIN),
58 myFlowRNG("flow") {
59 myMaxRandomDepartOffset = randomDepartOffset;
61}
62
63
65 for (const Flow& f : myFlows) {
66 delete (f.pars);
67 }
68}
69
70
71void
75
76
77bool
79 if (myFlowIDs.count(pars->id) > 0) {
80 return false;
81 }
82 const bool loadingFromState = index >= 0;
83 Flow flow{pars, loadingFromState ? index : 0, initScale(pars->vtypeid)};
84 if (!loadingFromState && pars->repetitionProbability < 0 && pars->repetitionOffset < 0) {
85 // init poisson flow (but only the timing)
86 flow.pars->incrementFlow(flow.scale, &myFlowRNG);
87 flow.pars->repetitionsDone--;
88 }
89 myFlows.emplace_back(flow);
90 myFlowIDs.insert(std::make_pair(pars->id, flow.index));
91 return true;
92}
93
94
95double
96MSInsertionControl::initScale(const std::string vtypeid) {
98 if (vc.hasVTypeDistribution(vtypeid)) {
99 double result = -1;
101 for (const MSVehicleType* t : dist->getVals()) {
102 if (result == -1) {
103 result = t->getParameter().scale;
104 } else if (result != t->getParameter().scale) {
105 // unequal scales in distribution
106 return -1;
107 }
108 }
109 return result;
110 } else {
111 // rng is not used since vtypeid is not a distribution
112 return vc.getVType(vtypeid, nullptr, true)->getParameter().scale;
113 }
114}
115
116
117void
118MSInsertionControl::updateScale(const std::string vtypeid) {
119 for (Flow& f : myFlows) {
120 if (f.pars->vtypeid == vtypeid) {
121 f.scale = initScale(vtypeid);
122 }
123 }
124}
125
126
127int
129 // check whether any vehicles shall be emitted within this time step
130 const bool havePreChecked = MSRoutingEngine::isEnabled();
131 if (myPendingEmits.empty() || (havePreChecked && myEmitCandidates.empty())) {
132 return 0;
133 }
134 int numEmitted = 0;
135 // we use buffering for the refused emits to save time
136 // for this, we have two lists; one contains previously refused emits, the second
137 // will be used to append those vehicles that will not be able to depart in this
138 // time step
140
141 // go through the list of previously refused vehicles, first
143 MSVehicleContainer::VehicleVector::const_iterator veh;
144 for (veh = myPendingEmits.begin(); veh != myPendingEmits.end(); veh++) {
145 if (havePreChecked && (myEmitCandidates.count(*veh) == 0)) {
146 refusedEmits.push_back(*veh);
147 } else {
148 numEmitted += tryInsert(time, *veh, refusedEmits);
149 }
150 }
151 myEmitCandidates.clear();
152 myPendingEmits = refusedEmits;
154 return numEmitted;
155}
156
157
158int
160 MSVehicleContainer::VehicleVector& refusedEmits) {
161 assert(veh->getParameter().depart <= time);
162 const MSEdge& edge = *veh->getEdge();
163 if (veh->isOnRoad()) {
164 return 1;
165 }
166 if ((myMaxVehicleNumber < 0 || (int)MSNet::getInstance()->getVehicleControl().getRunningVehicleNo() < myMaxVehicleNumber)
168 // Successful insertion
169 return 1;
170 }
171 if (myMaxDepartDelay >= 0 && time - veh->getParameter().depart > myMaxDepartDelay) {
172 // remove vehicles waiting too long for departure
174 } else if (edge.isVaporizing()) {
175 // remove vehicles if the edge shall be empty
177 } else if (myAbortedEmits.count(veh) > 0) {
178 // remove vehicles which shall not be inserted for some reason
179 myAbortedEmits.erase(veh);
181 } else if ((veh->getRouteValidity(false) & (
185 } else {
186 // let the vehicle wait one step, we'll retry then
187 refusedEmits.push_back(veh);
188 }
190 return 0;
191}
192
193
194void
196 if (myMaxDepartDelay >= 0) {
197 for (auto it = myPendingEmits.begin(); it != myPendingEmits.end();) {
198 SUMOVehicle* veh = *it;
199 if (time - veh->getParameter().depart > myMaxDepartDelay) {
200 // remove vehicles waiting too long for departure
202 it = myPendingEmits.erase(it);
203 } else {
204 it++;
205 }
206 }
207 }
208 while (myAllVeh.anyWaitingBefore(time)) {
210 copy(top.begin(), top.end(), back_inserter(myPendingEmits));
211 myAllVeh.pop();
212 }
213 if (preCheck) {
214 MSVehicleContainer::VehicleVector::const_iterator veh;
215 for (veh = myPendingEmits.begin(); veh != myPendingEmits.end(); veh++) {
216 SUMOVehicle* const v = *veh;
217 const MSEdge* const edge = v->getEdge();
218 if (edge->insertVehicle(*v, time, true, myEagerInsertionCheck)) {
219 myEmitCandidates.insert(v);
220 } else {
221 MSDevice_Routing* dev = static_cast<MSDevice_Routing*>(v->getDevice(typeid(MSDevice_Routing)));
222 if (dev != nullptr) {
223 dev->skipRouting(time);
224 }
225 }
226 }
227 }
228}
229
230
231void
234 // for equidistant vehicles, up-scaling is done via repetitionOffset
235 for (std::vector<Flow>::iterator i = myFlows.begin(); i != myFlows.end();) {
236 MSVehicleType* vtype = nullptr;
237 SUMOVehicleParameter* const pars = i->pars;
238 double typeScale = i->scale;
239 if (typeScale < 0) {
240 // must sample from distribution to determine scale value
241 vtype = vehControl.getVType(pars->vtypeid, MSRouteHandler::getParsingRNG());
242 typeScale = vtype->getParameter().scale;
243 }
244 const double scale = vehControl.getScale() * typeScale;
245 const long long int scaledRepetitions = pars->repetitionNumber == std::numeric_limits<long long int>::max() ? std::numeric_limits<long long int>::max() :
246 (long long int)((double)pars->repetitionNumber * scale + 0.5);
247 bool tryEmitByProb = pars->repetitionProbability > 0;
248 while (scale > 0 && ((pars->repetitionProbability < 0
249 && pars->repetitionsDone < scaledRepetitions
250 && pars->depart + pars->repetitionTotalOffset <= time)
251 || (tryEmitByProb
252 && pars->depart <= time
253 && pars->repetitionEnd > time
254 // only call rand if all other conditions are met
256 )) {
257 tryEmitByProb = false; // only emit one per step
258 SUMOVehicleParameter* const newPars = new SUMOVehicleParameter(*pars);
259 newPars->id = pars->id + "." + toString(i->index);
260 newPars->depart = pars->repetitionProbability > 0 ? time : pars->depart + pars->repetitionTotalOffset + computeRandomDepartOffset();
261 pars->incrementFlow(scale, &myFlowRNG);
262 myFlowIDs[pars->id] = i->index;
263 //std::cout << SIMTIME << " flow=" << pars->id << " done=" << pars->repetitionsDone << " totalOffset=" << STEPS2TIME(pars->repetitionTotalOffset) << "\n";
264 // try to build the vehicle
265 if (vehControl.getVehicle(newPars->id) == nullptr) {
266 ConstMSRoutePtr const route = MSRoute::dictionary(pars->routeid);
267 if (vtype == nullptr) {
268 vtype = vehControl.getVType(pars->vtypeid, MSRouteHandler::getParsingRNG());
269 }
270 SUMOVehicle* const vehicle = vehControl.buildVehicle(newPars, route, vtype, !MSGlobals::gCheckRoutes);
271 // for equidistant vehicles, all scaling is done via repetitionOffset (to avoid artefacts, #11441)
272 // for probabilistic vehicles, we use the quota
273 int quota = pars->repetitionProbability < 0 ? 1 : vehControl.getQuota(scale);
274 if (quota > 0) {
275 vehControl.addVehicle(newPars->id, vehicle);
277 add(vehicle);
278 }
279 i->index++;
280 while (--quota > 0) {
281 SUMOVehicleParameter* const quotaPars = new SUMOVehicleParameter(*pars);
282 quotaPars->id = pars->id + "." + toString(i->index);
283 quotaPars->depart = pars->repetitionProbability > 0 ? time :
285 SUMOVehicle* const quotaVehicle = vehControl.buildVehicle(quotaPars, route, vtype, !MSGlobals::gCheckRoutes);
286 vehControl.addVehicle(quotaPars->id, quotaVehicle);
288 add(quotaVehicle);
289 }
290 pars->repetitionsDone++;
291 i->index++;
292 }
293 } else {
294 vehControl.deleteVehicle(vehicle, true);
295 }
296 } else {
299 break;
300 }
301 throw ProcessError(TLF("Another vehicle with the id '%' exists.", newPars->id));
302 }
303 vtype = nullptr;
304 }
305 if (time >= pars->repetitionEnd || pars->repetitionsDone >= scaledRepetitions) {
306 i = myFlows.erase(i);
308 delete pars;
309 } else {
310 ++i;
311 }
312 }
314}
315
316
317int
319 return (int)myPendingEmits.size();
320}
321
322
323int
325 return (int)myFlows.size();
326}
327
328
329void
333
334void
338
339
340void
342 myPendingEmits.erase(std::remove(myPendingEmits.begin(), myPendingEmits.end(), veh), myPendingEmits.end());
343 myAllVeh.remove(veh);
344}
345
346
347void
349 //clear out the refused vehicle list, deleting the vehicles entirely
350 MSVehicleContainer::VehicleVector::iterator veh;
351 for (veh = myPendingEmits.begin(); veh != myPendingEmits.end();) {
352 if ((*veh)->getRoute().getID() == route || route == "") {
354 veh = myPendingEmits.erase(veh);
355 } else {
356 ++veh;
357 }
358 }
359}
360
361
362int
364 const MSNet* net = MSNet::getInstance();
366 net->lockPendingEmits();
367 // updated pending emits (only once per time step)
368 myPendingEmitsForLane.clear();
369 for (const SUMOVehicle* const veh : myPendingEmits) {
370 const MSLane* const vlane = veh->getLane();
371 if (vlane != nullptr) {
372 myPendingEmitsForLane[vlane]++;
373 } else {
374 // no (tentative) departLane was set, increase count for all
375 // lanes of the depart edge
376 for (const MSLane* const l : veh->getEdge()->getLanes()) {
378 }
379 }
380 }
382 net->unlockPendingEmits();
383 }
384 return myPendingEmitsForLane[lane];
385}
386
387
388void
390 // fill the public transport router with pre-parsed public transport lines
391 for (const Flow& f : myFlows) {
392 if (f.pars->line != "") {
393 ConstMSRoutePtr const route = MSRoute::dictionary(f.pars->routeid);
394 router.getNetwork()->addSchedule(*f.pars, route == nullptr ? nullptr : &route->getStops());
395 }
396 }
397}
398
399
400void
402 // save flow states
403 for (const Flow& flow : myFlows) {
404 flow.pars->write(out, OptionsCont::getOptions(), SUMO_TAG_FLOWSTATE,
405 flow.pars->vtypeid == DEFAULT_VTYPE_ID ? "" : flow.pars->vtypeid);
406 if (flow.pars->repetitionProbability <= 0) {
407 out.writeAttr(SUMO_ATTR_NEXT, STEPS2TIME(flow.pars->repetitionTotalOffset));
408 }
409 out.writeAttr(SUMO_ATTR_ROUTE, flow.pars->routeid);
410 out.writeAttr(SUMO_ATTR_DONE, flow.pars->repetitionsDone);
411 out.writeAttr(SUMO_ATTR_INDEX, flow.index);
412 if (flow.pars->wasSet(VEHPARS_FORCE_REROUTE)) {
413 out.writeAttr(SUMO_ATTR_REROUTE, true);
414 }
415 for (const SUMOVehicleParameter::Stop& stop : flow.pars->stops) {
416 stop.write(out);
417 }
418 out.closeTag();
419 }
420}
421
422
423void
425 for (const Flow& f : myFlows) {
426 delete (f.pars);
427 }
428 myFlows.clear();
429 myFlowIDs.clear();
431 myPendingEmits.clear();
432 myEmitCandidates.clear();
433 myAbortedEmits.clear();
434 // myPendingEmitsForLane must not be cleared since it updates itself on the next call
435}
436
437
440 if (myMaxRandomDepartOffset > 0) {
441 // round to the closest usable simulation step
443 }
444 return 0;
445}
446
448MSInsertionControl::getFlowPars(const std::string& id) const {
449 if (hasFlow(id)) {
450 for (const Flow& f : myFlows) {
451 if (f.pars->id == id) {
452 return f.pars;
453 }
454 }
455 }
456 return nullptr;
457}
458
460MSInsertionControl::getLastFlowVehicle(const std::string& id) const {
461 const auto it = myFlowIDs.find(id);
462 if (it != myFlowIDs.end()) {
463 const std::string vehID = id + "." + toString(it->second);
465 }
466 return nullptr;
467}
468
469
470bool
472 SumoRNG tmp("tmp");
473 for (const Flow& flow : myFlows) {
474 if (flow.scale != 0 &&
475 (StringUtils::toBool(flow.pars->getParameter("has.taxi.device", "false"))
476 || hasTaxiDeviceType(flow.pars->vtypeid, tmp))) {
477 return true;
478 }
479 }
480 return false;
481}
482
483
484bool
485MSInsertionControl::hasTaxiDeviceType(const std::string& vtypeId, SumoRNG& rng) {
487 const MSVehicleType* vtype = vehControl.getVType(vtypeId, &rng);
488 return StringUtils::toBool(vtype->getParameter().getParameter("has.taxi.device", "false"));
489}
490
491/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define TLF(string,...)
Definition MsgHandler.h:318
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
SUMOTime DELTA_T
Definition SUMOTime.cpp:39
#define STEPS2TIME(x)
Definition SUMOTime.h:58
#define SUMOTime_MIN
Definition SUMOTime.h:35
#define TS
Definition SUMOTime.h:45
const std::string DEFAULT_VTYPE_ID
const long long int VEHPARS_FORCE_REROUTE
@ BEGIN
The departure is at simulation start.
@ GIVEN
The time is given.
@ SPLIT
The departure is triggered by a train split.
@ SUMO_TAG_FLOWSTATE
a flow state definition (used when saving and loading simulatino state)
@ SUMO_ATTR_DONE
@ SUMO_ATTR_NEXT
succesor phase index
@ SUMO_ATTR_REROUTE
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_ROUTE
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
void addSchedule(const SUMOVehicleParameter &pars, const StopParVector *addStops=nullptr)
Network * getNetwork() const
@ ROUTE_START_INVALID_PERMISSIONS
A device that performs vehicle rerouting based on current edge speeds.
void skipRouting(const SUMOTime currentTime)
Labels the current time step as "unroutable".
A road/street connecting two junctions.
Definition MSEdge.h:78
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
Definition MSEdge.h:444
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false, const bool forceCheck=false) const
Tries to insert the given vehicle into the network.
Definition MSEdge.cpp:839
void setLastFailedInsertionTime(SUMOTime time) const
Sets the last time a vehicle could not be inserted.
Definition MSEdge.h:613
static bool gCheckRoutes
Definition MSGlobals.h:91
static bool gStateLoaded
Information whether a state has been loaded.
Definition MSGlobals.h:103
std::vector< Flow > myFlows
Container for periodical vehicle parameters.
void adaptIntermodalRouter(MSTransportableRouter &router) const
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
void clearPendingVehicles(const std::string &route)
clears out all pending vehicles from a route, "" for all routes
std::map< const MSLane *, int > myPendingEmitsForLane
the number of pending emits for each edge in the current time step
int tryInsert(SUMOTime time, SUMOVehicle *veh, MSVehicleContainer::VehicleVector &refusedEmits)
Tries to emit the vehicle.
bool myEagerInsertionCheck
Whether an edge on which a vehicle could not depart should be ignored in the same step.
SUMOVehicle * getLastFlowVehicle(const std::string &id) const
return the last vehicle for the given flow
int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
int getPendingEmits(const MSLane *lane)
return the number of pending emits for the given lane
bool addFlow(SUMOVehicleParameter *const pars, int index=-1)
Adds parameter for a vehicle flow for departure.
static bool hasTaxiDeviceType(const std::string &vtypeId, SumoRNG &rng)
bool hasFlow(const std::string &id) const
checks whether the given flow still exists
const SUMOVehicleParameter * getFlowPars(const std::string &id) const
return parameters for the given flow
SUMOTime myPendingEmitsUpdateTime
Last time at which pending emits for each edge where counted.
void retractDescheduleDeparture(const SUMOVehicle *veh)
reverts a previous call to descheduleDeparture (only needed for departPos="random_free")
std::set< SUMOVehicle * > myEmitCandidates
Buffer for vehicles that may be inserted in the current step.
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
SUMOTime myMaxRandomDepartOffset
The maximum random offset to be added to vehicles departure times (non-negative)
MSVehicleContainer::VehicleVector myPendingEmits
Buffers for vehicles that could not be inserted.
MSInsertionControl(MSVehicleControl &vc, SUMOTime maxDepartDelay, bool checkEdgesOnce, int maxVehicleNumber, SUMOTime randomDepartOffset)
Constructor.
MSVehicleControl & myVehicleControl
The assigned vehicle control (needed for vehicle re-insertion and deletion)
std::map< std::string, int > myFlowIDs
Cache for periodical vehicle ids and their most recent index for quicker checking.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
void determineCandidates(SUMOTime time)
Checks for all vehicles whether they can be emitted.
void updateScale(const std::string vtypeid)
updates the flow scale value to keep track of TraCI-induced change
void checkCandidates(SUMOTime time, const bool preCheck)
Adds all vehicles that should have been emitted earlier to the refuse container.
int getPendingFlowCount() const
Returns the number of flows that are still active.
std::set< const SUMOVehicle * > myAbortedEmits
Set of vehicles which shall not be inserted anymore.
void clearState()
Remove all vehicles before quick-loading state.
int myMaxVehicleNumber
Storage for maximum vehicle number.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
SUMOTime myMaxDepartDelay
The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion)
void descheduleDeparture(const SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
MSVehicleContainer myAllVeh
All loaded vehicles sorted by their departure time.
~MSInsertionControl()
Destructor.
SUMOTime computeRandomDepartOffset() const
compute (optional) random offset to the departure time
SumoRNG myFlowRNG
A random number generator for probabilistic flows.
static double initScale(const std::string vtypeid)
init scale value of flow
Representation of a lane in the micro simulation.
Definition MSLane.h:84
The simulated network and simulation perfomer.
Definition MSNet.h:90
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:201
virtual void unlockPendingEmits() const
release exclusive access to pending emits
Definition MSNet.h:861
virtual void lockPendingEmits() const
grant exclusive access to pending emits
Definition MSNet.h:858
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:335
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:403
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
Definition MSRoute.cpp:116
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
Definition MSRoute.cpp:194
static bool isEnabled()
returns whether any routing actions take place
bool anyWaitingBefore(SUMOTime time) const
Returns the information whether any vehicles want to depart before the given time.
void remove(SUMOVehicle *veh)
Removes a single vehicle.
void add(SUMOVehicle *veh)
Adds a single vehicle.
void pop()
Removes the uppermost vehicle vector.
std::vector< SUMOVehicle * > VehicleVector
definition of a list of vehicles which have the same departure time
void clearState()
Remove all vehicles before quick-loading state.
const VehicleVector & top()
Returns the uppermost vehicle vector.
The class responsible for building and deletion of vehicles.
double getScale() const
sets the demand scaling factor
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
int getQuota(double frac=-1, int loaded=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const VehicleDefinitionSource source=ROUTEFILE, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
const RandomDistributor< MSVehicleType * > * getVTypeDistribution(const std::string &typeDistID) const
return the vehicle type distribution with the given id
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false)
Deletes the vehicle.
The car-following model and parameter.
const SUMOVTypeParameter & getParameter() const
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
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 const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Represents a generic random distribution.
const std::vector< T > & getVals() const
Returns the members of the distribution.
static SumoRNG * getParsingRNG()
get parsing RNG
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or nullptr if not.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSEdge * getEdge() const =0
Returns the (normal) route edge the object is currently at.
double scale
individual scaling factor (-1 for undefined)
Representation of a vehicle.
Definition SUMOVehicle.h:63
virtual int getRouteValidity(bool update=true, bool silent=false, std::string *msgReturn=nullptr)=0
computes validity attributes for the current route
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.
double repetitionProbability
The probability for emitting a vehicle per second.
void incrementFlow(double scale, SumoRNG *rng=nullptr)
increment flow
std::string vtypeid
The vehicle's type id.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
long long int repetitionsDone
The number of times the vehicle was already inserted.
SUMOTime repetitionTotalOffset
The offset between depart and the time for the next vehicle insertions.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
static void initRandGlobal(SumoRNG *which=nullptr)
Reads the given random number options and initialises the random number generator in accordance.
Definition of vehicle flow with the current index for vehicle numbering.