Eclipse SUMO - Simulation of Urban MObility
MSVehicleControl.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-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 /****************************************************************************/
20 // The class responsible for building and deletion of vehicles
21 /****************************************************************************/
22 #include <config.h>
23 
24 #include "MSVehicleControl.h"
25 #include "MSVehicle.h"
26 #include "MSLane.h"
27 #include "MSEdge.h"
28 #include "MSNet.h"
29 #include "MSRouteHandler.h"
30 #include "MSStop.h"
34 #include <utils/common/Named.h>
35 #include <utils/common/RGBColor.h>
40 
41 
42 // ===========================================================================
43 // member method definitions
44 // ===========================================================================
46  myLoadedVehNo(0),
47  myRunningVehNo(0),
48  myEndedVehNo(0),
49  myDiscarded(0),
50  myCollisions(0),
51  myTeleportsCollision(0),
52  myTeleportsJam(0),
53  myTeleportsYield(0),
54  myTeleportsWrongLane(0),
55  myEmergencyStops(0),
56  myEmergencyBrakingCount(0),
57  myStoppedVehicles(0),
58  myTotalDepartureDelay(0),
59  myTotalTravelTime(0),
60  myWaitingForTransportable(0),
61  myMaxSpeedFactor(1),
62  myMinDeceleration(SUMOVTypeParameter::getDefaultDecel(SVC_IGNORING)),
63  myMinDecelerationRail(SUMOVTypeParameter::getDefaultDecel(SVC_RAIL)),
64  myPendingRemovals(MSGlobals::gNumSimThreads > 1) {
65 
68 }
69 
70 
72  clearState(false);
73 }
74 
75 
76 void
80 
84 
88 
92 
96 
98  // ISO Container TEU (cannot set this based on vClass)
99  defContainerType.length = 6.1;
100  defContainerType.width = 2.4;
101  defContainerType.height = 2.6;
102  defContainerType.parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
104 
106 }
107 
108 
111  ConstMSRoutePtr route, MSVehicleType* type,
112  const bool ignoreStopErrors, const bool fromRouteFile, bool addRouteStops) {
113  MSVehicle* built = new MSVehicle(defs, route, type, type->computeChosenSpeedDeviation(fromRouteFile ? MSRouteHandler::getParsingRNG() : nullptr));
114  initVehicle(built, ignoreStopErrors, addRouteStops);
115  return built;
116 }
117 
118 
119 void
120 MSVehicleControl::initVehicle(MSBaseVehicle* built, const bool ignoreStopErrors, bool addRouteStops) {
121  myLoadedVehNo++;
122  try {
123  built->initDevices();
124  built->addStops(ignoreStopErrors, nullptr, addRouteStops);
125  } catch (ProcessError&) {
126  delete built;
127  throw;
128  }
130 }
131 
132 
133 void
135  assert(myRunningVehNo > 0);
136  if (!checkDuplicate || !isPendingRemoval(veh)) {
137  myPendingRemovals.push_back(veh);
138  }
139 }
140 
141 
142 bool
144 #ifdef HAVE_FOX
145  return myPendingRemovals.contains(veh);
146 #else
147  return std::find(myPendingRemovals.begin(), myPendingRemovals.end(), veh) == myPendingRemovals.end();
148 #endif
149 }
150 
151 
152 void
154  OutputDevice* const tripinfoOut = OptionsCont::getOptions().isSet("tripinfo-output") ? &OutputDevice::getDeviceByOption("tripinfo-output") : nullptr;
155 #ifdef HAVE_FOX
156  std::vector<SUMOVehicle*>& vehs = myPendingRemovals.getContainer();
157 #else
158  std::vector<SUMOVehicle*>& vehs = myPendingRemovals;
159 #endif
160  std::sort(vehs.begin(), vehs.end(), ComparatorNumericalIdLess());
161  for (SUMOVehicle* const veh : vehs) {
162  myTotalTravelTime += STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep() - veh->getDeparture());
163  myRunningVehNo--;
165  // vehicle is equipped with tripinfo device (not all vehicles are)
166  const bool hasTripinfo = veh->getDevice(typeid(MSDevice_Tripinfo)) != nullptr;
167  for (MSVehicleDevice* const dev : veh->getDevices()) {
168  dev->generateOutput(hasTripinfo ? tripinfoOut : nullptr);
169  }
170  if (tripinfoOut != nullptr && hasTripinfo) {
171  // close tag after tripinfo (possibly including emissions from another device) have been written
172  tripinfoOut->closeTag();
173  }
174  deleteVehicle(veh);
175  }
176  vehs.clear();
177  if (tripinfoOut != nullptr) {
178  // there seem to be people who think reading an unfinished xml is a good idea ;-)
179  tripinfoOut->flush();
180  }
181 #ifdef HAVE_FOX
182  myPendingRemovals.unlock();
183 #endif
184 }
185 
186 
187 void
189  ++myRunningVehNo;
193  if ((v.getVClass() & (SVC_PEDESTRIAN | SVC_NON_ROAD)) == 0) {
194  // only worry about deceleration of road users
196  } else if ((v.getVClass() & SVC_RAIL_CLASSES) != 0) {
198  }
199 }
200 
201 
202 void
203 MSVehicleControl::setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime) {
204  myRunningVehNo = runningVehNo;
205  myLoadedVehNo = loadedVehNo;
206  myEndedVehNo = endedVehNo;
207  myTotalDepartureDelay = totalDepartureDelay;
208  myTotalTravelTime = totalTravelTime;
209 }
210 
211 
212 void
214  out.openTag(SUMO_TAG_DELAY);
220  // save vehicle types
221  for (const auto& item : myVTypeDict) {
222  if (myReplaceableDefaultVTypes.count(item.first) == 0) {
223  item.second->getParameter().write(out);
224  }
225  }
226  for (const auto& item : myVTypeDistDict) {
228  out.writeAttr(SUMO_ATTR_VTYPES, item.second->getVals());
229  out.writeAttr(SUMO_ATTR_PROBS, item.second->getProbs());
230  out.closeTag();
231  }
232  for (const auto& item : myVehicleDict) {
233  item.second->saveState(out);
234  }
235 }
236 
237 
238 void
239 MSVehicleControl::clearState(const bool reinit) {
240  for (const auto& item : myVehicleDict) {
241  delete item.second;
242  }
243  myVehicleDict.clear();
244  // delete vehicle type distributions
245  for (const auto& item : myVTypeDistDict) {
246  delete item.second;
247  }
248  myVTypeDistDict.clear();
249  // delete vehicle types
250  for (const auto& item : myVTypeDict) {
251  delete item.second;
252  }
253  myVTypeDict.clear();
254  myPendingRemovals.clear(); // could be leftovers from MSVehicleTransfer::checkInsertions (teleport beyond arrival)
255  if (reinit) {
257  }
258  myLoadedVehNo = 0;
259  myRunningVehNo = 0;
260  myEndedVehNo = 0;
261  myDiscarded = 0;
262  myCollisions = 0;
264  myTeleportsJam = 0;
265  myTeleportsYield = 0;
267  myEmergencyStops = 0;
269  myStoppedVehicles = 0;
271  myTotalTravelTime = 0;
272 }
273 
274 
275 bool
276 MSVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
277  VehicleDictType::iterator it = myVehicleDict.find(id);
278  if (it == myVehicleDict.end()) {
279  // id not in myVehicleDict.
280  myVehicleDict[id] = v;
281  handleTriggeredDepart(v, true);
282  const SUMOVehicleParameter& pars = v->getParameter();
283  if (v->getVClass() != SVC_TAXI && pars.line != "" && pars.repetitionNumber < 0) {
284  myPTVehicles.push_back(v);
285  }
286  return true;
287  }
288  return false;
289 }
290 
291 
292 void
294  const SUMOVehicleParameter& pars = v->getParameter();
296  const MSEdge* const firstEdge = v->getRoute().getEdges()[pars.departEdge];
297  if (add) {
298  if (!MSGlobals::gUseMesoSim) {
299  // position will be checked against person position later
300  static_cast<MSVehicle*>(v)->setTentativeLaneAndPosition(nullptr, v->getParameter().departPos);
301  }
302  if (firstEdge->isTazConnector()) {
303  for (MSEdge* out : firstEdge->getSuccessors()) {
304  out->addWaiting(v);
305  }
306  } else {
307  firstEdge->addWaiting(v);
308  }
310  } else {
311  if (firstEdge->isTazConnector()) {
312  for (MSEdge* out : firstEdge->getSuccessors()) {
313  out->removeWaiting(v);
314  }
315  } else {
316  firstEdge->removeWaiting(v);
317  }
319  }
320  }
321 }
322 
323 
325 MSVehicleControl::getVehicle(const std::string& id) const {
326  VehicleDictType::const_iterator it = myVehicleDict.find(id);
327  if (it == myVehicleDict.end()) {
328  return nullptr;
329  }
330  return it->second;
331 }
332 
333 
334 void
336  myEndedVehNo++;
337  if (discard) {
338  myDiscarded++;
339  }
340  if (veh != nullptr) {
341  myVehicleDict.erase(veh->getID());
342  }
343  auto ptVehIt = std::find(myPTVehicles.begin(), myPTVehicles.end(), veh);
344  if (ptVehIt != myPTVehicles.end()) {
345  myPTVehicles.erase(ptVehIt);
346  }
347  delete veh;
348 }
349 
350 
351 bool
352 MSVehicleControl::checkVType(const std::string& id) {
353  if (myReplaceableDefaultVTypes.erase(id) > 0) {
354  delete myVTypeDict[id];
355  myVTypeDict.erase(myVTypeDict.find(id));
356  } else {
357  if (myVTypeDict.find(id) != myVTypeDict.end() || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
358  return false;
359  }
360  }
361  return true;
362 }
363 
364 
365 bool
367  if (checkVType(vehType->getID())) {
368  myVTypeDict[vehType->getID()] = vehType;
369  return true;
370  }
371  return false;
372 }
373 
374 
375 void
377  assert(vehType != nullptr);
378  assert(myVTypeDict.find(vehType->getID()) != myVTypeDict.end());
379  myVTypeDict.erase(vehType->getID());
380  if (myVTypeToDist.find(vehType->getID()) != myVTypeToDist.end()) {
381  myVTypeToDist.erase(vehType->getID());
382  }
383  delete vehType;
384 }
385 
386 
387 bool
388 MSVehicleControl::addVTypeDistribution(const std::string& id, RandomDistributor<MSVehicleType*>* vehTypeDistribution) {
389  if (checkVType(id)) {
390  myVTypeDistDict[id] = vehTypeDistribution;
391  std::vector<MSVehicleType*> vehTypes = vehTypeDistribution->getVals();
392  for (auto vehType : vehTypes) {
393  if (myVTypeToDist.find(vehType->getID()) != myVTypeToDist.end()) {
394  myVTypeToDist[vehType->getID()].insert(id);
395  } else {
396  myVTypeToDist[vehType->getID()] = { id };
397  }
398  }
399  return true;
400  }
401  return false;
402 }
403 
404 
405 bool
406 MSVehicleControl::hasVType(const std::string& id) const {
407  return myVTypeDict.count(id) > 0 || myVTypeDistDict.count(id) > 0;
408 }
409 
410 
411 bool
412 MSVehicleControl::hasVTypeDistribution(const std::string& id) const {
413  return myVTypeDistDict.count(id) > 0;
414 }
415 
416 
418 MSVehicleControl::getVType(const std::string& id, SumoRNG* rng, bool readOnly) {
419  VTypeDictType::iterator it = myVTypeDict.find(id);
420  if (it == myVTypeDict.end()) {
421  VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
422  if (it2 == myVTypeDistDict.end()) {
423  return nullptr;
424  }
425  return it2->second->get(rng);
426  }
427  if (!readOnly && myReplaceableDefaultVTypes.erase(id) > 0) {
428  it->second->check();
429  }
430  return it->second;
431 }
432 
433 
434 void
435 MSVehicleControl::insertVTypeIDs(std::vector<std::string>& into) const {
436  into.reserve(into.size() + myVTypeDict.size() + myVTypeDistDict.size());
437  for (VTypeDictType::const_iterator i = myVTypeDict.begin(); i != myVTypeDict.end(); ++i) {
438  into.push_back((*i).first);
439  }
440  for (VTypeDistDictType::const_iterator i = myVTypeDistDict.begin(); i != myVTypeDistDict.end(); ++i) {
441  into.push_back((*i).first);
442  }
443 }
444 
445 
446 const std::set<std::string>
448  std::map<std::string, std::set<std::string>>::const_iterator it = myVTypeToDist.find(id);
449  if (it == myVTypeToDist.end()) {
450  return std::set<std::string>();
451  }
452  return it->second;
453 }
454 
455 
457 MSVehicleControl::getVTypeDistribution(const std::string& typeDistID) const {
458  const auto it = myVTypeDistDict.find(typeDistID);
459  if (it != myVTypeDistDict.end()) {
460  return it->second;
461  }
462  return nullptr;
463 }
464 
465 
466 const std::vector<MSVehicleType*>
468  std::vector<MSVehicleType*> pedestrianTypes;
469  for (auto const& e : myVTypeDict)
470  if (e.second->getVehicleClass() == SUMOVehicleClass::SVC_PEDESTRIAN) {
471  pedestrianTypes.push_back(e.second);
472  }
473  return pedestrianTypes;
474 }
475 
476 
477 void
479  for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
480  SUMOVehicle* veh = i->second;
481  std::string waitReason;
482  if (veh->isStoppedTriggered()) {
483  const MSStop& stop = veh->getNextStop();
484  if (stop.triggered) {
485  waitReason = "for a person that will never come";
486  } else if (stop.containerTriggered) {
487  waitReason = "for a container that will never come";
488  } else if (stop.joinTriggered) {
489  if (stop.pars.join != "") {
490  waitReason = "to be joined to vehicle '" + stop.pars.join + "'";
491  } else {
492  waitReason = "for a joining vehicle that will never come";
493  }
494  } else {
495  waitReason = "for an unknown trigger";
496  }
497  } else if (!veh->hasDeparted()) {
499  waitReason = "for a train from which to split";
501  waitReason = "at insertion for a person that will never come";
503  waitReason = "at insertion for a container that will never come";
504  } else {
505  waitReason = "for an unknown departure trigger";
506  }
507  } else {
508  waitReason = "for an unknown reason";
509  }
510  WRITE_WARNINGF(TL("Vehicle '%' aborted waiting %."), i->first, waitReason);
511  }
512 }
513 
514 
515 int
517  int result = 0;
518  for (MSVehicleControl::constVehIt it = loadedVehBegin(); it != loadedVehEnd(); ++it) {
519  const SUMOVehicle* veh = it->second;
520  if ((veh->isOnRoad() || veh->isRemoteControlled()) && veh->getSpeed() < SUMO_const_haltingSpeed) {
521  result++;
522  }
523  }
524  return result;
525 }
526 
527 
528 std::pair<double, double>
530  double speedSum = 0;
531  double relSpeedSum = 0;
532  int count = 0;
533  for (MSVehicleControl::constVehIt it = loadedVehBegin(); it != loadedVehEnd(); ++it) {
534  const SUMOVehicle* veh = it->second;
535  if ((veh->isOnRoad() || veh->isRemoteControlled()) && !veh->isStopped()) {
536  count++;
537  speedSum += veh->getSpeed();
538  relSpeedSum += veh->getEdge()->getSpeedLimit() > 0 ? veh->getSpeed() / veh->getEdge()->getSpeedLimit() : 0;
539  }
540  }
541  if (count > 0) {
542  return std::make_pair(speedSum / count, relSpeedSum / count);
543  } else {
544  return std::make_pair(-1, -1);
545  }
546 }
547 
548 
549 int
550 MSVehicleControl::getQuota(double frac, int loaded) const {
551  frac = frac < 0 ? myScale : frac;
552  const int origLoaded = (loaded < 1
553  // the vehicle in question has already been loaded, hence the '-1'
554  ? frac > 1. ? (int)(myLoadedVehNo / frac) : myLoadedVehNo - 1
555  // given transportable number reflects only previously loaded
556  : frac > 1. ? (int)(loaded / frac) : loaded);
557  return getScalingQuota(frac, origLoaded);
558 }
559 
560 
561 int
564 }
565 
566 
567 void
569  for (const SUMOVehicle* const veh : myPTVehicles) {
570  // add single vehicles with line attribute which are not part of a flow
571  ConstMSRoutePtr const route = MSRoute::dictionary(veh->getParameter().routeid);
572  router.getNetwork()->addSchedule(veh->getParameter(), route == nullptr ? nullptr : &route->getStops());
573  }
574 }
575 
576 
577 /****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define TL(string)
Definition: MsgHandler.h:315
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition: Route.h:31
#define STEPS2TIME(x)
Definition: SUMOTime.h:55
#define STEPFLOOR(x)
Definition: SUMOTime.h:58
const long long int VTYPEPARS_VEHICLECLASS_SET
const std::string DEFAULT_TAXITYPE_ID
const std::string DEFAULT_RAILTYPE_ID
const std::string DEFAULT_PEDTYPE_ID
const std::set< std::string > DEFAULT_VTYPES
const std::string DEFAULT_VTYPE_ID
const std::string DEFAULT_CONTAINERTYPE_ID
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_RAIL
vehicle is a not electrified rail
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_NON_ROAD
classes which (normally) do not drive on normal roads
@ SVC_TAXI
vehicle is a taxi
@ SVC_PEDESTRIAN
pedestrian
const std::string DEFAULT_BIKETYPE_ID
@ SPLIT
The departure is triggered by a train split.
@ CONTAINER_TRIGGERED
The departure is container triggered.
@ TRIGGERED
The departure is person triggered.
@ SUMO_TAG_DELAY
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ SUMO_ATTR_NUMBER
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_PROBS
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
@ SUMO_ATTR_TIME
trigger: the time of the step
int getScalingQuota(double frac, int loaded)
Returns the number of instances of the current object that shall be emitted given the number of loade...
Definition: StdDefs.cpp:59
T MIN2(T a, T b)
Definition: StdDefs.h:76
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:58
T MAX2(T a, T b)
Definition: StdDefs.h:82
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=nullptr)
Network * getNetwork() const
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:55
virtual void initDevices()
void addStops(const bool ignoreStopErrors, MSRouteIterator *searchStart=nullptr, bool addRouteStops=true)
Adds stops to the built vehicle.
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:264
A device which collects info on the vehicle trip (mainly on departure and arrival)
A road/street connecting two junctions.
Definition: MSEdge.h:77
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
Definition: MSEdge.cpp:1094
bool isTazConnector() const
Definition: MSEdge.h:288
void addWaiting(SUMOVehicle *vehicle) const
Adds a vehicle to the list of waiting vehicles.
Definition: MSEdge.cpp:1373
void removeWaiting(const SUMOVehicle *vehicle) const
Removes a vehicle from the list of waiting vehicles.
Definition: MSEdge.cpp:1382
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:1194
static bool gUseMesoSim
Definition: MSGlobals.h:103
@ BUILT
The vehicle was built, but has not yet departed.
@ ARRIVED
The vehicle arrived at his destination (is deleted)
@ DEPARTED
The vehicle has departed (was inserted into the network)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:182
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
Definition: MSNet.cpp:1258
static SumoRNG * getParsingRNG()
get parsing RNG
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:109
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:124
Definition: MSStop.h:44
bool triggered
whether an arriving person lets the vehicle continue
Definition: MSStop.h:69
bool containerTriggered
whether an arriving container lets the vehicle continue
Definition: MSStop.h:71
bool joinTriggered
whether coupling another vehicle (train) the vehicle continue
Definition: MSStop.h:73
const SUMOVehicleParameter::Stop pars
The stop parameter.
Definition: MSStop.h:65
void adaptIntermodalRouter(MSTransportableRouter &router) const
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
int myTeleportsCollision
The number of teleports due to collision.
double myScale
The scaling factor (especially for inc-dua)
bool hasVType(const std::string &id) const
Asks for existence of a vehicle type.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
const std::vector< MSVehicleType * > getPedestrianTypes(void) const
Return all pedestrian vehicle types.
bool addVType(MSVehicleType *vehType)
Adds a vehicle type.
void initVehicle(MSBaseVehicle *built, const bool ignoreStopErrors, bool addRouteStops)
void setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime)
Sets the current state variables as loaded from the stream.
void removePending()
Removes a vehicle after it has ended.
std::set< std::string > myReplaceableDefaultVTypes
the default vehicle types which may still be replaced
std::vector< SUMOVehicle * > myPendingRemovals
List of vehicles which are going to be removed.
int myLoadedVehNo
The number of build vehicles.
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
void initDefaultTypes()
create default types
int myTeleportsYield
The number of teleports due to vehicles stuck on a minor road.
int myTeleportsWrongLane
The number of teleports due to vehicles stuck on the wrong lane.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
void clearState(const bool reinit)
Remove all vehicles before quick-loading state.
std::map< std::string, std::set< std::string > > myVTypeToDist
Inverse lookup from vehicle type to distributions it is a member of.
double myMinDeceleration
The minimum deceleration capability for all road vehicles in the network.
bool isPendingRemoval(SUMOVehicle *veh)
whether the given vehicle is scheduled for removal
double myMinDecelerationRail
The minimum deceleration capability for all rail vehicles in the network.
virtual ~MSVehicleControl()
Destructor.
void removeVType(const MSVehicleType *vehType)
int myEmergencyBrakingCount
The number of emergency stops.
int myStoppedVehicles
The number of stopped vehicles.
void registerOneWaiting()
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
void unregisterOneWaiting()
decreases the count of vehicles waiting for a transport to allow recognition of person / container re...
virtual std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
int myCollisions
The number of collisions.
int myEmergencyStops
The number of emergency stops.
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" ...
MSVehicleControl()
Constructor.
double myMaxSpeedFactor
The maximum speed factor for all vehicles in the network.
int myDiscarded
The number of vehicles which were discarded while loading.
int myEndedVehNo
The number of removed vehicles.
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.
bool addVTypeDistribution(const std::string &id, RandomDistributor< MSVehicleType * > *vehTypeDistribution)
Adds a vehicle type distribution.
int myTeleportsJam
The number of teleports due to jam.
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector.
double myTotalDepartureDelay
The aggregated time vehicles had to wait for departure (in seconds)
VTypeDictType myVTypeDict
Dictionary of vehicle types.
const RandomDistributor< MSVehicleType * > * getVTypeDistribution(const std::string &typeDistID) const
return the vehicle type distribution with the given id
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
double myTotalTravelTime
The aggregated time vehicles needed to aacomplish their route (in seconds)
std::vector< SUMOVehicle * > myPTVehicles
List of vehicles which belong to public transport.
int getTeleportCount() const
return the number of teleports (including collisions)
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
void handleTriggeredDepart(SUMOVehicle *v, bool add)
register / unregister depart-triggered vehicles with edges
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
void saveState(OutputDevice &out)
Saves the current state into the given stream.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
const std::set< std::string > getVTypeDistributionMembership(const std::string &id) const
Return the distribution IDs the vehicle type is a member of.
int myRunningVehNo
The number of vehicles within the network (build and inserted but not removed)
VehicleDictType myVehicleDict
Dictionary of vehicles.
Abstract in-vehicle device.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
The car-following model and parameter.
Definition: MSVehicleType.h:63
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:91
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
double computeChosenSpeedDeviation(SumoRNG *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
const std::vector< T > & getVals() const
Returns the members of the distribution.
virtual double getChosenSpeedFactor() const =0
virtual double getSpeed() const =0
Returns the object's current speed.
virtual bool isStopped() const =0
Returns whether the object is at a stop.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
Structure representing possible vehicle parameter.
double width
This class' width.
double height
This class' height.
double length
The physical vehicle length.
long long int parametersSet
Information for the router which parameter were set.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
virtual const MSRoute & getRoute() const =0
Returns the current route.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual MSStop & getNextStop()=0
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual bool isStoppedTriggered() const =0
Returns whether the vehicle is at a stop and waiting for a person or container to continue.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
Structure representing possible vehicle parameter.
double departPos
(optional) The position the vehicle shall depart from
int departEdge
(optional) The initial edge within the route of the vehicle
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string line
The vehicle's line (mainly for public transport)
Function-object for stable sorting of objects with numerical ids.
Definition: Named.h:39