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

The main mesocopic simulation loop. More...

#include <MELoop.h>

Data Structures

struct  LeaderEvent
 

Public Member Functions

void addLeaderCar (MEVehicle *veh, MSLink *link, const bool fromState=false)
 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.
 
MESegment * getSegmentForEdge (const MSEdge &e, double pos=0)
 Get the segment for a given edge at a given position.
 
 MELoop (const SUMOTime recheckInterval)
 SUMO constructor.
 
void removeLeaderCar (MEVehicle *v)
 Removes the given car from the leading vehicles.
 
void simulate (SUMOTime tMax)
 Perform simulation up to the given time.
 
void vaporizeCar (MEVehicle *v, MSMoveReminder::Notification reason)
 remove the given car and clean up the relevant data structures
 
 ~MELoop ()
 

Static Public Member Functions

static long long int getEventCounter ()
 the number of leader events so far (for saving and loading state)
 
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)
 
static void setEventCounter (long long int counter)
 

Private Types

typedef std::priority_queue< LeaderEvent > LeaderEventQeue
 leader cars in the segments sorted by exit time
 

Private Member Functions

void checkCar (MEVehicle *veh)
 Check whether the vehicle may move.
 
 MELoop (const MELoop &)
 Invalidated copy constructor.
 
MESegment * nextSegment (MESegment *s, MEVehicle *v)
 Retrieve next segment.
 
MELoop & operator= (const MELoop &)
 Invalidated assignment operator.
 
void teleportVehicle (MEVehicle *veh, MESegment *const toSegment, bool disconnected)
 teleports a vehicle or continues a teleport
 
bool wasInvalidated (const LeaderEvent &e)
 check whether the current car was invalidated and remove it from myInvalidatedLeaderCars
 

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)
 
LeaderEventQeue myInvalidatedLeaderCars
 
LeaderEventQeue myLeaderCars
 
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.

Member Typedef Documentation

◆ LeaderEventQeue

typedef std::priority_queue<LeaderEvent> MELoop::LeaderEventQeue
private

leader cars in the segments sorted by exit time

Definition at line 179 of file MELoop.h.

Constructor & Destructor Documentation

◆ MELoop() [1/2]

MELoop::MELoop ( const SUMOTime  recheckInterval)

SUMO constructor.

Definition at line 48 of file MELoop.cpp.

◆ ~MELoop()

MELoop::~MELoop ( )

Definition at line 51 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,
const bool  fromState = false 
)

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
[in]fromStatewhether the event is restored from a loaded state (keeping the vehicle's event index)

Definition at line 301 of file MELoop.cpp.

References MELoop::LeaderEvent::myEventCounter, myLeaderCars, MEVehicle::setApproaching(), and MEVehicle::setEventIndex().

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 368 of file MELoop.cpp.

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

Referenced by MSEdgeControl::buildMesoSegments().

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

change to the next segment this handles combinations of the following cases: (ending / continuing route) and (leaving segment / finishing teleport)

Definition at line 114 of file MELoop.cpp.

References MSEdge::allowedLanes(), MEVehicle::endTriggeredStop(), MSGlobals::gCheckRoutes, MEVehicle::getBlockTime(), MESegment::getEdge(), MSBaseVehicle::getEdge(), MEVehicle::getEventTime(), Named::getID(), MESegment::getIndex(), MSNet::getInstance(), MSEdge::getLanes(), MEVehicle::getLastEntryTime(), MESegment::getNextSegment(), MSEdge::getNumericalID(), MSVehicleType::getParameter(), MEVehicle::getQueIndex(), MEVehicle::getSegment(), SUMOVTypeParameter::getTimeToTeleport(), MSBaseVehicle::getVClass(), MSNet::getVehicleControl(), MSBaseVehicle::getVehicleType(), MSGlobals::gTimeToGridlock, MSGlobals::gTimeToTeleportDisconnected, MESegment::hasSpaceFor(), MSBaseVehicle::ignoreTransientPermissions(), MESegment::isInvalid(), MSBaseVehicle::isParking(), MSBaseVehicle::isStopped(), MSBaseVehicle::isStoppedTriggered(), MAX2(), MEVehicle::mayProceed(), MIN2(), myEdges2FirstSegments, myLinkRecheckInterval, MSMoveReminder::NOTIFICATION_JUNCTION, MSMoveReminder::NOTIFICATION_SEGMENT, MSMoveReminder::NOTIFICATION_TELEPORT, MESegment::PARKING_QUEUE, MEVehicle::processStop(), MESegment::receive(), MSVehicleControl::scheduleVehicleRemoval(), MESegment::send(), MEVehicle::setSegment(), MSBaseVehicle::succEdge(), time2string(), TL, MEVehicle::updateDetectors(), MESegment::updateEntryBlockTime(), and WRITE_WARNINGF.

Referenced by checkCar(), MEVehicle::onRemovalFromNet(), teleportVehicle(), and MESegment::vaporizeAnyCar().

Here is the caller graph for this function:

◆ checkCar()

◆ clearState()

void MELoop::clearState ( )

Remove all vehicles before quick-loading state.

Definition at line 311 of file MELoop.cpp.

References myInvalidatedLeaderCars, and myLeaderCars.

Referenced by MSNet::clearState().

Here is the caller graph for this function:

◆ getEventCounter()

static long long int MELoop::getEventCounter ( )
inlinestatic

the number of leader events so far (for saving and loading state)

Definition at line 110 of file MELoop.h.

References MELoop::LeaderEvent::myEventCounter.

Referenced by MSStateHandler::saveState().

Here is the caller graph for this function:

◆ getSegmentForEdge()

◆ isEnteringRoundabout()

bool MELoop::isEnteringRoundabout ( const MSEdge &  e)
static

whether the given edge is entering a roundabout

Definition at line 414 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 332 of file MELoop.cpp.

References MESegment::getEdge(), MSEdge::getInternalFollowingEdge(), MESegment::getNextSegment(), MSEdge::getNumericalID(), MSBaseVehicle::getVClass(), MSGlobals::gUsingInternalLanes, MSEdge::isNormal(), 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 357 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()

void MELoop::removeLeaderCar ( MEVehicle *  v)

Removes the given car from the leading vehicles.

Parameters
[in]vthe car which was a leading one

Definition at line 318 of file MELoop.cpp.

References myInvalidatedLeaderCars.

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

Here is the caller graph for this function:

◆ setEventCounter()

static void MELoop::setEventCounter ( long long int  counter)
inlinestatic

Definition at line 114 of file MELoop.h.

References MELoop::LeaderEvent::myEventCounter.

Referenced by MSStateHandler::myEndElement().

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 63 of file MELoop.cpp.

References checkCar(), DELTA_T, myInvalidatedLeaderCars, myLeaderCars, MELoop::LeaderEvent::time, MELoop::LeaderEvent::veh, and wasInvalidated().

Referenced by MSNet::simulationStep().

Here is the caller graph for this function:

◆ teleportVehicle()

◆ vaporizeCar()

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

remove the given car and clean up the relevant data structures

Definition at line 324 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:

◆ wasInvalidated()

bool MELoop::wasInvalidated ( const LeaderEvent &  e)
private

check whether the current car was invalidated and remove it from myInvalidatedLeaderCars

Definition at line 87 of file MELoop.cpp.

References myInvalidatedLeaderCars, and MELoop::LeaderEvent::time.

Referenced by simulate().

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 184 of file MELoop.h.

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

◆ myFullRecheckInterval

const SUMOTime MELoop::myFullRecheckInterval
private

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

Definition at line 187 of file MELoop.h.

Referenced by checkCar().

◆ myInvalidatedLeaderCars

LeaderEventQeue MELoop::myInvalidatedLeaderCars
private

Definition at line 181 of file MELoop.h.

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

◆ myLeaderCars

LeaderEventQeue MELoop::myLeaderCars
private

Definition at line 180 of file MELoop.h.

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

◆ myLinkRecheckInterval

const SUMOTime MELoop::myLinkRecheckInterval
private

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

Definition at line 190 of file MELoop.h.

Referenced by changeSegment().


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