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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // The class responsible for building and deletion of vehicles
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include "MSVehicleControl.h"
26 #include "MSVehicle.h"
27 #include "MSLane.h"
28 #include "MSEdge.h"
29 #include "MSNet.h"
30 #include "MSRouteHandler.h"
33 #include <utils/common/Named.h>
34 #include <utils/common/RGBColor.h>
40 #ifdef HAVE_FOX
42 #endif
43 
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
49  myLoadedVehNo(0),
50  myRunningVehNo(0),
51  myEndedVehNo(0),
52  myDiscarded(0),
53  myCollisions(0),
54  myTeleportsJam(0),
55  myTeleportsYield(0),
56  myTeleportsWrongLane(0),
57  myEmergencyStops(0),
58  myTotalDepartureDelay(0),
59  myTotalTravelTime(0),
60  myDefaultVTypeMayBeDeleted(true),
61  myDefaultPedTypeMayBeDeleted(true),
62  myDefaultBikeTypeMayBeDeleted(true),
63  myWaitingForPerson(0),
64  myWaitingForContainer(0),
65  myMaxSpeedFactor(1),
66  myMinDeceleration(SUMOVTypeParameter::getDefaultDecel(SVC_IGNORING)),
67  myPendingRemovals(MSGlobals::gNumSimThreads > 1) {
77 }
78 
79 
81  // delete vehicles
82  for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
83  delete (*i).second;
84  }
85  myVehicleDict.clear();
86  // delete vehicle type distributions
87  for (VTypeDistDictType::iterator i = myVTypeDistDict.begin(); i != myVTypeDistDict.end(); ++i) {
88  delete (*i).second;
89  }
90  myVTypeDistDict.clear();
91  // delete vehicle types
92  for (VTypeDictType::iterator i = myVTypeDict.begin(); i != myVTypeDict.end(); ++i) {
93  delete (*i).second;
94  }
95  myVTypeDict.clear();
96 }
97 
98 
101  const MSRoute* route, MSVehicleType* type,
102  const bool ignoreStopErrors, const bool fromRouteFile) {
103  myLoadedVehNo++;
104  MSVehicle* built = new MSVehicle(defs, route, type, type->computeChosenSpeedDeviation(fromRouteFile ? MSRouteHandler::getParsingRNG() : nullptr));
105  try {
106  built->addStops(ignoreStopErrors);
107  } catch (ProcessError&) {
108  delete built;
109  throw;
110  }
112  return built;
113 }
114 
115 
116 void
118  assert(myRunningVehNo > 0);
119  if (!checkDuplicate || !isPendingRemoval(veh)) {
120  myPendingRemovals.push_back(veh);
121  }
122 }
123 
124 
125 bool
127 #ifdef HAVE_FOX
128  return myPendingRemovals.contains(veh);
129 #else
130  return std::find(myPendingRemovals.begin(), myPendingRemovals.end(), veh) == myPendingRemovals.end();
131 #endif
132 }
133 
134 void
136  OutputDevice* tripinfoOut = OptionsCont::getOptions().isSet("tripinfo-output") ? &OutputDevice::getDeviceByOption("tripinfo-output") : nullptr;
137 #ifdef HAVE_FOX
138  std::vector<SUMOVehicle*>& vehs = myPendingRemovals.getContainer();
139 #else
140  std::vector<SUMOVehicle*>& vehs = myPendingRemovals;
141 #endif
142  std::sort(vehs.begin(), vehs.end(), ComparatorNumericalIdLess());
143  for (SUMOVehicle* const veh : vehs) {
144  myTotalTravelTime += STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep() - veh->getDeparture());
145  myRunningVehNo--;
147  for (MSVehicleDevice* const dev : veh->getDevices()) {
148  dev->generateOutput();
149  }
150  if (tripinfoOut != nullptr) {
151  // close tag after tripinfo (possibly including emissions from another device) have been written
152  tripinfoOut->closeTag();
153  }
154  deleteVehicle(veh);
155  }
156  vehs.clear();
157  if (tripinfoOut != nullptr) {
158  // there seem to be people who think reading an unfinished xml is a good idea ;-)
159  tripinfoOut->flush();
160  }
161 #ifdef HAVE_FOX
162  myPendingRemovals.unlock();
163 #endif
164 }
165 
166 
167 void
169  ++myRunningVehNo;
173  if ((v.getVClass() & (SVC_PEDESTRIAN | SVC_NON_ROAD)) == 0) {
174  // only worry about deceleration of road users
176  }
177 }
178 
179 
180 void
181 MSVehicleControl::setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime) {
182  myRunningVehNo = runningVehNo;
183  myLoadedVehNo = loadedVehNo;
184  myEndedVehNo = endedVehNo;
185  myTotalDepartureDelay = totalDepartureDelay;
186  myTotalTravelTime = totalTravelTime;
187 }
188 
189 
190 void
192  out.openTag(SUMO_TAG_DELAY);
198  // save vehicle types
199  for (VTypeDictType::iterator it = myVTypeDict.begin(); it != myVTypeDict.end(); ++it) {
200  it->second->getParameter().write(out);
201  }
202  for (VTypeDistDictType::iterator it = myVTypeDistDict.begin(); it != myVTypeDistDict.end(); ++it) {
204  out.writeAttr(SUMO_ATTR_VTYPES, (*it).second->getVals());
205  out.writeAttr(SUMO_ATTR_PROBS, (*it).second->getProbs());
206  out.closeTag();
207  }
208  for (VehicleDictType::iterator it = myVehicleDict.begin(); it != myVehicleDict.end(); ++it) {
209  (*it).second->saveState(out);
210  }
211 }
212 
213 
214 bool
215 MSVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
216  VehicleDictType::iterator it = myVehicleDict.find(id);
217  if (it == myVehicleDict.end()) {
218  // id not in myVehicleDict.
219  myVehicleDict[id] = v;
220  const SUMOVehicleParameter& pars = v->getParameter();
222  const MSEdge* const firstEdge = v->getRoute().getEdges()[0];
223  if (!MSGlobals::gUseMesoSim) {
224  // position will be checked against person position later
225  static_cast<MSVehicle*>(v)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], v->getParameter().departPos);
226  }
227  firstEdge->addWaiting(v);
229  }
230  if (pars.line != "" && pars.repetitionNumber < 0) {
231  myPTVehicles.push_back(v);
232  }
233  return true;
234  }
235  return false;
236 }
237 
238 
240 MSVehicleControl::getVehicle(const std::string& id) const {
241  VehicleDictType::const_iterator it = myVehicleDict.find(id);
242  if (it == myVehicleDict.end()) {
243  return nullptr;
244  }
245  return it->second;
246 }
247 
248 
249 void
251  myEndedVehNo++;
252  if (discard) {
253  myDiscarded++;
254  }
255  if (veh != nullptr) {
256  myVehicleDict.erase(veh->getID());
257  }
258  auto ptVehIt = std::find(myPTVehicles.begin(), myPTVehicles.end(), veh);
259  if (ptVehIt != myPTVehicles.end()) {
260  myPTVehicles.erase(ptVehIt);
261  }
262  delete veh;
263 }
264 
265 
266 bool
267 MSVehicleControl::checkVType(const std::string& id) {
268  if (id == DEFAULT_VTYPE_ID) {
270  delete myVTypeDict[id];
271  myVTypeDict.erase(myVTypeDict.find(id));
273  } else {
274  return false;
275  }
276  } else if (id == DEFAULT_PEDTYPE_ID) {
278  delete myVTypeDict[id];
279  myVTypeDict.erase(myVTypeDict.find(id));
281  } else {
282  return false;
283  }
284  } else if (id == DEFAULT_BIKETYPE_ID) {
286  delete myVTypeDict[id];
287  myVTypeDict.erase(myVTypeDict.find(id));
289  } else {
290  return false;
291  }
292  } else {
293  if (myVTypeDict.find(id) != myVTypeDict.end() || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
294  return false;
295  }
296  }
297  return true;
298 }
299 
300 bool
302  if (checkVType(vehType->getID())) {
303  myVTypeDict[vehType->getID()] = vehType;
304  return true;
305  }
306  return false;
307 }
308 
309 
310 void
312  assert(vehType != 0);
313  assert(myVTypeDict.find(vehType->getID()) != myVTypeDict.end());
314  myVTypeDict.erase(vehType->getID());
315  if (myVTypeToDist.find(vehType->getID()) != myVTypeToDist.end()) {
316  myVTypeToDist.erase(vehType->getID());
317  }
318  delete vehType;
319 }
320 
321 
322 bool
323 MSVehicleControl::addVTypeDistribution(const std::string& id, RandomDistributor<MSVehicleType*>* vehTypeDistribution) {
324  if (checkVType(id)) {
325  myVTypeDistDict[id] = vehTypeDistribution;
326  std::vector<MSVehicleType*> vehTypes = vehTypeDistribution->getVals();
327  for (auto vehType : vehTypes) {
328  if (myVTypeToDist.find(vehType->getID()) != myVTypeToDist.end()) {
329  myVTypeToDist[vehType->getID()].insert(id);
330  } else {
331  myVTypeToDist[vehType->getID()] = { id };
332  }
333  }
334  return true;
335  }
336  return false;
337 }
338 
339 
340 bool
341 MSVehicleControl::hasVType(const std::string& id) const {
342  return myVTypeDict.count(id) > 0 || myVTypeDistDict.count(id) > 0;
343 }
344 
345 
346 bool
347 MSVehicleControl::hasVTypeDistribution(const std::string& id) const {
348  return myVTypeDistDict.count(id) > 0;
349 }
350 
351 
353 MSVehicleControl::getVType(const std::string& id, std::mt19937* rng) {
354  VTypeDictType::iterator it = myVTypeDict.find(id);
355  if (it == myVTypeDict.end()) {
356  VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
357  if (it2 == myVTypeDistDict.end()) {
358  return nullptr;
359  }
360  return it2->second->get(rng);
361  }
362  if (id == DEFAULT_VTYPE_ID) {
364  } else if (id == DEFAULT_PEDTYPE_ID) {
366  }
367  return it->second;
368 }
369 
370 
371 void
372 MSVehicleControl::insertVTypeIDs(std::vector<std::string>& into) const {
373  into.reserve(into.size() + myVTypeDict.size() + myVTypeDistDict.size());
374  for (VTypeDictType::const_iterator i = myVTypeDict.begin(); i != myVTypeDict.end(); ++i) {
375  into.push_back((*i).first);
376  }
377  for (VTypeDistDictType::const_iterator i = myVTypeDistDict.begin(); i != myVTypeDistDict.end(); ++i) {
378  into.push_back((*i).first);
379  }
380 }
381 
382 
383 const std::set<std::string>
385  std::map<std::string, std::set<std::string>>::const_iterator it = myVTypeToDist.find(id);
386  if (it == myVTypeToDist.end()) {
387  return std::set<std::string>();
388  }
389  return it->second;
390 }
391 
392 
393 void
395  for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
396  WRITE_WARNING("Vehicle " + i->first + " aborted waiting for a person or a container that will never come.");
397  }
398 }
399 
400 
401 int
403  int result = 0;
404  for (MSVehicleControl::constVehIt it = loadedVehBegin(); it != loadedVehEnd(); ++it) {
405  const SUMOVehicle* veh = it->second;
406  if ((veh->isOnRoad() || veh->isRemoteControlled()) && veh->getSpeed() < SUMO_const_haltingSpeed) {
407  result++;
408  }
409  }
410  return result;
411 }
412 
413 
414 
415 std::pair<double, double>
417  double speedSum = 0;
418  double relSpeedSum = 0;
419  int count = 0;
420  for (MSVehicleControl::constVehIt it = loadedVehBegin(); it != loadedVehEnd(); ++it) {
421  const SUMOVehicle* veh = it->second;
422  if ((veh->isOnRoad() || veh->isRemoteControlled()) && !veh->isStopped()) {
423  count++;
424  speedSum += veh->getSpeed();
425  relSpeedSum += veh->getSpeed() / veh->getEdge()->getSpeedLimit();
426  }
427  }
428  if (count > 0) {
429  return std::make_pair(speedSum / count, relSpeedSum / count);
430  } else {
431  return std::make_pair(-1, -1);
432  }
433 }
434 
435 
436 int
437 MSVehicleControl::getQuota(double frac) const {
438  frac = frac < 0 ? myScale : frac;
439  if (frac < 0 || frac == 1.) {
440  return 1;
441  }
442  // the vehicle in question has already been loaded, hence the '-1'
443  const int loaded = frac > 1. ? (int)(myLoadedVehNo / frac) : myLoadedVehNo - 1;
444  const int base = (int)frac;
445  const int resolution = 1000;
446  const int intFrac = (int)floor((frac - base) * resolution + 0.5);
447  // apply % twice to avoid integer overflow
448  if (((loaded % resolution) * intFrac) % resolution < intFrac) {
449  return base + 1;
450  }
451  return base;
452 }
453 
454 int
457 }
458 
459 
460 void
462  for (const SUMOVehicle* const veh : myPTVehicles) {
463  // add single vehicles with line attribute which are not part of a flow
464  const MSRoute* const route = MSRoute::dictionary(veh->getParameter().routeid);
465  router.getNetwork()->addSchedule(veh->getParameter(), route == nullptr ? nullptr : &route->getStops());
466  }
467 }
468 
469 
470 /****************************************************************************/
MSVehicleControl::vehicleDeparted
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
Definition: MSVehicleControl.cpp:168
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:65
OptionsCont::isSet
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Definition: OptionsCont.cpp:135
SVC_PEDESTRIAN
pedestrian
Definition: SUMOVehicleClass.h:156
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:93
MSVehicleControl::registerOneWaiting
void registerOneWaiting(const bool isPerson)
increases the count of vehicles waiting for a transport to allow recognition of person / container re...
Definition: MSVehicleControl.h:416
SUMO_ATTR_DEPART
Definition: SUMOXMLDefinitions.h:431
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
MSLane::teleportOnCollision
static bool teleportOnCollision()
Definition: MSLane.h:1197
MSCFModel::getMaxDecel
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:217
MSNet::VEHICLE_STATE_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSNet.h:539
MSEdge::getSpeedLimit
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:877
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
MSNet.h
DEFAULT_PEDTYPE_ID
const std::string DEFAULT_PEDTYPE_ID
MSEdge::addWaiting
void addWaiting(SUMOVehicle *vehicle) const
Adds a vehicle to the list of waiting vehicles.
Definition: MSEdge.cpp:1106
MSVehicleControl::getVType
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.
Definition: MSVehicleControl.cpp:353
MSVehicleControl::removeVType
void removeVType(const MSVehicleType *vehType)
Definition: MSVehicleControl.cpp:311
SUMOVehicle::getParameter
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
MSVehicleDevice.h
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
FXConditionalLock.h
OptionsCont.h
SUMOTrafficObject::getEdge
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
SUMOTrafficObject::getVehicleType
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
IntermodalRouter
Definition: MSNet.h:79
MSVehicleControl::~MSVehicleControl
virtual ~MSVehicleControl()
Destructor.
Definition: MSVehicleControl.cpp:80
MSVehicleControl::saveState
void saveState(OutputDevice &out)
Saves the current state into the given stream.
Definition: MSVehicleControl.cpp:191
MSNet::informVehicleStateListener
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:894
SUMOTrafficObject::getID
virtual const std::string & getID() const =0
Get the vehicle's ID.
MSVehicleControl::myTotalTravelTime
double myTotalTravelTime
The aggregated time vehicles needed to aacomplish their route (in seconds)
Definition: MSVehicleControl.h:558
SUMOVehicle::isRemoteControlled
virtual bool isRemoteControlled() const =0
Returns the information whether the vehicle is fully controlled via TraCI.
MSVehicleControl::abortWaiting
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
Definition: MSVehicleControl.cpp:394
MSVehicleControl::myDiscarded
int myDiscarded
The number of vehicles which were discarded while loading.
Definition: MSVehicleControl.h:531
FileHelpers.h
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
SUMOVehicle::isOnRoad
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
SUMOTrafficObject::getVClass
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle's access class.
IntermodalNetwork::addSchedule
void addSchedule(const SUMOVehicleParameter &pars, const std::vector< SUMOVehicleParameter::Stop > *addStops=nullptr)
Definition: IntermodalNetwork.h:550
SVC_BICYCLE
vehicle is a bicycle
Definition: SUMOVehicleClass.h:179
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
SUMOVehicleParameter::departProcedure
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
Definition: SUMOVehicleParameter.h:485
MSGlobals::gUseMesoSim
static bool gUseMesoSim
Definition: MSGlobals.h:90
MSGlobals
Definition: MSGlobals.h:48
MSVehicleControl::addVTypeDistribution
bool addVTypeDistribution(const std::string &id, RandomDistributor< MSVehicleType * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: MSVehicleControl.cpp:323
MSRoute::getEdges
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:120
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
SVC_NON_ROAD
classes which (normally) do not drive on normal roads
Definition: SUMOVehicleClass.h:209
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:297
MSEdge.h
MSVehicleControl::scheduleVehicleRemoval
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
Definition: MSVehicleControl.cpp:117
MSNet::VEHICLE_STATE_ARRIVED
The vehicle arrived at his destination (is deleted)
Definition: MSNet.h:545
MSRoute
Definition: MSRoute.h:66
MSVehicleControl::constVehIt
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
Definition: MSVehicleControl.h:74
SUMOVehicleParameter::depart
SUMOTime depart
Definition: SUMOVehicleParameter.h:482
MSVehicleControl::myVTypeDict
VTypeDictType myVTypeDict
Dictionary of vehicle types.
Definition: MSVehicleControl.h:580
RGBColor.h
SUMO_const_haltingSpeed
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:60
MSVehicle.h
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:253
SUMO_ATTR_BEGIN
weights: time range begin
Definition: SUMOXMLDefinitions.h:678
MSVehicleControl::myLoadedVehNo
int myLoadedVehNo
The number of build vehicles.
Definition: MSVehicleControl.h:521
MSVehicleControl::myDefaultPedTypeMayBeDeleted
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
Definition: MSVehicleControl.h:594
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
SUMOTrafficObject::getChosenSpeedFactor
virtual double getChosenSpeedFactor() const =0
MSVehicleControl::myVTypeToDist
std::map< std::string, std::set< std::string > > myVTypeToDist
Inverse lookup from vehicle type to distributions it is a member of.
Definition: MSVehicleControl.h:588
SUMOVTypeParameter::parametersSet
int parametersSet
Information for the router which parameter were set.
Definition: SUMOVTypeParameter.h:307
SUMOVehicleParameter::line
std::string line
The vehicle's line (mainly for public transport)
Definition: SUMOVehicleParameter.h:561
MSVehicleControl::buildVehicle
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.
Definition: MSVehicleControl.cpp:100
BinaryInputDevice.h
SUMOVehicle::getDeparture
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
SUMOVehicle::getRoute
virtual const MSRoute & getRoute() const =0
Returns the current route.
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
MSVehicleControl::addVehicle
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
Definition: MSVehicleControl.cpp:215
MSVehicleControl::myMaxSpeedFactor
double myMaxSpeedFactor
The maximum speed factor for all vehicles in the network.
Definition: MSVehicleControl.h:609
MSVehicleControl::getVehicle
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
Definition: MSVehicleControl.cpp:240
MSVehicleType::computeChosenSpeedDeviation
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
Definition: MSVehicleType.cpp:82
OutputDevice::flush
void flush()
Definition: OutputDevice.h:331
MSVehicleControl::setState
void setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime)
Sets the current state variables as loaded from the stream.
Definition: MSVehicleControl.cpp:181
MSVehicleControl::getVTypeDistributionMembership
const std::set< std::string > getVTypeDistributionMembership(const std::string &id) const
Return the distribution IDs the vehicle type is a member of.
Definition: MSVehicleControl.cpp:384
MSVehicleType::getCarFollowModel
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
Definition: MSVehicleType.h:140
MSVehicleControl::adaptIntermodalRouter
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
Definition: MSVehicleControl.cpp:461
MSVehicleControl::hasVTypeDistribution
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
Definition: MSVehicleControl.cpp:347
MSVehicleControl::myVTypeDistDict
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition: MSVehicleControl.h:585
MSVehicleControl::myRunningVehNo
int myRunningVehNo
The number of vehicles within the network (build and inserted but not removed)
Definition: MSVehicleControl.h:525
SUMOVTypeParameter
Structure representing possible vehicle parameter.
Definition: SUMOVTypeParameter.h:86
Named.h
MSVehicleControl::addVType
bool addVType(MSVehicleType *vehType)
Adds a vehicle type.
Definition: MSVehicleControl.cpp:301
STEPFLOOR
#define STEPFLOOR(x)
Definition: SUMOTime.h:59
DEFAULT_VTYPE_ID
const std::string DEFAULT_VTYPE_ID
MSVehicleControl::loadedVehEnd
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Definition: MSVehicleControl.h:185
MSVehicleControl::myVehicleDict
VehicleDictType myVehicleDict
Dictionary of vehicles.
Definition: MSVehicleControl.h:569
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Definition: SUMOVehicleClass.h:159
MSVehicleControl::myTeleportsJam
int myTeleportsJam
The number of teleports due to jam.
Definition: MSVehicleControl.h:537
OutputDevice.h
MSVehicleControl::deleteVehicle
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
Definition: MSVehicleControl.cpp:250
ProcessError
Definition: UtilExceptions.h:39
MSNet::VEHICLE_STATE_BUILT
The vehicle was built, but has not yet departed.
Definition: MSNet.h:537
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
DEPART_TRIGGERED
The departure is person triggered.
Definition: SUMOVehicleParameter.h:102
SUMO_ATTR_PROBS
Definition: SUMOXMLDefinitions.h:630
MSVehicleControl::getQuota
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
Definition: MSVehicleControl.cpp:437
MSVehicleControl::myTotalDepartureDelay
double myTotalDepartureDelay
The aggregated time vehicles had to wait for departure (in seconds)
Definition: MSVehicleControl.h:555
SUMO_ATTR_TIME
trigger: the time of the step
Definition: SUMOXMLDefinitions.h:676
RandomDistributor< MSVehicleType * >
MSVehicleControl::myPTVehicles
std::vector< SUMOVehicle * > myPTVehicles
List of vehicles which belong to public transport.
Definition: MSVehicleControl.h:615
MSVehicleControl::myScale
double myScale
The scaling factor (especially for inc-dua)
Definition: MSVehicleControl.h:606
MSVehicleControl::myTeleportsYield
int myTeleportsYield
The number of teleports due to vehicles stuck on a minor road.
Definition: MSVehicleControl.h:540
MSBaseVehicle::addStops
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
Definition: MSBaseVehicle.cpp:593
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:208
SUMO_TAG_DELAY
Definition: SUMOXMLDefinitions.h:258
MSVehicleControl::isPendingRemoval
bool isPendingRemoval(SUMOVehicle *veh)
whether the given vehicle is scheduled for removal
Definition: MSVehicleControl.cpp:126
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
MSVehicleControl::getHaltingVehicleNo
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
Definition: MSVehicleControl.cpp:402
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
SUMO_ATTR_VTYPES
Definition: SUMOXMLDefinitions.h:632
MSVehicleType::build
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
Definition: MSVehicleType.cpp:281
MSVehicleControl::removePending
void removePending()
Removes a vehicle after it has ended.
Definition: MSVehicleControl.cpp:135
MSVehicleControl::myMinDeceleration
double myMinDeceleration
The minimum deceleration capability for all vehicles in the network.
Definition: MSVehicleControl.h:612
MSVehicleControl::MSVehicleControl
MSVehicleControl()
Constructor.
Definition: MSVehicleControl.cpp:48
MSRouteHandler::getParsingRNG
static std::mt19937 * getParsingRNG()
get parsing RNG
Definition: MSRouteHandler.h:62
MSVehicleControl::myCollisions
int myCollisions
The number of collisions.
Definition: MSVehicleControl.h:534
MSVehicleControl::myDefaultVTypeMayBeDeleted
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
Definition: MSVehicleControl.h:591
MSRoute::getStops
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
Definition: MSRoute.cpp:376
ComparatorNumericalIdLess
Function-object for stable sorting of objects with numerical ids.
Definition: Named.h:41
MSEdge::getLanes
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:167
MSVehicleControl::getVehicleMeanSpeeds
virtual std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
Definition: MSVehicleControl.cpp:416
MSVehicleControl::myTeleportsWrongLane
int myTeleportsWrongLane
The number of teleports due to vehicles stuck on the wrong lane.
Definition: MSVehicleControl.h:543
MSVehicleControl::checkVType
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: MSVehicleControl.cpp:267
MSVehicleControl::insertVTypeIDs
void insertVTypeIDs(std::vector< std::string > &into) const
Inserts ids of all known vehicle types and vehicle type distributions to the given vector.
Definition: MSVehicleControl.cpp:372
MSRoute::dictionary
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:113
config.h
MSVehicleControl::myPendingRemovals
std::vector< SUMOVehicle * > myPendingRemovals
List of vehicles which are going to be removed.
Definition: MSVehicleControl.h:621
SUMO_ATTR_END
weights: time range end
Definition: SUMOXMLDefinitions.h:680
MSVehicleControl::hasVType
bool hasVType(const std::string &id) const
Asks for existence of a vehicle type.
Definition: MSVehicleControl.cpp:341
MSVehicleControl::loadedVehBegin
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
Definition: MSVehicleControl.h:177
MSLane.h
MSVehicleControl::getTeleportCount
int getTeleportCount() const
return the number of teleports (including collisions)
Definition: MSVehicleControl.cpp:455
DEPART_CONTAINER_TRIGGERED
The departure is container triggered.
Definition: SUMOVehicleParameter.h:104
SUMOVehicleParameter::repetitionNumber
int repetitionNumber
Definition: SUMOVehicleParameter.h:544
IntermodalRouter::getNetwork
Network * getNetwork() const
Definition: IntermodalRouter.h:234
MSVehicleControl::myEndedVehNo
int myEndedVehNo
The number of removed vehicles.
Definition: MSVehicleControl.h:528
SVC_IGNORING
vehicles ignoring classes
Definition: SUMOVehicleClass.h:135
DEFAULT_BIKETYPE_ID
const std::string DEFAULT_BIKETYPE_ID
SUMOVTypeParameter.h
MSRouteHandler.h
SUMO_ATTR_NUMBER
Definition: SUMOXMLDefinitions.h:666
MSVehicleControl.h
OutputDevice::getDeviceByOption
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
Definition: OutputDevice.cpp:116
SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
Definition: SUMOXMLDefinitions.h:216
SUMOVehicleParameter::departPos
double departPos
(optional) The position the vehicle shall depart from
Definition: SUMOVehicleParameter.h:494
IntermodalRouter.h
RandomDistributor::getVals
const std::vector< T > & getVals() const
Returns the members of the distribution.
Definition: RandomDistributor.h:151
VTYPEPARS_VEHICLECLASS_SET
const int VTYPEPARS_VEHICLECLASS_SET
Definition: SUMOVTypeParameter.h:52
SUMOTrafficObject::getSpeed
virtual double getSpeed() const =0
Returns the vehicle's current speed.
MSVehicleControl::myDefaultBikeTypeMayBeDeleted
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
Definition: MSVehicleControl.h:597
SUMOTrafficObject::isStopped
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop.
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:79
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:54