![]() |
SUMO - Simulation of Urban MObility
|
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. More... | |
void | buildSegmentsFor (const MSEdge &e, const OptionsCont &oc) |
Build the segments for a given edge. More... | |
bool | changeSegment (MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, const bool ignoreLink=false) |
change to the next segment this handles combinations of the following cases: (ending / continuing route) and (leaving segment / finishing teleport) More... | |
MESegment * | getSegmentForEdge (const MSEdge &e, double pos=0) |
Get the segment for a given edge at a given position. More... | |
MELoop (const SUMOTime recheckInterval) | |
SUMO constructor. More... | |
void | removeLeaderCar (MEVehicle *v) |
Removes the given car from the leading vehicles. More... | |
void | simulate (SUMOTime tMax) |
Perform simulation up to the given time. More... | |
~MELoop () | |
Static Public Member Functions | |
static int | numSegmentsFor (const double length, const double slength) |
Compute number of segments per edge (best value stay close to the configured segment length) More... | |
static void | setApproaching (MEVehicle *veh, MSLink *link) |
registers vehicle with the given link More... | |
Private Member Functions | |
void | checkCar (MEVehicle *veh) |
Check whether the vehicle may move. More... | |
MELoop (const MELoop &) | |
Invalidated copy constructor. More... | |
MESegment * | nextSegment (MESegment *s, MEVehicle *v) |
Retrieve next segment. More... | |
MELoop & | operator= (const MELoop &) |
Invalidated assignment operator. More... | |
void | teleportVehicle (MEVehicle *veh, MESegment *const toSegment) |
teleports a vehicle or continues a teleport More... | |
Static Private Member Functions | |
static bool | isEnteringRoundabout (const MSEdge &e) |
whether the given edge is entering a roundabout More... | |
Private Attributes | |
std::vector< MESegment * > | myEdges2FirstSegments |
mapping from internal edge ids to their initial segments More... | |
const SUMOTime | myFullRecheckInterval |
the interval at which to recheck at full segments (<=0 means asap) More... | |
std::map< SUMOTime, std::vector< MEVehicle * > > | myLeaderCars |
leader cars in the segments sorted by exit time More... | |
const SUMOTime | myLinkRecheckInterval |
the interval at which to recheck at blocked junctions (<=0 means asap) More... | |
MELoop::MELoop | ( | const SUMOTime | recheckInterval | ) |
SUMO constructor.
Definition at line 48 of file MELoop.cpp.
MELoop::~MELoop | ( | ) |
Definition at line 51 of file MELoop.cpp.
References MESegment::getNextSegment(), and myEdges2FirstSegments.
|
private |
Invalidated copy constructor.
Adds the given car to the leading vehicles.
[in] | veh | the car which became a leading one |
[in] | link | the link on which the car shall register its approach |
Definition at line 198 of file MELoop.cpp.
References MEVehicle::getEventTime(), myLeaderCars, and setApproaching().
Referenced by checkCar(), MESegment::loadState(), MEVehicle::loadState(), MESegment::receive(), MESegment::send(), MESegment::setSpeedForQueue(), and teleportVehicle().
void MELoop::buildSegmentsFor | ( | const MSEdge & | e, |
const OptionsCont & | oc | ||
) |
Build the segments for a given edge.
[in] | e | the edge to build for |
Definition at line 255 of file MELoop.cpp.
References OptionsCont::getBool(), OptionsCont::getFloat(), Named::getID(), MSEdge::getLanes(), MSEdge::getLength(), MSEdge::getNumericalID(), OptionsCont::getString(), isEnteringRoundabout(), myEdges2FirstSegments, nextSegment(), numSegmentsFor(), string2time(), and toString().
Referenced by MSEdge::closeBuilding().
bool MELoop::changeSegment | ( | MEVehicle * | veh, |
SUMOTime | leaveTime, | ||
MESegment *const | toSegment, | ||
const bool | ignoreLink = false |
||
) |
change to the next segment this handles combinations of the following cases: (ending / continuing route) and (leaving segment / finishing teleport)
Definition at line 81 of file MELoop.cpp.
References MSBaseVehicle::getEdge(), MESegment::getEdge(), Named::getID(), MSBaseVehicle::getID(), MESegment::getIndex(), MSNet::getInstance(), MESegment::getNextSegment(), MSEdge::getNumericalID(), MEVehicle::getSegment(), MSNet::getVehicleControl(), MESegment::hasSpaceFor(), MESegment::isInvalid(), MEVehicle::mayProceed(), myEdges2FirstSegments, MSMoveReminder::NOTIFICATION_ARRIVED, MSMoveReminder::NOTIFICATION_JUNCTION, MSMoveReminder::NOTIFICATION_SEGMENT, MSMoveReminder::NOTIFICATION_VAPORIZED, MESegment::receive(), MSVehicleControl::scheduleVehicleRemoval(), MESegment::send(), MEVehicle::setSegment(), time2string(), toString(), and WRITE_WARNING.
Referenced by checkCar(), teleportVehicle(), and MESegment::vaporizeAnyCar().
|
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.
[in] | veh | The vehicle to check |
Definition at line 112 of file MELoop.cpp.
References addLeaderCar(), changeSegment(), MEVehicle::getBlockTime(), MESegment::getEntryBlockTime(), MEVehicle::getEventTime(), MESegment::getEventTime(), MESegment::getLink(), MEVehicle::getSegment(), MEVehicle::getWaitingTime(), MSGlobals::gTimeToGridlock, MESegment::hasSpaceFor(), MAX2(), MAX3(), MEVehicle::mayProceed(), MIN2(), myFullRecheckInterval, myLinkRecheckInterval, nextSegment(), MEVehicle::setBlockTime(), MEVehicle::setEventTime(), SUMOTime_MAX, and teleportVehicle().
Referenced by simulate().
Get the segment for a given edge at a given position.
[in] | e | the edge to get the segment for |
[in] | pos | the position to get the segment for |
Definition at line 283 of file MELoop.cpp.
References MESegment::getLength(), MESegment::getNextSegment(), MSEdge::getNumericalID(), and myEdges2FirstSegments.
Referenced by MEVehicle::addStop(), METriggeredCalibrator::execute(), GUIEdge::getSegmentAtPosition(), MSMeanData::init(), MSEdge::insertVehicle(), MESegment::limitedControlOverride(), MEVehicle::loadState(), MSRouteProbe::MSRouteProbe(), MSTriggeredRerouter::MSTriggeredRerouter(), MSStateHandler::myStartElement(), MSLaneSpeedTrigger::processCommand(), MSMeanData::resetOnly(), teleportVehicle(), MSXMLRawOut::writeEdge(), and MSMeanData::writeEdge().
|
staticprivate |
whether the given edge is entering a roundabout
Definition at line 297 of file MELoop.cpp.
References MSEdge::getSuccessors().
Referenced by buildSegmentsFor().
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.
[in] | s | The segment the vehicle is currently at |
[in] | v | The vehicle to get the next segment for |
Definition at line 225 of file MELoop.cpp.
References MESegment::getNextSegment(), MSEdge::getNumericalID(), myEdges2FirstSegments, and MSBaseVehicle::succEdge().
Referenced by buildSegmentsFor(), and checkCar().
|
static |
Compute number of segments per edge (best value stay close to the configured segment length)
Definition at line 244 of file MELoop.cpp.
Referenced by buildSegmentsFor(), and GUILane::splitAtSegments().
void MELoop::removeLeaderCar | ( | MEVehicle * | v | ) |
Removes the given car from the leading vehicles.
[in] | v | the car which was a leading one |
Definition at line 218 of file MELoop.cpp.
References MEVehicle::getEventTime(), and myLeaderCars.
Referenced by MESegment::receive(), MESegment::setSpeedForQueue(), and MESegment::vaporizeAnyCar().
registers vehicle with the given link
[in] | veh | the car to register |
[in] | link | the link on which the car shall register its approach |
Definition at line 205 of file MELoop.cpp.
References MEVehicle::getEventTime(), MESegment::getLength(), MEVehicle::getSegment(), MEVehicle::getSpeed(), MSLink::getState(), MEVehicle::getWaitingTime(), LINKSTATE_ALLWAY_STOP, RandHelper::rand(), and MSLink::setApproaching().
Referenced by addLeaderCar(), and MEVehicle::replaceRoute().
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.
[in] | tMax | the end time for the sim step |
Definition at line 63 of file MELoop.cpp.
References checkCar(), DELTA_T, and myLeaderCars.
Referenced by MSNet::simulationStep().
teleports a vehicle or continues a teleport
[in] | veh | The vehicle to teleport |
[in] | toSegment | The first segment where the vehicle may reenter the network |
Definition at line 146 of file MELoop.cpp.
References MSBaseVehicle::activateReminders(), addLeaderCar(), changeSegment(), MSBaseVehicle::getEdge(), MESegment::getEdge(), MEVehicle::getEventTime(), Named::getID(), MSBaseVehicle::getID(), MESegment::getIndex(), MSNet::getInstance(), MSEdge::getLength(), MESegment::getNextSegment(), MEVehicle::getSegment(), getSegmentForEdge(), MSEdge::getSpeedLimit(), MSNet::getVehicleControl(), MESegment::hasSpaceFor(), MAX2(), MEVehicle::moveRoutePointer(), MSMoveReminder::NOTIFICATION_JUNCTION, MSMoveReminder::NOTIFICATION_TELEPORT, NUMERICAL_EPS, MSVehicleControl::registerTeleportJam(), MESegment::send(), MESegment::setEntryBlockTime(), MEVehicle::setEventTime(), MEVehicle::setSegment(), TIME2STEPS, time2string(), toString(), and WRITE_WARNING.
Referenced by checkCar().
|
private |
mapping from internal edge ids to their initial segments
Definition at line 146 of file MELoop.h.
Referenced by buildSegmentsFor(), changeSegment(), getSegmentForEdge(), nextSegment(), and ~MELoop().
|
private |
the interval at which to recheck at full segments (<=0 means asap)
Definition at line 149 of file MELoop.h.
Referenced by checkCar().
leader cars in the segments sorted by exit time
Definition at line 143 of file MELoop.h.
Referenced by addLeaderCar(), removeLeaderCar(), and simulate().
|
private |
the interval at which to recheck at blocked junctions (<=0 means asap)
Definition at line 152 of file MELoop.h.
Referenced by checkCar().