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 /****************************************************************************/
17 // The class responsible for building and deletion of vehicles
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "MSVehicleControl.h"
27 #include "MSVehicle.h"
28 #include "MSLane.h"
29 #include "MSEdge.h"
30 #include "MSNet.h"
31 #include "MSRouteHandler.h"
34 #include <utils/common/Named.h>
35 #include <utils/common/RGBColor.h>
41 #ifdef HAVE_FOX
43 #endif
44 
45 
46 // ===========================================================================
47 // member method definitions
48 // ===========================================================================
50  myLoadedVehNo(0),
51  myRunningVehNo(0),
52  myEndedVehNo(0),
53  myDiscarded(0),
54  myCollisions(0),
55  myTeleportsJam(0),
56  myTeleportsYield(0),
57  myTeleportsWrongLane(0),
58  myEmergencyStops(0),
59  myTotalDepartureDelay(0),
60  myTotalTravelTime(0),
61  myDefaultVTypeMayBeDeleted(true),
62  myDefaultPedTypeMayBeDeleted(true),
63  myDefaultBikeTypeMayBeDeleted(true),
64  myWaitingForPerson(0),
65  myWaitingForContainer(0),
66  myMaxSpeedFactor(1),
67  myMinDeceleration(SUMOVTypeParameter::getDefaultDecel(SVC_IGNORING)),
68  myPendingRemovals(MSGlobals::gNumSimThreads > 1) {
78  myScale = oc.getFloat("scale");
79  myStopTolerance = oc.getFloat("ride.stop-tolerance");
80 }
81 
82 
84  // delete vehicles
85  for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
86  delete (*i).second;
87  }
88  myVehicleDict.clear();
89  // delete vehicle type distributions
90  for (VTypeDistDictType::iterator i = myVTypeDistDict.begin(); i != myVTypeDistDict.end(); ++i) {
91  delete (*i).second;
92  }
93  myVTypeDistDict.clear();
94  // delete vehicle types
95  for (VTypeDictType::iterator i = myVTypeDict.begin(); i != myVTypeDict.end(); ++i) {
96  //delete(*i).second;
97  }
98  myVTypeDict.clear();
99 }
100 
101 
104  const MSRoute* route, MSVehicleType* type,
105  const bool ignoreStopErrors, const bool fromRouteFile) {
106  myLoadedVehNo++;
107  MSVehicle* built = new MSVehicle(defs, route, type, type->computeChosenSpeedDeviation(fromRouteFile ? MSRouteHandler::getParsingRNG() : nullptr));
108  built->addStops(ignoreStopErrors);
110  return built;
111 }
112 
113 
114 void
116  assert(myRunningVehNo > 0);
117  if (!checkDuplicate ||
118 #ifdef HAVE_FOX
119  std::find(myPendingRemovals.getContainer().begin(), myPendingRemovals.getContainer().end(), veh) == myPendingRemovals.getContainer().end()
120 #else
121  std::find(myPendingRemovals.begin(), myPendingRemovals.end(), veh) == myPendingRemovals.end()
122 #endif
123  ) {
124  myPendingRemovals.push_back(veh);
125  }
126 }
127 
128 
129 void
131  OutputDevice* tripinfoOut = OptionsCont::getOptions().isSet("tripinfo-output") ? &OutputDevice::getDeviceByOption("tripinfo-output") : nullptr;
132 #ifdef HAVE_FOX
133  std::vector<SUMOVehicle*>& vehs = myPendingRemovals.getContainer();
134 #else
135  std::vector<SUMOVehicle*>& vehs = myPendingRemovals;
136 #endif
137  std::sort(vehs.begin(), vehs.end(), ComparatorNumericalIdLess());
138  for (SUMOVehicle* const veh : vehs) {
139  myTotalTravelTime += STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep() - veh->getDeparture());
140  myRunningVehNo--;
142  for (MSVehicleDevice* const dev : veh->getDevices()) {
143  dev->generateOutput();
144  }
145  if (tripinfoOut != nullptr) {
146  // close tag after tripinfo (possibly including emissions from another device) have been written
147  tripinfoOut->closeTag();
148  }
149  deleteVehicle(veh);
150  }
151  vehs.clear();
152  if (tripinfoOut != nullptr) {
153  // there seem to be people who think reading an unfinished xml is a good idea ;-)
154  tripinfoOut->flush();
155  }
156 #ifdef HAVE_FOX
157  myPendingRemovals.unlock();
158 #endif
159 }
160 
161 
162 void
164  ++myRunningVehNo;
168  if ((v.getVClass() & (SVC_PEDESTRIAN | SVC_NON_ROAD)) == 0) {
169  // only worry about deceleration of road users
171  }
172 }
173 
174 
175 void
176 MSVehicleControl::setState(int runningVehNo, int loadedVehNo, int endedVehNo, double totalDepartureDelay, double totalTravelTime) {
177  myRunningVehNo = runningVehNo;
178  myLoadedVehNo = loadedVehNo;
179  myEndedVehNo = endedVehNo;
180  myTotalDepartureDelay = totalDepartureDelay;
181  myTotalTravelTime = totalTravelTime;
182 }
183 
184 
185 void
187  out.openTag(SUMO_TAG_DELAY);
193  // save vehicle types
194  for (VTypeDictType::iterator it = myVTypeDict.begin(); it != myVTypeDict.end(); ++it) {
195  it->second->getParameter().write(out);
196  }
197  for (VTypeDistDictType::iterator it = myVTypeDistDict.begin(); it != myVTypeDistDict.end(); ++it) {
199  out.writeAttr(SUMO_ATTR_VTYPES, (*it).second->getVals());
200  out.writeAttr(SUMO_ATTR_PROBS, (*it).second->getProbs());
201  out.closeTag();
202  }
203  for (VehicleDictType::iterator it = myVehicleDict.begin(); it != myVehicleDict.end(); ++it) {
204  (*it).second->saveState(out);
205  }
206 }
207 
208 
209 bool
210 MSVehicleControl::addVehicle(const std::string& id, SUMOVehicle* v) {
211  VehicleDictType::iterator it = myVehicleDict.find(id);
212  if (it == myVehicleDict.end()) {
213  // id not in myVehicleDict.
214  myVehicleDict[id] = v;
215  const SUMOVehicleParameter& pars = v->getParameter();
217  const MSEdge* const firstEdge = v->getRoute().getEdges()[0];
218  if (!MSGlobals::gUseMesoSim) {
219  // position will be checked against person position later
220  static_cast<MSVehicle*>(v)->setTentativeLaneAndPosition(firstEdge->getLanes()[0], v->getParameter().departPos);
221  }
222  addWaiting(v->getRoute().getEdges().front(), v);
224  }
225  if (pars.line != "" && pars.repetitionNumber < 0) {
226  myPTVehicles.push_back(v);
227  }
228  return true;
229  }
230  return false;
231 }
232 
233 
235 MSVehicleControl::getVehicle(const std::string& id) const {
236  VehicleDictType::const_iterator it = myVehicleDict.find(id);
237  if (it == myVehicleDict.end()) {
238  return nullptr;
239  }
240  return it->second;
241 }
242 
243 
244 void
246  myEndedVehNo++;
247  if (discard) {
248  myDiscarded++;
249  }
250  if (veh != nullptr) {
251  myVehicleDict.erase(veh->getID());
252  }
253  auto ptVehIt = std::find(myPTVehicles.begin(), myPTVehicles.end(), veh);
254  if (ptVehIt != myPTVehicles.end()) {
255  myPTVehicles.erase(ptVehIt);
256  }
257  delete veh;
258 }
259 
260 
261 bool
262 MSVehicleControl::checkVType(const std::string& id) {
263  if (id == DEFAULT_VTYPE_ID) {
265  delete myVTypeDict[id];
266  myVTypeDict.erase(myVTypeDict.find(id));
268  } else {
269  return false;
270  }
271  } else if (id == DEFAULT_PEDTYPE_ID) {
273  delete myVTypeDict[id];
274  myVTypeDict.erase(myVTypeDict.find(id));
276  } else {
277  return false;
278  }
279  } else if (id == DEFAULT_BIKETYPE_ID) {
281  delete myVTypeDict[id];
282  myVTypeDict.erase(myVTypeDict.find(id));
284  } else {
285  return false;
286  }
287  } else {
288  if (myVTypeDict.find(id) != myVTypeDict.end() || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
289  return false;
290  }
291  }
292  return true;
293 }
294 
295 bool
297  if (checkVType(vehType->getID())) {
298  myVTypeDict[vehType->getID()] = vehType;
299  return true;
300  }
301  return false;
302 }
303 
304 
305 void
307  assert(vehType != 0);
308  assert(myVTypeDict.find(vehType->getID()) != myVTypeDict.end());
309  myVTypeDict.erase(vehType->getID());
310  if (myVTypeToDist.find(vehType->getID()) != myVTypeToDist.end()) {
311  myVTypeToDist.erase(vehType->getID());
312  }
313  delete vehType;
314 }
315 
316 
317 bool
318 MSVehicleControl::addVTypeDistribution(const std::string& id, RandomDistributor<MSVehicleType*>* vehTypeDistribution) {
319  if (checkVType(id)) {
320  myVTypeDistDict[id] = vehTypeDistribution;
321  std::vector<MSVehicleType*> vehTypes = vehTypeDistribution->getVals();
322  for (auto vehType : vehTypes) {
323  if (myVTypeToDist.find(vehType->getID()) != myVTypeToDist.end()) {
324  myVTypeToDist[vehType->getID()].insert(id);
325  } else {
326  myVTypeToDist[vehType->getID()] = { id };
327  }
328  }
329  return true;
330  }
331  return false;
332 }
333 
334 
335 bool
336 MSVehicleControl::hasVType(const std::string& id) const {
337  return myVTypeDict.count(id) > 0 || myVTypeDistDict.count(id) > 0;
338 }
339 
340 
341 bool
342 MSVehicleControl::hasVTypeDistribution(const std::string& id) const {
343  return myVTypeDistDict.count(id) > 0;
344 }
345 
346 
348 MSVehicleControl::getVType(const std::string& id, std::mt19937* rng) {
349  VTypeDictType::iterator it = myVTypeDict.find(id);
350  if (it == myVTypeDict.end()) {
351  VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
352  if (it2 == myVTypeDistDict.end()) {
353  return nullptr;
354  }
355  return it2->second->get(rng);
356  }
357  if (id == DEFAULT_VTYPE_ID) {
359  } else if (id == DEFAULT_PEDTYPE_ID) {
361  }
362  return it->second;
363 }
364 
365 
366 void
367 MSVehicleControl::insertVTypeIDs(std::vector<std::string>& into) const {
368  into.reserve(into.size() + myVTypeDict.size() + myVTypeDistDict.size());
369  for (VTypeDictType::const_iterator i = myVTypeDict.begin(); i != myVTypeDict.end(); ++i) {
370  into.push_back((*i).first);
371  }
372  for (VTypeDistDictType::const_iterator i = myVTypeDistDict.begin(); i != myVTypeDistDict.end(); ++i) {
373  into.push_back((*i).first);
374  }
375 }
376 
377 
378 const std::set<std::string>
380  std::map<std::string, std::set<std::string>>::const_iterator it = myVTypeToDist.find(id);
381  if (it == myVTypeToDist.end()) {
382  return std::set<std::string>();
383  }
384  return it->second;
385 }
386 
387 
388 void
389 MSVehicleControl::addWaiting(const MSEdge* const edge, SUMOVehicle* vehicle) {
390  if (myWaiting.find(edge) == myWaiting.end()) {
391  myWaiting[edge] = std::vector<SUMOVehicle*>();
392  }
393  myWaiting[edge].push_back(vehicle);
394 }
395 
396 
397 void
398 MSVehicleControl::removeWaiting(const MSEdge* const edge, const SUMOVehicle* vehicle) {
399  if (myWaiting.find(edge) != myWaiting.end()) {
400  std::vector<SUMOVehicle*>::iterator it = std::find(myWaiting[edge].begin(), myWaiting[edge].end(), vehicle);
401  if (it != myWaiting[edge].end()) {
402  myWaiting[edge].erase(it);
403  }
404  }
405 }
406 
407 
409 MSVehicleControl::getWaitingVehicle(MSTransportable* transportable, const MSEdge* const edge, const double position) {
410  if (myWaiting.find(edge) != myWaiting.end()) {
411  for (SUMOVehicle* const vehicle : myWaiting[edge]) {
412  if (transportable->isWaitingFor(vehicle)) {
413  if (vehicle->isStoppedInRange(position, myStopTolerance) ||
414  (!vehicle->hasDeparted() &&
415  (vehicle->getParameter().departProcedure == DEPART_TRIGGERED ||
416  vehicle->getParameter().departProcedure == DEPART_CONTAINER_TRIGGERED))) {
417  return vehicle;
418  }
419  // !!! this gives false warnings when there are two stops on the same edge
420  WRITE_WARNING(transportable->getID() + " at edge '" + edge->getID() + "' position " + toString(position) + " cannot use waiting vehicle '"
421  + vehicle->getID() + "' at position " + toString(vehicle->getPositionOnLane()) + " because it is too far away.");
422  }
423  }
424  }
425  return nullptr;
426 }
427 
428 
429 void
431  for (VehicleDictType::iterator i = myVehicleDict.begin(); i != myVehicleDict.end(); ++i) {
432  WRITE_WARNING("Vehicle " + i->first + " aborted waiting for a person or a container that will never come.");
433  }
434 }
435 
436 
437 int
439  int result = 0;
440  for (MSVehicleControl::constVehIt it = loadedVehBegin(); it != loadedVehEnd(); ++it) {
441  const SUMOVehicle* veh = it->second;
442  if ((veh->isOnRoad() || veh->isRemoteControlled()) && veh->getSpeed() < SUMO_const_haltingSpeed) {
443  result++;
444  }
445  }
446  return result;
447 }
448 
449 
450 
451 std::pair<double, double>
453  double speedSum = 0;
454  double relSpeedSum = 0;
455  int count = 0;
456  for (MSVehicleControl::constVehIt it = loadedVehBegin(); it != loadedVehEnd(); ++it) {
457  const SUMOVehicle* veh = it->second;
458  if ((veh->isOnRoad() || veh->isRemoteControlled()) && !veh->isStopped()) {
459  count++;
460  speedSum += veh->getSpeed();
461  relSpeedSum += veh->getSpeed() / veh->getEdge()->getSpeedLimit();
462  }
463  }
464  if (count > 0) {
465  return std::make_pair(speedSum / count, relSpeedSum / count);
466  } else {
467  return std::make_pair(-1, -1);
468  }
469 }
470 
471 
472 int
473 MSVehicleControl::getQuota(double frac) const {
474  frac = frac < 0 ? myScale : frac;
475  if (frac < 0 || frac == 1.) {
476  return 1;
477  }
478  // the vehicle in question has already been loaded, hence the '-1'
479  const int loaded = frac > 1. ? (int)(myLoadedVehNo / frac) : myLoadedVehNo - 1;
480  const int base = (int)frac;
481  const int resolution = 1000;
482  const int intFrac = (int)floor((frac - base) * resolution + 0.5);
483  // apply % twice to avoid integer overflow
484  if (((loaded % resolution) * intFrac) % resolution < intFrac) {
485  return base + 1;
486  }
487  return base;
488 }
489 
490 int
493 }
494 
495 
496 void
498  for (const SUMOVehicle* const veh : myPTVehicles) {
499  // add single vehicles with line attribute which are not part of a flow
500  const MSRoute* const route = MSRoute::dictionary(veh->getParameter().routeid);
501  router.getNetwork()->addSchedule(veh->getParameter(), route == nullptr ? nullptr : &route->getStops());
502  }
503 }
504 
505 
506 /****************************************************************************/
507 
MSVehicleControl::vehicleDeparted
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
Definition: MSVehicleControl.cpp:163
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:66
OptionsCont::isSet
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Definition: OptionsCont.cpp:136
SVC_PEDESTRIAN
pedestrian
Definition: SUMOVehicleClass.h:157
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
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:431
SUMO_ATTR_DEPART
Definition: SUMOXMLDefinitions.h:432
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:74
MSLane::teleportOnCollision
static bool teleportOnCollision()
Definition: MSLane.h:1198
MSCFModel::getMaxDecel
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:218
MSNet::VEHICLE_STATE_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSNet.h:540
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:916
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
MSNet.h
DEFAULT_PEDTYPE_ID
const std::string DEFAULT_PEDTYPE_ID
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:348
MSVehicleControl::removeVType
void removeVType(const MSVehicleType *vehType)
Definition: MSVehicleControl.cpp:306
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:64
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:80
MSVehicleControl::~MSVehicleControl
virtual ~MSVehicleControl()
Destructor.
Definition: MSVehicleControl.cpp:83
MSVehicleControl::saveState
void saveState(OutputDevice &out)
Saves the current state into the given stream.
Definition: MSVehicleControl.cpp:186
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:882
SUMOTrafficObject::getID
virtual const std::string & getID() const =0
Get the vehicle's ID.
MSVehicleControl::removeWaiting
void removeWaiting(const MSEdge *const edge, const SUMOVehicle *vehicle)
Removes a vehicle from the list of waiting vehicles for the given edge.
Definition: MSVehicleControl.cpp:398
MSVehicleControl::myTotalTravelTime
double myTotalTravelTime
The aggregated time vehicles needed to aacomplish their route (in seconds)
Definition: MSVehicleControl.h:570
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:430
MSVehicleControl::myDiscarded
int myDiscarded
The number of vehicles which were discarded while loading.
Definition: MSVehicleControl.h:543
FileHelpers.h
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
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:546
SVC_BICYCLE
vehicle is a bicycle
Definition: SUMOVehicleClass.h:180
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
SUMOVehicleParameter::departProcedure
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
Definition: SUMOVehicleParameter.h:479
MSGlobals::gUseMesoSim
static bool gUseMesoSim
Definition: MSGlobals.h:91
MSGlobals
Definition: MSGlobals.h:49
MSVehicleControl::addVTypeDistribution
bool addVTypeDistribution(const std::string &id, RandomDistributor< MSVehicleType * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: MSVehicleControl.cpp:318
MSRoute::getEdges
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:121
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:379
SVC_NON_ROAD
classes which (normally) do not drive on normal roads
Definition: SUMOVehicleClass.h:210
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:291
MSEdge.h
MSTransportable
Definition: MSTransportable.h:59
MSVehicleControl::scheduleVehicleRemoval
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
Definition: MSVehicleControl.cpp:115
MSNet::VEHICLE_STATE_ARRIVED
The vehicle arrived at his destination (is deleted)
Definition: MSNet.h:546
MSRoute
Definition: MSRoute.h:67
MSVehicleControl::constVehIt
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
Definition: MSVehicleControl.h:75
SUMOVehicleParameter::depart
SUMOTime depart
Definition: SUMOVehicleParameter.h:476
MSVehicleControl::addWaiting
void addWaiting(const MSEdge *const edge, SUMOVehicle *vehicle)
Adds a vehicle to the list of waiting vehicles for the given edge.
Definition: MSVehicleControl.cpp:389
MSVehicleControl::myVTypeDict
VTypeDictType myVTypeDict
Dictionary of vehicle types.
Definition: MSVehicleControl.h:592
RGBColor.h
SUMO_const_haltingSpeed
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition: StdDefs.h:61
MSVehicle.h
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:254
SUMO_ATTR_BEGIN
weights: time range begin
Definition: SUMOXMLDefinitions.h:675
MSVehicleControl::myLoadedVehNo
int myLoadedVehNo
The number of build vehicles.
Definition: MSVehicleControl.h:533
MSVehicleControl::myDefaultPedTypeMayBeDeleted
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
Definition: MSVehicleControl.h:606
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:80
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:600
SUMOVTypeParameter::parametersSet
int parametersSet
Information for the router which parameter were set.
Definition: SUMOVTypeParameter.h:308
SUMOVehicleParameter::line
std::string line
The vehicle's line (mainly for public transport)
Definition: SUMOVehicleParameter.h:555
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:103
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:256
MSVehicleControl::addVehicle
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
Definition: MSVehicleControl.cpp:210
MSVehicleControl::myMaxSpeedFactor
double myMaxSpeedFactor
The maximum speed factor for all vehicles in the network.
Definition: MSVehicleControl.h:624
MSVehicleControl::getVehicle
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
Definition: MSVehicleControl.cpp:235
MSVehicleType::computeChosenSpeedDeviation
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
Definition: MSVehicleType.cpp:83
OutputDevice::flush
void flush()
Definition: OutputDevice.h:332
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:176
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:379
MSVehicleType::getCarFollowModel
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
Definition: MSVehicleType.h:141
MSVehicleControl::adaptIntermodalRouter
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
Definition: MSVehicleControl.cpp:497
MSVehicleControl::hasVTypeDistribution
bool hasVTypeDistribution(const std::string &id) const
Asks for a vehicle type distribution.
Definition: MSVehicleControl.cpp:342
MSVehicleControl::myVTypeDistDict
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition: MSVehicleControl.h:597
MSVehicleControl::myRunningVehNo
int myRunningVehNo
The number of vehicles within the network (build and inserted but not removed)
Definition: MSVehicleControl.h:537
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:296
STEPFLOOR
#define STEPFLOOR(x)
Definition: SUMOTime.h:60
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:186
MSVehicleControl::myVehicleDict
VehicleDictType myVehicleDict
Dictionary of vehicles.
Definition: MSVehicleControl.h:581
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:57
SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Definition: SUMOVehicleClass.h:160
MSVehicleControl::myTeleportsJam
int myTeleportsJam
The number of teleports due to jam.
Definition: MSVehicleControl.h:549
MSVehicleControl::myStopTolerance
double myStopTolerance
The tolerance to apply when matching waiting persons and vehicles.
Definition: MSVehicleControl.h:633
OutputDevice.h
MSVehicleControl::deleteVehicle
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
Definition: MSVehicleControl.cpp:245
MSNet::VEHICLE_STATE_BUILT
The vehicle was built, but has not yet departed.
Definition: MSNet.h:538
MSVehicleControl::myWaiting
std::map< const MSEdge *const, std::vector< SUMOVehicle * > > myWaiting
the lists of waiting vehicles to a given edge
Definition: MSVehicleControl.h:612
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
DEPART_TRIGGERED
The departure is person triggered.
Definition: SUMOVehicleParameter.h:98
SUMO_ATTR_PROBS
Definition: SUMOXMLDefinitions.h:628
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:473
MSVehicleControl::myTotalDepartureDelay
double myTotalDepartureDelay
The aggregated time vehicles had to wait for departure (in seconds)
Definition: MSVehicleControl.h:567
SUMO_ATTR_TIME
trigger: the time of the step
Definition: SUMOXMLDefinitions.h:673
MSTransportable::isWaitingFor
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle in the current step.
Definition: MSTransportable.h:717
RandomDistributor< MSVehicleType * >
MSVehicleControl::myPTVehicles
std::vector< SUMOVehicle * > myPTVehicles
List of vehicles which belong to public transport.
Definition: MSVehicleControl.h:630
MSVehicleControl::myScale
double myScale
The scaling factor (especially for inc-dua)
Definition: MSVehicleControl.h:621
MSVehicleControl::myTeleportsYield
int myTeleportsYield
The number of teleports due to vehicles stuck on a minor road.
Definition: MSVehicleControl.h:552
MSBaseVehicle::addStops
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
Definition: MSBaseVehicle.cpp:559
OptionsCont::getFloat
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
Definition: OptionsCont.cpp:209
SUMO_TAG_DELAY
Definition: SUMOXMLDefinitions.h:259
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:240
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
MSVehicleControl::getHaltingVehicleNo
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
Definition: MSVehicleControl.cpp:438
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
SUMO_ATTR_VTYPES
Definition: SUMOXMLDefinitions.h:630
MSVehicleType::build
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
Definition: MSVehicleType.cpp:282
MSVehicleControl::removePending
void removePending()
Removes a vehicle after it has ended.
Definition: MSVehicleControl.cpp:130
MSVehicleControl::myMinDeceleration
double myMinDeceleration
The minimum deceleration capability for all vehicles in the network.
Definition: MSVehicleControl.h:627
MSVehicleControl::MSVehicleControl
MSVehicleControl()
Constructor.
Definition: MSVehicleControl.cpp:49
MSRouteHandler::getParsingRNG
static std::mt19937 * getParsingRNG()
get parsing RNG
Definition: MSRouteHandler.h:63
MSVehicleControl::myCollisions
int myCollisions
The number of collisions.
Definition: MSVehicleControl.h:546
MSVehicleControl::myDefaultVTypeMayBeDeleted
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
Definition: MSVehicleControl.h:603
MSRoute::getStops
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
Definition: MSRoute.cpp:375
MSTransportable::getID
const std::string & getID() const
returns the id of the transportable
Definition: MSTransportable.cpp:694
ComparatorNumericalIdLess
Function-object for stable sorting of objects with numerical ids.
Definition: Named.h:42
MSEdge::getLanes
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:165
MSVehicleControl::getVehicleMeanSpeeds
virtual std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
Definition: MSVehicleControl.cpp:452
MSVehicleControl::myTeleportsWrongLane
int myTeleportsWrongLane
The number of teleports due to vehicles stuck on the wrong lane.
Definition: MSVehicleControl.h:555
MSVehicleControl::checkVType
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: MSVehicleControl.cpp:262
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:367
MSRoute::dictionary
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:114
config.h
MSVehicleControl::myPendingRemovals
std::vector< SUMOVehicle * > myPendingRemovals
List of vehicles which are going to be removed.
Definition: MSVehicleControl.h:639
SUMO_ATTR_END
weights: time range end
Definition: SUMOXMLDefinitions.h:677
HAVE_FOX
#define HAVE_FOX
Definition: config.h:38
MSVehicleControl::hasVType
bool hasVType(const std::string &id) const
Asks for existence of a vehicle type.
Definition: MSVehicleControl.cpp:336
MSVehicleControl::getWaitingVehicle
SUMOVehicle * getWaitingVehicle(MSTransportable *transportable, const MSEdge *const edge, const double position)
Definition: MSVehicleControl.cpp:409
MSVehicleControl::loadedVehBegin
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
Definition: MSVehicleControl.h:178
MSLane.h
MSVehicleControl::getTeleportCount
int getTeleportCount() const
return the number of teleports (including collisions)
Definition: MSVehicleControl.cpp:491
DEPART_CONTAINER_TRIGGERED
The departure is container triggered.
Definition: SUMOVehicleParameter.h:100
SUMOVehicleParameter::repetitionNumber
int repetitionNumber
Definition: SUMOVehicleParameter.h:538
IntermodalRouter::getNetwork
Network * getNetwork() const
Definition: IntermodalRouter.h:235
MSVehicleControl::myEndedVehNo
int myEndedVehNo
The number of removed vehicles.
Definition: MSVehicleControl.h:540
SVC_IGNORING
vehicles ignoring classes
Definition: SUMOVehicleClass.h:136
DEFAULT_BIKETYPE_ID
const std::string DEFAULT_BIKETYPE_ID
SUMOVTypeParameter.h
MSRouteHandler.h
SUMO_ATTR_NUMBER
Definition: SUMOXMLDefinitions.h:664
MSVehicleControl.h
OutputDevice::getDeviceByOption
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
Definition: OutputDevice.cpp:117
SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
Definition: SUMOXMLDefinitions.h:217
SUMOVehicleParameter::departPos
double departPos
(optional) The position the vehicle shall depart from
Definition: SUMOVehicleParameter.h:488
IntermodalRouter.h
RandomDistributor::getVals
const std::vector< T > & getVals() const
Returns the members of the distribution.
Definition: RandomDistributor.h:149
VTYPEPARS_VEHICLECLASS_SET
const int VTYPEPARS_VEHICLECLASS_SET
Definition: SUMOVTypeParameter.h:53
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:609
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:80
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:55