Eclipse SUMO - Simulation of Urban MObility
|
Inserts vehicles into the network when their departure time is reached. More...
#include <MSInsertionControl.h>
Data Structures | |
struct | Flow |
Definition of vehicle flow with the current index for vehicle numbering. More... | |
Public Member Functions | |
void | adaptIntermodalRouter (MSTransportableRouter &router) const |
void | add (SUMOVehicle *veh) |
Adds a single vehicle for departure. | |
bool | addFlow (SUMOVehicleParameter *const pars, int index=-1) |
Adds parameter for a vehicle flow for departure. | |
void | alreadyDeparted (SUMOVehicle *veh) |
stops trying to emit the given vehicle (because it already departed) | |
void | clearPendingVehicles (const std::string &route) |
clears out all pending vehicles from a route, "" for all routes | |
void | clearState () |
Remove all vehicles before quick-loading state. | |
SUMOTime | computeRandomDepartOffset () const |
compute (optional) random offset to the departure time | |
void | descheduleDeparture (const SUMOVehicle *veh) |
stops trying to emit the given vehicle (and delete it) | |
void | determineCandidates (SUMOTime time) |
Checks for all vehicles whether they can be emitted. | |
int | emitVehicles (SUMOTime time) |
Emits vehicles that want to depart at the given time. | |
const SUMOVehicleParameter * | getFlowPars (const std::string &id) const |
return parameters for the given flow | |
SumoRNG * | getFlowRNG () |
retrieve internal RNG | |
SUMOVehicle * | getLastFlowVehicle (const std::string &id) const |
return the last vehicle for the given flow | |
int | getPendingEmits (const MSLane *lane) |
return the number of pending emits for the given lane | |
int | getPendingFlowCount () const |
Returns the number of flows that are still active. | |
const MSVehicleContainer::VehicleVector & | getPendingVehicles () const |
retrieve vehicles waiting for insertion | |
int | getWaitingVehicleNo () const |
Returns the number of waiting vehicles. | |
bool | hasFlow (const std::string &id) const |
checks whether the given flow still exists | |
MSInsertionControl (MSVehicleControl &vc, SUMOTime maxDepartDelay, bool checkEdgesOnce, int maxVehicleNumber, SUMOTime randomDepartOffset) | |
Constructor. | |
void | retractDescheduleDeparture (const SUMOVehicle *veh) |
reverts a previous call to descheduleDeparture (only needed for departPos="random_free") | |
void | saveState (OutputDevice &out) |
Saves the current state into the given stream. | |
void | updateScale (const std::string vtypeid) |
updates the flow scale value to keep track of TraCI-induced change | |
~MSInsertionControl () | |
Destructor. | |
Private Member Functions | |
void | checkCandidates (SUMOTime time, const bool preCheck) |
Adds all vehicles that should have been emitted earlier to the refuse container. | |
MSInsertionControl (const MSInsertionControl &) | |
Invalidated copy constructor. | |
MSInsertionControl & | operator= (const MSInsertionControl &) |
Invalidated assignment operator. | |
int | tryInsert (SUMOTime time, SUMOVehicle *veh, MSVehicleContainer::VehicleVector &refusedEmits) |
Tries to emit the vehicle. | |
Static Private Member Functions | |
static double | initScale (const std::string vtypeid) |
init scale value of flow | |
Private Attributes | |
std::set< const SUMOVehicle * > | myAbortedEmits |
Set of vehicles which shall not be inserted anymore. | |
MSVehicleContainer | myAllVeh |
All loaded vehicles sorted by their departure time. | |
bool | myEagerInsertionCheck |
Whether an edge on which a vehicle could not depart should be ignored in the same step. | |
std::set< SUMOVehicle * > | myEmitCandidates |
Buffer for vehicles that may be inserted in the current step. | |
std::map< std::string, int > | myFlowIDs |
Cache for periodical vehicle ids and their most recent index for quicker checking. | |
SumoRNG | myFlowRNG |
A random number generator for probabilistic flows. | |
std::vector< Flow > | myFlows |
Container for periodical vehicle parameters. | |
SUMOTime | myMaxDepartDelay |
The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion) | |
SUMOTime | myMaxRandomDepartOffset |
The maximum random offset to be added to vehicles departure times (non-negative) | |
int | myMaxVehicleNumber |
Storage for maximum vehicle number. | |
MSVehicleContainer::VehicleVector | myPendingEmits |
Buffers for vehicles that could not be inserted. | |
std::map< const MSLane *, int > | myPendingEmitsForLane |
the number of pending emits for each edge in the current time step | |
SUMOTime | myPendingEmitsUpdateTime |
Last time at which pending emits for each edge where counted. | |
MSVehicleControl & | myVehicleControl |
The assigned vehicle control (needed for vehicle re-insertion and deletion) | |
Inserts vehicles into the network when their departure time is reached.
Holds a list of vehicles which may be filled by vehicles read by SUMORouteLoaders. Tries to emit vehicles departing at a time into the network as soon this time is reached and keeps them as long the insertion fails.
If a vehicle is emitted, the control about it is given to the lanes.
Vehicles are not controlled (created, deleted) by this class.
Definition at line 62 of file MSInsertionControl.h.
MSInsertionControl::MSInsertionControl | ( | MSVehicleControl & | vc, |
SUMOTime | maxDepartDelay, | ||
bool | checkEdgesOnce, | ||
int | maxVehicleNumber, | ||
SUMOTime | randomDepartOffset | ||
) |
Constructor.
[in] | vc | The assigned vehicle control (needed for vehicle re-insertion and deletion) |
[in] | maxDepartDelay | Vehicles waiting for insertion longer than this time are deleted (-1: no deletion) |
[in] | checkEdgesOnce | Whether an edge on which a vehicle could not depart should be ignored in the same step |
[in] | maxVehicleNumber | The maximum number of vehicles that should not be exceeded |
Definition at line 47 of file MSInsertionControl.cpp.
References RandHelper::initRandGlobal(), myFlowRNG, and myMaxRandomDepartOffset.
MSInsertionControl::~MSInsertionControl | ( | ) |
|
private |
Invalidated copy constructor.
void MSInsertionControl::adaptIntermodalRouter | ( | MSTransportableRouter & | router | ) | const |
Definition at line 371 of file MSInsertionControl.cpp.
References IntermodalNetwork< E, L, N, V >::addSchedule(), MSRoute::dictionary(), IntermodalRouter< E, L, N, V >::getNetwork(), and myFlows.
Referenced by MSNet::adaptIntermodalRouter().
void MSInsertionControl::add | ( | SUMOVehicle * | veh | ) |
Adds a single vehicle for departure.
The vehicle is added to "myAllVeh".
[in] | veh | The vehicle to add for later insertion |
Definition at line 71 of file MSInsertionControl.cpp.
References MSVehicleContainer::add(), and myAllVeh.
Referenced by LIBSUMO_NAMESPACE::Vehicle::add(), MSRouteHandler::closeVehicle(), determineCandidates(), MSStageDriving::proceed(), MSVehicle::processNextStop(), and MSDevice_FCDReplay::FCDHandler::updateTrafficObjects().
bool MSInsertionControl::addFlow | ( | SUMOVehicleParameter *const | pars, |
int | index = -1 |
||
) |
Adds parameter for a vehicle flow for departure.
[in] | pars | The flow parameters to add for later insertion |
[in] | index | The current index when loading this flow from a simulation state |
Definition at line 77 of file MSInsertionControl.cpp.
References SUMOVehicleParameter::id, SUMOVehicleParameter::incrementFlow(), initScale(), myFlowIDs, myFlowRNG, myFlows, SUMOVehicleParameter::repetitionOffset, SUMOVehicleParameter::repetitionProbability, and SUMOVehicleParameter::vtypeid.
Referenced by MSStateHandler::myStartElement().
void MSInsertionControl::alreadyDeparted | ( | SUMOVehicle * | veh | ) |
stops trying to emit the given vehicle (because it already departed)
Definition at line 326 of file MSInsertionControl.cpp.
References myAllVeh, myPendingEmits, and MSVehicleContainer::remove().
Referenced by MSStateHandler::closeVehicle(), MSVehicleTransfer::loadState(), LIBSUMO_NAMESPACE::Vehicle::moveTo(), LIBSUMO_NAMESPACE::Vehicle::moveToXY(), and LIBSUMO_NAMESPACE::Vehicle::remove().
|
private |
Adds all vehicles that should have been emitted earlier to the refuse container.
[in] | time | The current simulation time |
Definition at line 192 of file MSInsertionControl.cpp.
References MSVehicleContainer::anyWaitingBefore(), SUMOTrafficObject::getDevice(), SUMOTrafficObject::getEdge(), MSEdge::insertVehicle(), myAllVeh, myEagerInsertionCheck, myEmitCandidates, myPendingEmits, MSVehicleContainer::pop(), MSDevice_Routing::skipRouting(), and MSVehicleContainer::top().
Referenced by determineCandidates().
void MSInsertionControl::clearPendingVehicles | ( | const std::string & | route | ) |
clears out all pending vehicles from a route, "" for all routes
Definition at line 333 of file MSInsertionControl.cpp.
References MSVehicleControl::deleteVehicle(), myPendingEmits, and myVehicleControl.
Referenced by LIBSUMO_NAMESPACE::Simulation::clearPending().
void MSInsertionControl::clearState | ( | ) |
Remove all vehicles before quick-loading state.
Definition at line 415 of file MSInsertionControl.cpp.
References MSVehicleContainer::clearState(), myAbortedEmits, myAllVeh, myEmitCandidates, myFlowIDs, myFlows, and myPendingEmits.
Referenced by MSNet::clearState().
SUMOTime MSInsertionControl::computeRandomDepartOffset | ( | ) | const |
compute (optional) random offset to the departure time
Definition at line 430 of file MSInsertionControl.cpp.
References DELTA_T, MSRouteHandler::getParsingRNG(), myMaxRandomDepartOffset, and RandHelper::rand().
Referenced by MSRouteHandler::addFlowTransportable(), MSRouteHandler::closeVehicle(), and determineCandidates().
void MSInsertionControl::descheduleDeparture | ( | const SUMOVehicle * | veh | ) |
stops trying to emit the given vehicle (and delete it)
Definition at line 315 of file MSInsertionControl.cpp.
References myAbortedEmits.
Referenced by MSLane::checkFailure(), MSLane::isInsertionSuccess(), and MSBaseVehicle::reroute().
void MSInsertionControl::determineCandidates | ( | SUMOTime | time | ) |
Checks for all vehicles whether they can be emitted.
[in] | time | The current simulation time |
Definition at line 217 of file MSInsertionControl.cpp.
References add(), MSVehicleControl::addVehicle(), BEGIN, MSVehicleControl::buildVehicle(), checkCandidates(), MSRoute::checkDist(), computeRandomDepartOffset(), MSVehicleControl::deleteVehicle(), SUMOVehicleParameter::depart, SUMOVehicleParameter::departProcedure, MSRoute::dictionary(), MSGlobals::gCheckRoutes, MSNet::getInstance(), MSVehicleType::getParameter(), MSRouteHandler::getParsingRNG(), MSVehicleControl::getQuota(), MSVehicleControl::getScale(), MSVehicleControl::getVehicle(), MSNet::getVehicleControl(), MSVehicleControl::getVType(), GIVEN, MSGlobals::gStateLoaded, SUMOVehicleParameter::id, SUMOVehicleParameter::incrementFlow(), MSRoutingEngine::isEnabled(), myFlowIDs, myFlowRNG, myFlows, RandHelper::rand(), SUMOVehicleParameter::repetitionEnd, SUMOVehicleParameter::repetitionNumber, SUMOVehicleParameter::repetitionProbability, SUMOVehicleParameter::repetitionsDone, SUMOVehicleParameter::repetitionTotalOffset, SUMOVehicleParameter::routeid, SUMOVTypeParameter::scale, TLF, toString(), TS, and SUMOVehicleParameter::vtypeid.
Referenced by MSNet::simulationStep().
int MSInsertionControl::emitVehicles | ( | SUMOTime | time | ) |
Emits vehicles that want to depart at the given time.
All vehicles scheduled for this time are tried to be emitted. This includes those with a depart time as the given time and those that wait for being emitted due they could not be inserted in previous steps.
For each vehicle, tryInsert is called. If this fails, a vehicle keeps within the refused emit containers ("myRefusedEmits1", "myRefusedEmits2") so that it may be emitted within the next steps.
Returns the number of vehicles that could be inserted into the net.
[in] | time | The current simulation time |
Definition at line 127 of file MSInsertionControl.cpp.
References MSRoutingEngine::isEnabled(), myEmitCandidates, myPendingEmits, and tryInsert().
Referenced by MSNet::simulationStep().
const SUMOVehicleParameter * MSInsertionControl::getFlowPars | ( | const std::string & | id | ) | const |
return parameters for the given flow
Definition at line 439 of file MSInsertionControl.cpp.
References hasFlow(), and myFlows.
Referenced by MSRouteHandler::addRideOrTransport().
|
inline |
retrieve internal RNG
Definition at line 170 of file MSInsertionControl.h.
References myFlowRNG.
Referenced by MSStateHandler::myStartElement().
SUMOVehicle * MSInsertionControl::getLastFlowVehicle | ( | const std::string & | id | ) | const |
return the last vehicle for the given flow
Definition at line 451 of file MSInsertionControl.cpp.
References MSNet::getInstance(), MSVehicleControl::getVehicle(), MSNet::getVehicleControl(), myFlowIDs, and toString().
Referenced by MSStageDriving::proceed().
int MSInsertionControl::getPendingEmits | ( | const MSLane * | lane | ) |
return the number of pending emits for the given lane
Definition at line 348 of file MSInsertionControl.cpp.
References MSNet::getCurrentTimeStep(), MSNet::getInstance(), myPendingEmits, myPendingEmitsForLane, and myPendingEmitsUpdateTime.
Referenced by GUIEdge::getPendingEmits(), GUILane::getPendingEmits(), and GUILane::getScaleValue().
int MSInsertionControl::getPendingFlowCount | ( | ) | const |
Returns the number of flows that are still active.
Definition at line 309 of file MSInsertionControl.cpp.
References myFlows.
Referenced by LIBSUMO_NAMESPACE::Simulation::getMinExpectedNumber(), and MSNet::simulationState().
|
inline |
retrieve vehicles waiting for insertion
Definition at line 125 of file MSInsertionControl.h.
References myPendingEmits.
Referenced by LIBSUMO_NAMESPACE::Simulation::getPendingVehicles(), LIBSUMO_NAMESPACE::Edge::getPendingVehicles(), and LIBSUMO_NAMESPACE::Lane::getPendingVehicles().
int MSInsertionControl::getWaitingVehicleNo | ( | ) | const |
Returns the number of waiting vehicles.
The sizes of refused emits (sum of vehicles in "myRefusedEmits1" and "myRefusedEmits2") is returned.
Definition at line 303 of file MSInsertionControl.cpp.
References myPendingEmits.
Referenced by MSNet::generateStatistics(), GUINet::getParameterWindow(), GUIApplicationWindow::handleEvent_SimulationStep(), MSNet::postSimStepOutput(), MSNet::writeStatistics(), and MSNet::writeSummaryOutput().
|
inline |
checks whether the given flow still exists
Definition at line 175 of file MSInsertionControl.h.
References myFlowIDs.
Referenced by getFlowPars(), and MSNet::hasFlow().
|
staticprivate |
init scale value of flow
Definition at line 95 of file MSInsertionControl.cpp.
References MSNet::getInstance(), MSVehicleType::getParameter(), RandomDistributor< T >::getVals(), MSNet::getVehicleControl(), MSVehicleControl::getVType(), MSVehicleControl::getVTypeDistribution(), MSVehicleControl::hasVTypeDistribution(), and SUMOVTypeParameter::scale.
Referenced by addFlow(), and updateScale().
|
private |
Invalidated assignment operator.
void MSInsertionControl::retractDescheduleDeparture | ( | const SUMOVehicle * | veh | ) |
reverts a previous call to descheduleDeparture (only needed for departPos="random_free")
Definition at line 320 of file MSInsertionControl.cpp.
References myAbortedEmits.
Referenced by MSLane::insertVehicle().
void MSInsertionControl::saveState | ( | OutputDevice & | out | ) |
Saves the current state into the given stream.
Definition at line 383 of file MSInsertionControl.cpp.
References OutputDevice::closeTag(), DEFAULT_VTYPE_ID, OptionsCont::getOptions(), myFlows, STEPS2TIME, SUMO_ATTR_DONE, SUMO_ATTR_END, SUMO_ATTR_INDEX, SUMO_ATTR_NEXT, SUMO_ATTR_NUMBER, SUMO_ATTR_PERIOD, SUMO_ATTR_PROB, SUMO_ATTR_REROUTE, SUMO_ATTR_ROUTE, SUMO_TAG_FLOWSTATE, SUMOTime_MAX, toString(), VEHPARS_FORCE_REROUTE, and OutputDevice::writeAttr().
Referenced by MSStateHandler::saveState().
|
private |
Tries to emit the vehicle.
If the insertion fails, it is examined whether the reason was a vaporizing edge. If so, the vehicle is deleted. Otherwise, it is checked whether the time the vehicle had to wait so far is larger than the maximum allowed waiting time. If so, the vehicle is deleted, too. If both does not match, the vehicle is reinserted to "refusedEmits" in order to be emitted in next steps.
[in] | time | The current simulation time |
[in] | veh | The vehicle to emit |
[in] | refusedEmits | Container to insert vehicles that could not be emitted into |
Definition at line 156 of file MSInsertionControl.cpp.
References MSVehicleControl::deleteVehicle(), SUMOVehicleParameter::depart, SUMOVehicleParameter::departProcedure, SUMOTrafficObject::getEdge(), MSNet::getInstance(), SUMOTrafficObject::getParameter(), SUMOVehicle::getRouteValidity(), MSEdge::insertVehicle(), SUMOVehicle::isOnRoad(), MSEdge::isVaporizing(), myAbortedEmits, myEagerInsertionCheck, myMaxDepartDelay, myMaxVehicleNumber, myVehicleControl, MSBaseVehicle::ROUTE_START_INVALID_LANE, MSBaseVehicle::ROUTE_START_INVALID_PERMISSIONS, MSEdge::setLastFailedInsertionTime(), and SPLIT.
Referenced by emitVehicles().
void MSInsertionControl::updateScale | ( | const std::string | vtypeid | ) |
updates the flow scale value to keep track of TraCI-induced change
Definition at line 117 of file MSInsertionControl.cpp.
References initScale(), and myFlows.
Referenced by MSVehicleType::setScale().
|
private |
Set of vehicles which shall not be inserted anymore.
Definition at line 238 of file MSInsertionControl.h.
Referenced by clearState(), descheduleDeparture(), retractDescheduleDeparture(), and tryInsert().
|
private |
All loaded vehicles sorted by their departure time.
Definition at line 225 of file MSInsertionControl.h.
Referenced by add(), alreadyDeparted(), checkCandidates(), and clearState().
|
private |
Whether an edge on which a vehicle could not depart should be ignored in the same step.
Definition at line 263 of file MSInsertionControl.h.
Referenced by checkCandidates(), and tryInsert().
|
private |
Buffer for vehicles that may be inserted in the current step.
Definition at line 231 of file MSInsertionControl.h.
Referenced by checkCandidates(), clearState(), and emitVehicles().
|
private |
Cache for periodical vehicle ids and their most recent index for quicker checking.
Definition at line 257 of file MSInsertionControl.h.
Referenced by addFlow(), clearState(), determineCandidates(), getLastFlowVehicle(), and hasFlow().
|
private |
A random number generator for probabilistic flows.
Definition at line 285 of file MSInsertionControl.h.
Referenced by addFlow(), determineCandidates(), getFlowRNG(), and MSInsertionControl().
|
private |
Container for periodical vehicle parameters.
Definition at line 254 of file MSInsertionControl.h.
Referenced by adaptIntermodalRouter(), addFlow(), clearState(), determineCandidates(), getFlowPars(), getPendingFlowCount(), saveState(), updateScale(), and ~MSInsertionControl().
|
private |
The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion)
Definition at line 260 of file MSInsertionControl.h.
Referenced by tryInsert().
|
private |
The maximum random offset to be added to vehicles departure times (non-negative)
Definition at line 275 of file MSInsertionControl.h.
Referenced by computeRandomDepartOffset(), and MSInsertionControl().
|
private |
Storage for maximum vehicle number.
Definition at line 266 of file MSInsertionControl.h.
Referenced by tryInsert().
|
private |
Buffers for vehicles that could not be inserted.
Definition at line 228 of file MSInsertionControl.h.
Referenced by alreadyDeparted(), checkCandidates(), clearPendingVehicles(), clearState(), emitVehicles(), getPendingEmits(), getPendingVehicles(), and getWaitingVehicleNo().
|
private |
the number of pending emits for each edge in the current time step
Definition at line 272 of file MSInsertionControl.h.
Referenced by getPendingEmits().
|
private |
Last time at which pending emits for each edge where counted.
Definition at line 269 of file MSInsertionControl.h.
Referenced by getPendingEmits().
|
private |
The assigned vehicle control (needed for vehicle re-insertion and deletion)
Definition at line 222 of file MSInsertionControl.h.
Referenced by clearPendingVehicles(), and tryInsert().