SUMO - Simulation of Urban MObility
MSInsertionControl Class Reference

Inserts vehicles into the network when their departure time is reached. More...

#include <MSInsertionControl.h>

Collaboration diagram for MSInsertionControl:
Collaboration graph

Data Structures

struct  Flow
 

Public Member Functions

void add (SUMOVehicle *veh)
 Adds a single vehicle for departure. More...
 
bool add (SUMOVehicleParameter *const pars)
 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 (std::string &route)
 clears out all pending vehicles from a route, "" for all routes More...
 
void descheduleDeparture (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...
 
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)
 Constructor. 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...
 
MSInsertionControloperator= (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< SUMOVehicle * > myAbortedEmits
 Set of vehicles which shall not be inserted anymore. More...
 
MSVehicleContainer myAllVeh
 All loaded vehicles sorted by their departure time. More...
 
bool myCheckEdgesOnce
 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::vector< FlowmyFlows
 Container for periodical vehicle parameters. More...
 
SUMOTime myMaxDepartDelay
 The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion) 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...
 
MSVehicleControlmyVehicleControl
 The assigned vehicle control (needed for vehicle re-insertion and deletion) More...
 

Detailed Description

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.

Todo:
When a vehicle is deleted due to waiting too long or because of vaporizing, this is not reported anywhere

Definition at line 67 of file MSInsertionControl.h.

Constructor & Destructor Documentation

§ MSInsertionControl() [1/2]

MSInsertionControl::MSInsertionControl ( MSVehicleControl vc,
SUMOTime  maxDepartDelay,
bool  checkEdgesOnce,
int  maxVehicleNumber 
)

Constructor.

Parameters
[in]vcThe assigned vehicle control (needed for vehicle re-insertion and deletion)
[in]maxDepartDelayVehicles waiting for insertion longer than this time are deleted (-1: no deletion)
[in]checkEdgesOnceWhether an edge on which a vehicle could not depart should be ignored in the same step
[in]maxVehicleNumberThe maximum number of vehicles that should not be exceeded

Definition at line 55 of file MSInsertionControl.cpp.

§ ~MSInsertionControl()

MSInsertionControl::~MSInsertionControl ( )

Destructor.

Definition at line 67 of file MSInsertionControl.cpp.

References myFlows.

§ MSInsertionControl() [2/2]

MSInsertionControl::MSInsertionControl ( const MSInsertionControl )
private

Invalidated copy constructor.

Member Function Documentation

§ add() [1/2]

void MSInsertionControl::add ( SUMOVehicle veh)

Adds a single vehicle for departure.

The vehicle is added to "myAllVeh".

Parameters
[in]vehThe vehicle to add for later insertion

Definition at line 75 of file MSInsertionControl.cpp.

References MSVehicleContainer::add(), and myAllVeh.

Referenced by MSRouteHandler::closeVehicle(), determineCandidates(), MSStateHandler::myStartElement(), MSContainer::MSContainerStage_Driving::proceed(), MSPerson::MSPersonStage_Driving::proceed(), and TraCIServerAPI_Vehicle::processSet().

§ add() [2/2]

bool MSInsertionControl::add ( SUMOVehicleParameter *const  pars)

Adds parameter for a vehicle flow for departure.

Parameters
[in]flowThe flow to add for later insertion
Returns
whether it could be added (no other flow with the same id was present)

Definition at line 81 of file MSInsertionControl.cpp.

References SUMOVehicleParameter::id, MSInsertionControl::Flow::index, myFlowIDs, myFlows, and MSInsertionControl::Flow::pars.

§ alreadyDeparted()

void MSInsertionControl::alreadyDeparted ( SUMOVehicle veh)

stops trying to emit the given vehicle (because it already departed)

Definition at line 263 of file MSInsertionControl.cpp.

References myAllVeh, myPendingEmits, and MSVehicleContainer::remove().

Referenced by TraCIServerAPI_Vehicle::processSet().

§ checkCandidates()

void MSInsertionControl::checkCandidates ( SUMOTime  time,
const bool  preCheck 
)
private

Adds all vehicles that should have been emitted earlier to the refuse container.

Parameters
[in]timeThe current simulation time
Todo:
recheck

Definition at line 157 of file MSInsertionControl.cpp.

References MSVehicleContainer::anyWaitingBefore(), DELTA_T, SUMOVehicle::getDevice(), SUMOVehicle::getEdge(), MSEdge::getLastFailedInsertionTime(), MSEdge::insertVehicle(), myAllVeh, myCheckEdgesOnce, myEmitCandidates, myPendingEmits, MSVehicleContainer::pop(), MSDevice_Routing::skipRouting(), and MSVehicleContainer::top().

Referenced by determineCandidates().

§ clearPendingVehicles()

void MSInsertionControl::clearPendingVehicles ( std::string &  route)

clears out all pending vehicles from a route, "" for all routes

Definition at line 270 of file MSInsertionControl.cpp.

References MSVehicleControl::deleteVehicle(), myPendingEmits, and myVehicleControl.

Referenced by TraCIServerAPI_Simulation::processSet().

§ descheduleDeparture()

void MSInsertionControl::descheduleDeparture ( SUMOVehicle veh)

stops trying to emit the given vehicle (and delete it)

Definition at line 257 of file MSInsertionControl.cpp.

References myAbortedEmits.

Referenced by MSLane::checkFailure(), MSEdge::insertVehicle(), and MSLane::isInsertionSuccess().

§ determineCandidates()

§ emitVehicles()

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.

Parameters
[in]timeThe current simulation time
Returns
The number of vehicles that could be inserted into the net

Definition at line 95 of file MSInsertionControl.cpp.

References MSDevice_Routing::isEnabled(), myEmitCandidates, myPendingEmits, and tryInsert().

Referenced by MSNet::simulationStep().

§ getPendingEmits()

int MSInsertionControl::getPendingEmits ( const MSLane lane)

§ getPendingFlowCount()

int MSInsertionControl::getPendingFlowCount ( ) const

Returns the number of flows that are still active.

Returns
number of active flows

Definition at line 251 of file MSInsertionControl.cpp.

References myFlows.

Referenced by MSNet::simulationState().

§ getWaitingVehicleNo()

int MSInsertionControl::getWaitingVehicleNo ( ) const

Returns the number of waiting vehicles.

The sizes of refused emits (sum of vehicles in "myRefusedEmits1" and "myRefusedEmits2") is returned.

Returns
The number of vehicles that could not (yet) be inserted into the net

Definition at line 245 of file MSInsertionControl.cpp.

References myPendingEmits.

Referenced by MSNet::closeSimulation(), GUINet::getParameterWindow(), GUIApplicationWindow::handleEvent_SimulationStep(), and MSNet::writeOutput().

§ operator=()

MSInsertionControl& MSInsertionControl::operator= ( const MSInsertionControl )
private

Invalidated assignment operator.

§ tryInsert()

int MSInsertionControl::tryInsert ( SUMOTime  time,
SUMOVehicle veh,
MSVehicleContainer::VehicleVector refusedEmits 
)
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.

Parameters
[in]timeThe current simulation time
[in]vehThe vehicle to emit
[in]refusedEmitsContainer to insert vehicles that could not be emitted into
Returns
The number of emitted vehicles (0 or 1)

Definition at line 124 of file MSInsertionControl.cpp.

References MSVehicleControl::deleteVehicle(), DELTA_T, SUMOVehicleParameter::depart, SUMOVehicle::getEdge(), MSNet::getInstance(), SUMOVehicle::getParameter(), SUMOVehicle::isOnRoad(), myAbortedEmits, myCheckEdgesOnce, myMaxDepartDelay, myMaxVehicleNumber, and myVehicleControl.

Referenced by emitVehicles().

Field Documentation

§ myAbortedEmits

std::set<SUMOVehicle*> MSInsertionControl::myAbortedEmits
private

Set of vehicles which shall not be inserted anymore.

Definition at line 196 of file MSInsertionControl.h.

Referenced by descheduleDeparture(), and tryInsert().

§ myAllVeh

MSVehicleContainer MSInsertionControl::myAllVeh
private

All loaded vehicles sorted by their departure time.

Definition at line 187 of file MSInsertionControl.h.

Referenced by add(), alreadyDeparted(), and checkCandidates().

§ myCheckEdgesOnce

bool MSInsertionControl::myCheckEdgesOnce
private

Whether an edge on which a vehicle could not depart should be ignored in the same step.

Definition at line 218 of file MSInsertionControl.h.

Referenced by checkCandidates(), and tryInsert().

§ myEmitCandidates

std::set<SUMOVehicle*> MSInsertionControl::myEmitCandidates
private

Buffer for vehicles that may be inserted in the current step.

Definition at line 193 of file MSInsertionControl.h.

Referenced by checkCandidates(), and emitVehicles().

§ myFlowIDs

std::set<std::string> MSInsertionControl::myFlowIDs
private

Cache for periodical vehicle ids for quicker checking.

Definition at line 212 of file MSInsertionControl.h.

Referenced by add().

§ myFlows

std::vector<Flow> MSInsertionControl::myFlows
private

Container for periodical vehicle parameters.

Definition at line 209 of file MSInsertionControl.h.

Referenced by add(), determineCandidates(), getPendingFlowCount(), and ~MSInsertionControl().

§ myMaxDepartDelay

SUMOTime MSInsertionControl::myMaxDepartDelay
private

The maximum waiting time; vehicles waiting longer are deleted (-1: no deletion)

Definition at line 215 of file MSInsertionControl.h.

Referenced by tryInsert().

§ myMaxVehicleNumber

int MSInsertionControl::myMaxVehicleNumber
private

Storage for maximum vehicle number.

Definition at line 221 of file MSInsertionControl.h.

Referenced by tryInsert().

§ myPendingEmits

MSVehicleContainer::VehicleVector MSInsertionControl::myPendingEmits
private

Buffers for vehicles that could not be inserted.

Definition at line 190 of file MSInsertionControl.h.

Referenced by alreadyDeparted(), checkCandidates(), clearPendingVehicles(), emitVehicles(), getPendingEmits(), and getWaitingVehicleNo().

§ myPendingEmitsForLane

std::map<const MSLane*, int> MSInsertionControl::myPendingEmitsForLane
private

the number of pending emits for each edge in the current time step

Definition at line 227 of file MSInsertionControl.h.

Referenced by getPendingEmits().

§ myPendingEmitsUpdateTime

SUMOTime MSInsertionControl::myPendingEmitsUpdateTime
private

Last time at which pending emits for each edge where counted.

Definition at line 224 of file MSInsertionControl.h.

Referenced by getPendingEmits().

§ myVehicleControl

MSVehicleControl& MSInsertionControl::myVehicleControl
private

The assigned vehicle control (needed for vehicle re-insertion and deletion)

Definition at line 184 of file MSInsertionControl.h.

Referenced by clearPendingVehicles(), and tryInsert().


The documentation for this class was generated from the following files: