Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MELoop Class Reference

The main mesocopic simulation loop. More...

#include <MELoop.h>

Public Member Functions

void addLeaderCar (MEVehicle *veh, MSLink *link)
 Adds the given car to the leading vehicles.
 
void buildSegmentsFor (const MSEdge &e, const OptionsCont &oc)
 Build the segments for a given edge.
 
SUMOTime changeSegment (MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, MSMoveReminder::Notification reason, const bool ignoreLink=false) const
 change to the next segment this handles combinations of the following cases: (ending / continuing route) and (leaving segment / finishing teleport)
 
void clearState ()
 Remove all vehicles before quick-loading state.
 
MESegmentgetSegmentForEdge (const MSEdge &e, double pos=0)
 Get the segment for a given edge at a given position.
 
 MELoop (const SUMOTime recheckInterval)
 SUMO constructor.
 
bool removeLeaderCar (MEVehicle *v)
 Removes the given car from the leading vehicles.
 
void simulate (SUMOTime tMax)
 Perform simulation up to the given time.
 
void updateSegmentsForEdge (const MSEdge &e)
 Update segments after loading meso edge type parameters from additional file.
 
void vaporizeCar (MEVehicle *v, MSMoveReminder::Notification reason)
 remove the given car and clean up the relevant data structures
 
 ~MELoop ()
 

Static Public Member Functions

static bool isEnteringRoundabout (const MSEdge &e)
 whether the given edge is entering a roundabout
 
static int numSegmentsFor (const double length, const double slength)
 Compute number of segments per edge (best value stay close to the configured segment length)
 

Private Member Functions

void checkCar (MEVehicle *veh)
 Check whether the vehicle may move.
 
 MELoop (const MELoop &)
 Invalidated copy constructor.
 
MESegmentnextSegment (MESegment *s, MEVehicle *v)
 Retrieve next segment.
 
MELoopoperator= (const MELoop &)
 Invalidated assignment operator.
 
void teleportVehicle (MEVehicle *veh, MESegment *const toSegment, bool disconnected)
 teleports a vehicle or continues a teleport
 

Private Attributes

std::vector< MESegment * > myEdges2FirstSegments
 mapping from internal edge ids to their initial segments
 
const SUMOTime myFullRecheckInterval
 the interval at which to recheck at full segments (<=0 means asap)
 
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
 leader cars in the segments sorted by exit time
 
const SUMOTime myLinkRecheckInterval
 the interval at which to recheck at blocked junctions (<=0 means asap)
 

Detailed Description

The main mesocopic simulation loop.

Definition at line 47 of file MELoop.h.

Constructor & Destructor Documentation

◆ MELoop() [1/2]

MELoop::MELoop ( const SUMOTime  recheckInterval)

SUMO constructor.

Definition at line 46 of file MELoop.cpp.

◆ ~MELoop()

MELoop::~MELoop ( )

Definition at line 49 of file MELoop.cpp.

References MESegment::getNextSegment(), and myEdges2FirstSegments.

◆ MELoop() [2/2]

MELoop::MELoop ( const MELoop )
private

Invalidated copy constructor.

Member Function Documentation

◆ addLeaderCar()

void MELoop::addLeaderCar ( MEVehicle veh,
MSLink link 
)

Adds the given car to the leading vehicles.

Parameters
[in]vehthe car which became a leading one
[in]linkthe link on which the car shall register its approach

Definition at line 238 of file MELoop.cpp.

References MEVehicle::getEventTime(), myLeaderCars, and MEVehicle::setApproaching().

Referenced by checkCar(), MESegment::loadState(), MEVehicle::loadState(), MESegment::receive(), MEVehicle::resumeFromStopping(), MESegment::send(), MESegment::setSpeedForQueue(), and teleportVehicle().

Here is the caller graph for this function:

◆ buildSegmentsFor()

void MELoop::buildSegmentsFor ( const MSEdge e,
const OptionsCont oc 
)

Build the segments for a given edge.

Parameters
[in]ethe edge to build for

Definition at line 304 of file MELoop.cpp.

References OptionsCont::getBool(), MSEdge::getEdgeType(), OptionsCont::getFloat(), Named::getID(), MSNet::getInstance(), MSEdge::getLanes(), MSEdge::getLength(), MSNet::getMesoType(), MSEdge::getNumericalID(), MSEdge::getNumSuccessors(), myEdges2FirstSegments, nextSegment(), numSegmentsFor(), and toString().

Referenced by NLEdgeControlBuilder::build().

Here is the caller graph for this function:

◆ changeSegment()

SUMOTime MELoop::changeSegment ( MEVehicle veh,
SUMOTime  leaveTime,
MESegment *const  toSegment,
MSMoveReminder::Notification  reason,
const bool  ignoreLink = false 
) const

◆ checkCar()

void MELoop::checkCar ( MEVehicle veh)
private

Check whether the vehicle may move.

This method is called when the vehicle reaches its event time and checks whether it may proceed to the next segment.

Parameters
[in]vehThe vehicle to check

Definition at line 135 of file MELoop.cpp.

References addLeaderCar(), MSEdge::allowedLanes(), changeSegment(), DELTA_T, MEVehicle::getBlockTime(), MSBaseVehicle::getEdge(), MESegment::getEventTime(), MEVehicle::getEventTime(), MESegment::getLink(), MEVehicle::getQueIndex(), MEVehicle::getSegment(), MSBaseVehicle::getVClass(), MEVehicle::getWaitingTime(), MSGlobals::gTimeToGridlock, MSGlobals::gTimeToTeleportDisconnected, MSBaseVehicle::isStopped(), MAX2(), MAX3(), MIN2(), myFullRecheckInterval, nextSegment(), MSMoveReminder::NOTIFICATION_ARRIVED, MESegment::PARKING_QUEUE, MEVehicle::setBlockTime(), MEVehicle::setEventTime(), MSBaseVehicle::succEdge(), SUMOTime_MAX, and teleportVehicle().

Referenced by simulate().

Here is the caller graph for this function:

◆ clearState()

void MELoop::clearState ( )

Remove all vehicles before quick-loading state.

Definition at line 245 of file MELoop.cpp.

References myLeaderCars.

Referenced by MSNet::clearState().

Here is the caller graph for this function:

◆ getSegmentForEdge()

MESegment * MELoop::getSegmentForEdge ( const MSEdge e,
double  pos = 0 
)

Get the segment for a given edge at a given position.

Parameters
[in]ethe edge to get the segment for
[in]posthe position to get the segment for
Returns
The relevant segment

Definition at line 340 of file MELoop.cpp.

References MESegment::getLength(), MESegment::getNextSegment(), MSEdge::getNumericalID(), and myEdges2FirstSegments.

Referenced by MSBaseVehicle::addStop(), NLTriggerBuilder::buildMECalibrator(), MSDriveWay::buildRoute(), GUIEdge::getSegmentAtPosition(), MSIdling_Stop::idle(), MSMeanData::init(), MSBaseVehicle::insertStop(), MSEdge::insertVehicle(), MESegment::limitedControlOverride(), MEVehicle::loadState(), MSRouteProbe::MSRouteProbe(), MSTriggeredRerouter::MSTriggeredRerouter(), MSStateHandler::myStartElement(), MSBaseVehicle::replaceStop(), MSMeanData::resetOnly(), MSLane::setMaxSpeed(), teleportVehicle(), MSMeanData::writeAggregated(), MSMeanData::writeEdge(), and MSXMLRawOut::writeEdge().

Here is the caller graph for this function:

◆ isEnteringRoundabout()

bool MELoop::isEnteringRoundabout ( const MSEdge e)
static

whether the given edge is entering a roundabout

Definition at line 357 of file MELoop.cpp.

References MSEdge::getSuccessors().

Referenced by MESegment::initSegment().

Here is the caller graph for this function:

◆ nextSegment()

MESegment * MELoop::nextSegment ( MESegment s,
MEVehicle v 
)
private

Retrieve next segment.

If the segment is not the last on the current edge, its successor is returned. Otherwise, the first segment of the edge at which the vehicle continues his journey is returned.

Parameters
[in]sThe segment the vehicle is currently at
[in]vThe vehicle to get the next segment for
Returns
The vehicle's next segment
Todo:
Recheck the "quick and dirty" stuff (
See also
MESegment::saveState,
MESegment::loadState)

Definition at line 274 of file MELoop.cpp.

References MESegment::getNextSegment(), MSEdge::getNumericalID(), myEdges2FirstSegments, and MSBaseVehicle::succEdge().

Referenced by buildSegmentsFor(), and checkCar().

Here is the caller graph for this function:

◆ numSegmentsFor()

int MELoop::numSegmentsFor ( const double  length,
const double  slength 
)
static

Compute number of segments per edge (best value stay close to the configured segment length)

Definition at line 293 of file MELoop.cpp.

Referenced by buildSegmentsFor(), and GUILane::splitAtSegments().

Here is the caller graph for this function:

◆ operator=()

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

Invalidated assignment operator.

◆ removeLeaderCar()

bool MELoop::removeLeaderCar ( MEVehicle v)

Removes the given car from the leading vehicles.

Parameters
[in]vthe car which was a leading one

Definition at line 251 of file MELoop.cpp.

References MEVehicle::getEventTime(), and myLeaderCars.

Referenced by MEVehicle::onRemovalFromNet(), MESegment::receive(), MESegment::setSpeedForQueue(), MESegment::vaporizeAnyCar(), and vaporizeCar().

Here is the caller graph for this function:

◆ simulate()

void MELoop::simulate ( SUMOTime  tMax)

Perform simulation up to the given time.

Checks all vehicles with an event time less or equal than the given time.

Parameters
[in]tMaxthe end time for the sim step

Definition at line 61 of file MELoop.cpp.

References checkCar(), DELTA_T, and myLeaderCars.

Referenced by MSNet::simulationStep().

Here is the caller graph for this function:

◆ teleportVehicle()

void MELoop::teleportVehicle ( MEVehicle veh,
MESegment *const  toSegment,
bool  disconnected 
)
private

◆ updateSegmentsForEdge()

void MELoop::updateSegmentsForEdge ( const MSEdge e)

Update segments after loading meso edge type parameters from additional file.

Parameters
[in]ethe edge to update

Definition at line 327 of file MELoop.cpp.

References MESegment::getCapacity(), MSEdge::getEdgeType(), MSNet::getInstance(), MSNet::getMesoType(), MESegment::getNextSegment(), MSEdge::getNumericalID(), MESegment::initSegment(), and myEdges2FirstSegments.

Referenced by MSEdge::updateMesoType().

Here is the caller graph for this function:

◆ vaporizeCar()

void MELoop::vaporizeCar ( MEVehicle v,
MSMoveReminder::Notification  reason 
)

remove the given car and clean up the relevant data structures

Definition at line 266 of file MELoop.cpp.

References MSNet::getInstance(), MEVehicle::getSegment(), removeLeaderCar(), and MESegment::send().

Referenced by GUIBaseVehicle::GUIBaseVehiclePopupMenu::onCmdRemoveObject().

Here is the caller graph for this function:

Field Documentation

◆ myEdges2FirstSegments

std::vector<MESegment*> MELoop::myEdges2FirstSegments
private

mapping from internal edge ids to their initial segments

Definition at line 149 of file MELoop.h.

Referenced by buildSegmentsFor(), changeSegment(), getSegmentForEdge(), nextSegment(), updateSegmentsForEdge(), and ~MELoop().

◆ myFullRecheckInterval

const SUMOTime MELoop::myFullRecheckInterval
private

the interval at which to recheck at full segments (<=0 means asap)

Definition at line 152 of file MELoop.h.

Referenced by checkCar().

◆ myLeaderCars

std::map<SUMOTime, std::vector<MEVehicle*> > MELoop::myLeaderCars
private

leader cars in the segments sorted by exit time

Definition at line 146 of file MELoop.h.

Referenced by addLeaderCar(), clearState(), removeLeaderCar(), and simulate().

◆ myLinkRecheckInterval

const SUMOTime MELoop::myLinkRecheckInterval
private

the interval at which to recheck at blocked junctions (<=0 means asap)

Definition at line 155 of file MELoop.h.

Referenced by changeSegment().


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