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.org/sumo
3 // Copyright (C) 2001-2020 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"
33 #include <utils/common/Named.h>
34 #include <utils/common/RGBColor.h>
39 #ifdef HAVE_FOX
41 #endif
42 
43 
44 // ===========================================================================
45 // member method definitions
46 // ===========================================================================
48  myLoadedVehNo(0),
49  myRunningVehNo(0),
50  myEndedVehNo(0),
51  myDiscarded(0),
52  myCollisions(0),
53  myTeleportsJam(0),
54  myTeleportsYield(0),
55  myTeleportsWrongLane(0),
56  myEmergencyStops(0),
57  myStoppedVehicles(0),
58  myTotalDepartureDelay(0),
59  myTotalTravelTime(0),
60  myDefaultVTypeMayBeDeleted(true),
61  myDefaultPedTypeMayBeDeleted(true),
62  myDefaultContainerTypeMayBeDeleted(true),
63  myDefaultBikeTypeMayBeDeleted(true),
64  myDefaultTaxiTypeMayBeDeleted(true),
65  myWaitingForPerson(0),
66  myWaitingForContainer(0),
67  myMaxSpeedFactor(1),
68  myMinDeceleration(SUMOVTypeParameter::getDefaultDecel(SVC_IGNORING)),
69  myPendingRemovals(MSGlobals::gNumSimThreads > 1) {
72 
76 
80 
84 
86  // ISO Container TEU (cannot set this based on vClass)
87  defContainerType.length = 6.1;
88  defContainerType.width = 2.4;
89  defContainerType.height = 2.6;
90  defContainerType.parametersSet |= VTYPEPARS_VEHICLECLASS_SET;
92 
94 }
95 
96 
98  clearState();
99 }
100 
101 
104  const MSRoute* route, MSVehicleType* type,
105  const bool ignoreStopErrors, const bool fromRouteFile) {
106  MSVehicle* built = new MSVehicle(defs, route, type, type->computeChosenSpeedDeviation(fromRouteFile ? MSRouteHandler::getParsingRNG() : nullptr));
107  initVehicle(built, ignoreStopErrors);
108  return built;
109 }
110 
111 
112 void
113 MSVehicleControl::initVehicle(MSBaseVehicle* built, const bool ignoreStopErrors) {
114  myLoadedVehNo++;
115  try {
116  built->initDevices();
117  built->addStops(ignoreStopErrors);
118  } catch (ProcessError&) {
119  delete built;
120  throw;
121  }
123 }
124 
125 
126 void
128  assert(myRunningVehNo > 0);
129  if (!checkDuplicate || !isPendingRemoval(veh)) {
130  myPendingRemovals.push_back(veh);
131  }
132 }
133 
134 
135 bool
137 #ifdef HAVE_FOX
138  return myPendingRemovals.contains(veh);
139 #else
140  return std::find(myPendingRemovals.begin(), myPendingRemovals.end(), veh) == myPendingRemovals.end();
141 #endif
142 }
143 
144 void
146  OutputDevice* const tripinfoOut = OptionsCont::getOptions().isSet("tripinfo-output") ? &OutputDevice::getDeviceByOption("tripinfo-output") : nullptr;
147 #ifdef HAVE_FOX
148  std::vector<SUMOVehicle*>& vehs = myPendingRemovals.getContainer();
149 #else
150  std::vector<SUMOVehicle*>& vehs = myPendingRemovals;
151 #endif
152  std::sort(vehs.begin(), vehs.end(), ComparatorNumericalIdLess());
153  for (SUMOVehicle* const veh : vehs) {
154  myTotalTravelTime += STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep() - veh->getDeparture());
155  myRunningVehNo--;
157  // vehicle is equipped with tripinfo device (not all vehicles are)
158  const bool hasTripinfo = veh->getDevice(typeid(MSDevice_Tripinfo)) != nullptr;
159  for (MSVehicleDevice* const dev : veh->getDevices()) {
160  dev->generateOutput(hasTripinfo ? tripinfoOut : nullptr);
161  }
162  if (tripinfoOut != nullptr && hasTripinfo) {
163  // close tag after tripinfo (possibly including emissions from another device) have been written
164  tripinfoOut->closeTag();
165  }
166  deleteVehicle(veh);
167  }
168  vehs.clear();
169  if (tripinfoOut != nullptr) {
170  // there seem to be people who think reading an unfinished xml is a good idea ;-)
171  tripinfoOut->flush();
172  }
173 #ifdef HAVE_FOX
174  myPendingRemovals.unlock();
175 #endif
176 }
177 
178 
179 void
181  ++myRunningVehNo;
185  if ((v.getVClass() & (SVC_PEDESTRIAN | SVC_NON_ROAD)) == 0) {
186  // only worry about deceleration of road users
188  }
189 }
190 
191 
192 void
193 MSVehicleControl::setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime) {
194  myRunningVehNo = runningVehNo;
195  myLoadedVehNo = loadedVehNo;
196  myEndedVehNo = endedVehNo;
197  myTotalDepartureDelay = totalDepartureDelay;
198  myTotalTravelTime = totalTravelTime;
199 }
200 
201 
202 void
204  out.openTag(SUMO_TAG_DELAY);
210  // save vehicle types
211  VTypeDictType vTypes = myVTypeDict;
213  vTypes.erase(DEFAULT_VTYPE_ID);
214  }
216  vTypes.erase(DEFAULT_PEDTYPE_ID);
217  }
219  vTypes.erase(DEFAULT_CONTAINERTYPE_ID);
220  }
222  vTypes.erase(DEFAULT_BIKETYPE_ID);
223  }
225  vTypes.erase(DEFAULT_TAXITYPE_ID);
226  }
227  for (const auto& item : vTypes) {
228  item.second->getParameter().write(out);
229  }
230  for (VTypeDistDictType::iterator it = myVTypeDistDict.begin(); it != myVTypeDistDict.end(); ++it) {
232  out.writeAttr(SUMO_ATTR_VTYPES, (*it).second->getVals());
233  out.writeAttr(SUMO_ATTR_PROBS, (*it).second->getProbs());
234  out.closeTag();
235  }
236  for (VehicleDictType::iterator it = myVehicleDict.begin(); it != myVehicleDict.end(); ++it) {
237  (*it).second->saveState(out);
238  }
239 }
240 
241 
242 void
244  for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
245  delete (*i).second;
246  }
247  myVehicleDict.clear();
248  // delete vehicle type distributions
249  for (VTypeDistDictType::iterator i = myVTypeDistDict.begin(); i != myVTypeDistDict.end(); ++i) {
250  delete (*i).second;
251  }
252  myVTypeDistDict.clear();
253  // delete vehicle types
254  for (VTypeDictType::iterator i = myVTypeDict.begin(); i != myVTypeDict.end(); ++i) {
255  delete (*i).second;
256  }
257  myVTypeDict.clear();
263 }
264 
265 
266 bool
267 MSVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
268  VehicleDictType::iterator it = myVehicleDict.find(id);
269  if (it == myVehicleDict.end()) {
270  // id not in myVehicleDict.
271  myVehicleDict[id] = v;
272  const SUMOVehicleParameter& pars = v->getParameter();
274  const MSEdge* const firstEdge = v->getRoute().getEdges()[0];
275  if (!MSGlobals::gUseMesoSim) {
276  // position will be checked against person position later
277  static_cast<MSVehicle*>(v)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], v->getParameter().departPos);
278  }
279  firstEdge->addWaiting(v);
281  }
282  if (v->getVClass() != SVC_TAXI && pars.line != "" && pars.repetitionNumber < 0) {
283  myPTVehicles.push_back(v);
284  }
285  return true;
286  }
287  return false;
288 }
289 
290 
292 MSVehicleControl::getVehicle(const std::string& id) const {
293  VehicleDictType::const_iterator it = myVehicleDict.find(id);
294  if (it == myVehicleDict.end()) {
295  return nullptr;
296  }
297  return it->second;
298 }
299 
300 
301 void
303  myEndedVehNo++;
304  if (discard) {
305  myDiscarded++;
306  }
307  if (veh != nullptr) {
308  myVehicleDict.erase(veh->getID());
309  }
310  auto ptVehIt = std::find(myPTVehicles.begin(), myPTVehicles.end(), veh);
311  if (ptVehIt != myPTVehicles.end()) {
312  myPTVehicles.erase(ptVehIt);
313  }
314  delete veh;
315 }
316 
317 
318 bool
319 MSVehicleControl::checkVType(const std::string& id) {
320  if (id == DEFAULT_VTYPE_ID) {
322  delete myVTypeDict[id];
323  myVTypeDict.erase(myVTypeDict.find(id));
325  } else {
326  return false;
327  }
328  } else if (id == DEFAULT_PEDTYPE_ID) {
330  delete myVTypeDict[id];
331  myVTypeDict.erase(myVTypeDict.find(id));
333  } else {
334  return false;
335  }
336  } else if (id == DEFAULT_CONTAINERTYPE_ID) {
338  delete myVTypeDict[id];
339  myVTypeDict.erase(myVTypeDict.find(id));
341  } else {
342  return false;
343  }
344  } else if (id == DEFAULT_BIKETYPE_ID) {
346  delete myVTypeDict[id];
347  myVTypeDict.erase(myVTypeDict.find(id));
349  } else {
350  return false;
351  }
352  } else if (id == DEFAULT_TAXITYPE_ID) {
354  delete myVTypeDict[id];
355  myVTypeDict.erase(myVTypeDict.find(id));
357  } else {
358  return false;
359  }
360  } else {
361  if (myVTypeDict.find(id) != myVTypeDict.end() || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
362  return false;
363  }
364  }
365  return true;
366 }
367 
368 bool
370  if (checkVType(vehType->getID())) {
371  myVTypeDict[vehType->getID()] = vehType;
372  return true;
373  }
374  return false;
375 }
376 
377 
378 void
380  assert(vehType != 0);
381  assert(myVTypeDict.find(vehType->getID()) != myVTypeDict.end());
382  myVTypeDict.erase(vehType->getID());
383  if (myVTypeToDist.find(vehType->getID()) != myVTypeToDist.end()) {
384  myVTypeToDist.erase(vehType->getID());
385  }
386  delete vehType;
387 }
388 
389 
390 bool
391 MSVehicleControl::addVTypeDistribution(const std::string& id, RandomDistributor<MSVehicleType*>* vehTypeDistribution) {
392  if (checkVType(id)) {
393  myVTypeDistDict[id] = vehTypeDistribution;
394  std::vector<MSVehicleType*> vehTypes = vehTypeDistribution->getVals();
395  for (auto vehType : vehTypes) {
396  if (myVTypeToDist.find(vehType->getID()) != myVTypeToDist.end()) {
397  myVTypeToDist[vehType->getID()].insert(id);
398  } else {
399  myVTypeToDist[vehType->getID()] = { id };
400  }
401  }
402  return true;
403  }
404  return false;
405 }
406 
407 
408 bool
409 MSVehicleControl::hasVType(const std::string& id) const {
410  return myVTypeDict.count(id) > 0 || myVTypeDistDict.count(id) > 0;
411 }
412 
413 
414 bool
415 MSVehicleControl::hasVTypeDistribution(const std::string& id) const {
416  return myVTypeDistDict.count(id) > 0;
417 }
418 
419 
421 MSVehicleControl::getVType(const std::string& id, std::mt19937* rng) {
422  VTypeDictType::iterator it = myVTypeDict.find(id);
423  if (it == myVTypeDict.end()) {
424  VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
425  if (it2 == myVTypeDistDict.end()) {
426  return nullptr;
427  }
428  return it2->second->get(rng);
429  }
430  if (id == DEFAULT_VTYPE_ID) {
432  } else if (id == DEFAULT_PEDTYPE_ID) {
434  }
435  return it->second;
436 }
437 
438 
439 void
440 MSVehicleControl::insertVTypeIDs(std::vector<std::string>& into) const {
441  into.reserve(into.size() + myVTypeDict.size() + myVTypeDistDict.size());
442  for (VTypeDictType::const_iterator i = myVTypeDict.begin(); i != myVTypeDict.end(); ++i) {
443  into.push_back((*i).first);
444  }
445  for (VTypeDistDictType::const_iterator i = myVTypeDistDict.begin(); i != myVTypeDistDict.end(); ++i) {
446  into.push_back((*i).first);
447  }
448 }
449 
450 
451 const std::set<std::string>
453  std::map<std::string, std::set<std::string>>::const_iterator it = myVTypeToDist.find(id);
454  if (it == myVTypeToDist.end()) {
455  return std::set<std::string>();
456  }
457  return it->second;
458 }
459 
461 MSVehicleControl::getVTypeDistribution(const std::string& typeDistID) const {
462  auto it = myVTypeDistDict.find(typeDistID);
463  if (it != myVTypeDistDict.end()) {
464  return it->second;
465  } else {
466  return nullptr;
467  }
468 }
469 
470 void
472  for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
473  WRITE_WARNINGF("Vehicle '%' aborted waiting for a % that will never come.", i->first,
474  i->second->getParameter().departProcedure == DEPART_SPLIT ? "split" : "person or container")
475  }
476 }
477 
478 
479 int
481  int result = 0;
482  for (MSVehicleControl::constVehIt it = loadedVehBegin(); it != loadedVehEnd(); ++it) {
483  const SUMOVehicle* veh = it->second;
484  if ((veh->isOnRoad() || veh->isRemoteControlled()) && veh->getSpeed() < SUMO_const_haltingSpeed) {
485  result++;
486  }
487  }
488  return result;
489 }
490 
491 
492 
493 std::pair<double, double>
495  double speedSum = 0;
496  double relSpeedSum = 0;
497  int count = 0;
498  for (MSVehicleControl::constVehIt it = loadedVehBegin(); it != loadedVehEnd(); ++it) {
499  const SUMOVehicle* veh = it->second;
500  if ((veh->isOnRoad() || veh->isRemoteControlled()) && !veh->isStopped()) {
501  count++;
502  speedSum += veh->getSpeed();
503  relSpeedSum += veh->getSpeed() / veh->getEdge()->getSpeedLimit();
504  }
505  }
506  if (count > 0) {
507  return std::make_pair(speedSum / count, relSpeedSum / count);
508  } else {
509  return std::make_pair(-1, -1);
510  }
511 }
512 
513 
514 int
515 MSVehicleControl::getQuota(double frac, int loaded) const {
516  frac = frac < 0 ? myScale : frac;
517  if (frac < 0 || frac == 1.) {
518  return 1;
519  }
520  const int origLoaded = (loaded < 1
521  // the vehicle in question has already been loaded, hence the '-1'
522  ? frac > 1. ? (int)(myLoadedVehNo / frac) : myLoadedVehNo - 1
523  // given transportable number reflects only previously loaded
524  : frac > 1. ? (int)(loaded / frac) : loaded);
525  const int base = (int)frac;
526  const int resolution = 1000;
527  const int intFrac = (int)floor((frac - base) * resolution + 0.5);
528  // apply % twice to avoid integer overflow
529  if (((origLoaded % resolution) * intFrac) % resolution < intFrac) {
530  return base + 1;
531  }
532  return base;
533 }
534 
535 int
538 }
539 
540 
541 void
543  for (const SUMOVehicle* const veh : myPTVehicles) {
544  // add single vehicles with line attribute which are not part of a flow
545  const MSRoute* const route = MSRoute::dictionary(veh->getParameter().routeid);
546  router.getNetwork()->addSchedule(veh->getParameter(), route == nullptr ? nullptr : &route->getStops());
547  }
548 }
549 
550 
551 /****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:277
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define STEPFLOOR(x)
Definition: SUMOTime.h:56
const int VTYPEPARS_VEHICLECLASS_SET
@ SVC_IGNORING
vehicles ignoring classes
@ 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_TAXITYPE_ID
const std::string DEFAULT_PEDTYPE_ID
const std::string DEFAULT_VTYPE_ID
const std::string DEFAULT_CONTAINERTYPE_ID
const std::string DEFAULT_BIKETYPE_ID
@ DEPART_SPLIT
The departure is triggered by a train split.
@ DEPART_CONTAINER_TRIGGERED
The departure is container triggered.
@ DEPART_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
T MIN2(T a, T b)
Definition: StdDefs.h:73
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:60
T MAX2(T a, T b)
Definition: StdDefs.h:79
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:51
void addStops(const bool ignoreStopErrors, MSRouteIterator *searchStart=nullptr)
Adds stops to the built vehicle.
virtual void initDevices()
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:216
A device which collects info on the vehicle trip (mainly on departure and arrival)
A road/street connecting two junctions.
Definition: MSEdge.h:77
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:166
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:919
void addWaiting(SUMOVehicle *vehicle) const
Adds a vehicle to the list of waiting vehicles.
Definition: MSEdge.cpp:1159
static bool gUseMesoSim
Definition: MSGlobals.h:88
static bool teleportOnCollision()
Definition: MSLane.h:1231
@ VEHICLE_STATE_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSNet.h:591
@ VEHICLE_STATE_ARRIVED
The vehicle arrived at his destination (is deleted)
Definition: MSNet.h:597
@ VEHICLE_STATE_BUILT
The vehicle was built, but has not yet departed.
Definition: MSNet.h:589
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
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:1071
static std::mt19937 * getParsingRNG()
get parsing RNG
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
Definition: MSRoute.cpp:397
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:113
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:120
void registerOneWaiting(const bool isPerson)
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
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.
void clearState()
Remove all vehicles before quick-loading state.
bool myDefaultTaxiTypeMayBeDeleted
Whether the default taxi type was already used or can still be replaced.
bool addVType(MSVehicleType *vehType)
Adds a vehicle type.
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.
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
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.
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
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.
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.
std::map< std::string, std::set< std::string > > myVTypeToDist
Inverse lookup from vehicle type to distributions it is a member of.
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
double myMinDeceleration
The minimum deceleration capability for all vehicles in the network.
bool isPendingRemoval(SUMOVehicle *veh)
whether the given vehicle is scheduled for removal
virtual ~MSVehicleControl()
Destructor.
void removeVType(const MSVehicleType *vehType)
std::map< std::string, MSVehicleType * > VTypeDictType
Vehicle type dictionary type.
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
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.
void initVehicle(MSBaseVehicle *built, const bool ignoreStopErrors)
int myCollisions
The number of collisions.
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.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
bool myDefaultContainerTypeMayBeDeleted
Whether the default container type was already used or can still be replaced.
int myEndedVehNo
The number of removed vehicles.
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)
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
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 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:62
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:90
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
const std::string & getID() const
Returns the id.
Definition: Named.h:73
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:58
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
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:239
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.
int parametersSet
Information for the router which parameter were set.
Representation of a vehicle.
Definition: SUMOVehicle.h:58
virtual const MSRoute & getRoute() const =0
Returns the current route.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
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.
Structure representing possible vehicle parameter.
double departPos
(optional) The position the vehicle shall depart from
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:38