![]() |
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 (MSNet::MSIntermodalRouter &router) const |
void | add (SUMOVehicle *veh) |
Adds a single vehicle for departure. More... | |
bool | addFlow (SUMOVehicleParameter *const pars, int index=-1) |
Adds parameter for a vehicle flow for departure. More... | |
void | alreadyDeparted (SUMOVehicle *veh) |
stops trying to emit the given vehicle (because it already departed) More... | |
void | clearPendingVehicles (const std::string &route) |
clears out all pending vehicles from a route, "" for all routes More... | |
SUMOTime | computeRandomDepartOffset () const |
compute (optional) random offset to the departure time More... | |
void | descheduleDeparture (const SUMOVehicle *veh) |
stops trying to emit the given vehicle (and delete it) More... | |
void | determineCandidates (SUMOTime time) |
Checks for all vehicles whether they can be emitted. More... | |
int | emitVehicles (SUMOTime time) |
Emits vehicles that want to depart at the given time. More... | |
std::mt19937 * | getFlowRNG () |
retrieve internal RNG More... | |
int | getPendingEmits (const MSLane *lane) |
return the number of pending emits for the given lane More... | |
int | getPendingFlowCount () const |
Returns the number of flows that are still active. More... | |
int | getWaitingVehicleNo () const |
Returns the number of waiting vehicles. More... | |
MSInsertionControl (MSVehicleControl &vc, SUMOTime maxDepartDelay, bool checkEdgesOnce, int maxVehicleNumber, SUMOTime randomDepartOffset) | |
Constructor. More... | |
void | saveState (OutputDevice &out) |
Saves the current state into the given stream. More... | |
~MSInsertionControl () | |
Destructor. More... | |
Private Member Functions | |
void | checkCandidates (SUMOTime time, const bool preCheck) |
Adds all vehicles that should have been emitted earlier to the refuse container. More... | |
MSInsertionControl (const MSInsertionControl &) | |
Invalidated copy constructor. More... | |
MSInsertionControl & | operator= (const MSInsertionControl &) |
Invalidated assignment operator. More... | |
int | tryInsert (SUMOTime time, SUMOVehicle *veh, MSVehicleContainer::VehicleVector &refusedEmits) |
Tries to emit the vehicle. More... | |
Private Attributes | |
std::set< const SUMOVehicle * > | myAbortedEmits |
Set of vehicles which shall not be inserted anymore. More... | |
MSVehicleContainer | myAllVeh |
All loaded vehicles sorted by their departure time. More... | |
bool | myEagerInsertionCheck |
Whether an edge on which a vehicle could not depart should be ignored in the same step. More... | |
std::set< SUMOVehicle * > | myEmitCandidates |
Buffer for vehicles that may be inserted in the current step. More... | |
std::set< std::string > | myFlowIDs |
Cache for periodical vehicle ids for quicker checking. More... | |
std::mt19937 | myFlowRNG |
A random number generator for probabilistic flows. More... | |
std::vector< Flow > | myFlows |
Container for periodical vehicle parameters. More... | |
SUMOTime | myMaxDepartDelay |
The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion) More... | |
SUMOTime | myMaxRandomDepartOffset |
The maximum random offset to be added to vehicles departure times (non-negative) More... | |
int | myMaxVehicleNumber |
Storage for maximum vehicle number. More... | |
MSVehicleContainer::VehicleVector | myPendingEmits |
Buffers for vehicles that could not be inserted. More... | |
std::map< const MSLane *, int > | myPendingEmitsForLane |
the number of pending emits for each edge in the current time step More... | |
SUMOTime | myPendingEmitsUpdateTime |
Last time at which pending emits for each edge where counted. More... | |
MSVehicleControl & | myVehicleControl |
The assigned vehicle control (needed for vehicle re-insertion and deletion) More... | |
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 48 of file MSInsertionControl.cpp.
References RandHelper::initRandGlobal(), myFlowRNG, and myMaxRandomDepartOffset.
MSInsertionControl::~MSInsertionControl | ( | ) |
|
private |
Invalidated copy constructor.
void MSInsertionControl::adaptIntermodalRouter | ( | MSNet::MSIntermodalRouter & | router | ) | const |
Definition at line 325 of file MSInsertionControl.cpp.
References IntermodalNetwork< E, L, N, V >::addSchedule(), MSRoute::dictionary(), IntermodalRouter< E, L, N, V >::getNetwork(), MSRoute::getStops(), 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::Vehicle::add(), MSRouteHandler::closeVehicle(), determineCandidates(), MSContainer::MSContainerStage_Driving::proceed(), and MSPerson::MSPersonStage_Driving::proceed().
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, MSInsertionControl::Flow::index, myFlowIDs, myFlows, SUMOVehicleParameter::parametersSet, MSInsertionControl::Flow::pars, and VEHPARS_FORCE_REROUTE.
Referenced by MSStateHandler::myStartElement().
void MSInsertionControl::alreadyDeparted | ( | SUMOVehicle * | veh | ) |
stops trying to emit the given vehicle (because it already departed)
Definition at line 278 of file MSInsertionControl.cpp.
References myAllVeh, myPendingEmits, and MSVehicleContainer::remove().
Referenced by MSStateHandler::closeVehicle(), MSVehicleTransfer::loadState(), libsumo::Vehicle::moveTo(), libsumo::Vehicle::moveToXY(), and libsumo::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 171 of file MSInsertionControl.cpp.
References MSVehicleContainer::anyWaitingBefore(), DELTA_T, SUMOVehicle::getDevice(), SUMOTrafficObject::getEdge(), MSEdge::insertVehicle(), myAllVeh, myEagerInsertionCheck, myEmitCandidates, myPendingEmits, MSVehicleContainer::pop(), MSDevice_Routing::skipRouting(), and MSVehicleContainer::top().
Referenced by determineCandidates(), and getFlowRNG().
void MSInsertionControl::clearPendingVehicles | ( | const std::string & | route | ) |
clears out all pending vehicles from a route, "" for all routes
Definition at line 285 of file MSInsertionControl.cpp.
References MSVehicleControl::deleteVehicle(), myPendingEmits, and myVehicleControl.
Referenced by libsumo::Simulation::clearPending().
SUMOTime MSInsertionControl::computeRandomDepartOffset | ( | ) | const |
compute (optional) random offset to the departure time
Definition at line 352 of file MSInsertionControl.cpp.
References DELTA_T, MSRouteHandler::getParsingRNG(), myMaxRandomDepartOffset, and RandHelper::rand().
Referenced by MSRouteHandler::closeVehicle(), and determineCandidates().
void MSInsertionControl::descheduleDeparture | ( | const SUMOVehicle * | veh | ) |
stops trying to emit the given vehicle (and delete it)
Definition at line 272 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 196 of file MSInsertionControl.cpp.
References add(), MSVehicleControl::addVehicle(), MSVehicleControl::buildVehicle(), checkCandidates(), MSRoute::checkDist(), computeRandomDepartOffset(), MSVehicleControl::deleteVehicle(), DELTA_T, SUMOVehicleParameter::depart, MSRoute::dictionary(), MSVehicleControl::discountStateLoaded(), MSGlobals::gCheckRoutes, MSNet::getInstance(), MSRouteHandler::getParsingRNG(), MSVehicleControl::getQuota(), MSVehicleControl::getVehicle(), MSNet::getVehicleControl(), MSVehicleControl::getVType(), MSGlobals::gStateLoaded, SUMOVehicleParameter::id, MSRoutingEngine::isEnabled(), myFlowRNG, myFlows, RandHelper::rand(), SUMOVehicleParameter::repetitionEnd, SUMOVehicleParameter::repetitionNumber, SUMOVehicleParameter::repetitionOffset, SUMOVehicleParameter::repetitionProbability, SUMOVehicleParameter::repetitionsDone, SUMOVehicleParameter::routeid, 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 110 of file MSInsertionControl.cpp.
References MSRoutingEngine::isEnabled(), myEmitCandidates, myPendingEmits, and tryInsert().
Referenced by MSNet::simulationStep().
|
inline |
retrieve internal RNG
Definition at line 161 of file MSInsertionControl.h.
References checkCandidates(), myFlowRNG, and tryInsert().
Referenced by MSStateHandler::myStartElement().
int MSInsertionControl::getPendingEmits | ( | const MSLane * | lane | ) |
return the number of pending emits for the given lane
Definition at line 300 of file MSInsertionControl.cpp.
References MSNet::getCurrentTimeStep(), MSNet::getInstance(), MSEdge::getLanes(), myPendingEmits, myPendingEmitsForLane, and myPendingEmitsUpdateTime.
Referenced by GUIEdge::getColorValue(), GUILane::getPendingEmits(), GUIEdge::getScaleValue(), and GUILane::getScaleValue().
int MSInsertionControl::getPendingFlowCount | ( | ) | const |
Returns the number of flows that are still active.
Definition at line 266 of file MSInsertionControl.cpp.
References myFlows.
Referenced by libsumo::Simulation::getMinExpectedNumber(), and MSNet::simulationState().
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 260 of file MSInsertionControl.cpp.
References myPendingEmits.
Referenced by MSNet::generateStatistics(), GUINet::getParameterWindow(), GUIApplicationWindow::handleEvent_SimulationStep(), MSNet::postSimStepOutput(), and MSNet::writeOutput().
|
private |
Invalidated assignment operator.
void MSInsertionControl::saveState | ( | OutputDevice & | out | ) |
Saves the current state into the given stream.
Definition at line 337 of file MSInsertionControl.cpp.
References OutputDevice::closeTag(), myFlows, OutputDevice::openTag(), SUMO_ATTR_ID, SUMO_ATTR_INDEX, SUMO_ATTR_REROUTE, SUMO_TAG_FLOWSTATE, 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 139 of file MSInsertionControl.cpp.
References MSVehicleControl::deleteVehicle(), DELTA_T, SUMOVehicleParameter::depart, SUMOTrafficObject::getEdge(), MSNet::getInstance(), SUMOVehicle::getParameter(), SUMOVehicle::isOnRoad(), myAbortedEmits, myEagerInsertionCheck, myMaxDepartDelay, myMaxVehicleNumber, and myVehicleControl.
Referenced by emitVehicles(), and getFlowRNG().
|
private |
Set of vehicles which shall not be inserted anymore.
Definition at line 207 of file MSInsertionControl.h.
Referenced by descheduleDeparture(), and tryInsert().
|
private |
All loaded vehicles sorted by their departure time.
Definition at line 198 of file MSInsertionControl.h.
Referenced by add(), alreadyDeparted(), and checkCandidates().
|
private |
Whether an edge on which a vehicle could not depart should be ignored in the same step.
Definition at line 229 of file MSInsertionControl.h.
Referenced by checkCandidates(), and tryInsert().
|
private |
Buffer for vehicles that may be inserted in the current step.
Definition at line 204 of file MSInsertionControl.h.
Referenced by checkCandidates(), and emitVehicles().
|
private |
Cache for periodical vehicle ids for quicker checking.
Definition at line 223 of file MSInsertionControl.h.
Referenced by addFlow().
|
private |
A random number generator for probabilistic flows.
Definition at line 251 of file MSInsertionControl.h.
Referenced by determineCandidates(), getFlowRNG(), and MSInsertionControl().
|
private |
Container for periodical vehicle parameters.
Definition at line 220 of file MSInsertionControl.h.
Referenced by adaptIntermodalRouter(), addFlow(), determineCandidates(), getPendingFlowCount(), saveState(), and ~MSInsertionControl().
|
private |
The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion)
Definition at line 226 of file MSInsertionControl.h.
Referenced by tryInsert().
|
private |
The maximum random offset to be added to vehicles departure times (non-negative)
Definition at line 241 of file MSInsertionControl.h.
Referenced by computeRandomDepartOffset(), and MSInsertionControl().
|
private |
Storage for maximum vehicle number.
Definition at line 232 of file MSInsertionControl.h.
Referenced by tryInsert().
|
private |
Buffers for vehicles that could not be inserted.
Definition at line 201 of file MSInsertionControl.h.
Referenced by alreadyDeparted(), checkCandidates(), clearPendingVehicles(), emitVehicles(), getPendingEmits(), and getWaitingVehicleNo().
|
private |
the number of pending emits for each edge in the current time step
Definition at line 238 of file MSInsertionControl.h.
Referenced by getPendingEmits().
|
private |
Last time at which pending emits for each edge where counted.
Definition at line 235 of file MSInsertionControl.h.
Referenced by getPendingEmits().
|
private |
The assigned vehicle control (needed for vehicle re-insertion and deletion)
Definition at line 195 of file MSInsertionControl.h.
Referenced by clearPendingVehicles(), and tryInsert().