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, SUMOReal 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 SUMOReal length, const SUMOReal 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... | |
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 58 of file MELoop.cpp.
MELoop::~MELoop | ( | ) |
Definition at line 61 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 208 of file MELoop.cpp.
References MEVehicle::getEventTime(), myLeaderCars, and setApproaching().
Referenced by checkCar(), MEVehicle::loadState(), MESegment::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 265 of file MELoop.cpp.
References OptionsCont::getBool(), OptionsCont::getFloat(), Named::getID(), MSEdge::getLanes(), MSEdge::getLength(), MSEdge::getNumericalID(), OptionsCont::getString(), myEdges2FirstSegments, nextSegment(), numSegmentsFor(), string2time(), SUMOReal, 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 91 of file MELoop.cpp.
References MSBaseVehicle::getEdge(), MESegment::getEdge(), Named::getID(), MSBaseVehicle::getID(), MESegment::getIndex(), MSNet::getInstance(), MSEdge::getNumericalID(), MEVehicle::getSegment(), MSNet::getVehicleControl(), MESegment::hasSpaceFor(), MESegment::isInvalid(), MEVehicle::mayProceed(), myEdges2FirstSegments, 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 122 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(), MEVehicle::isStopped(), 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 295 of file MELoop.cpp.
References MESegment::getLength(), MESegment::getNextSegment(), MSEdge::getNumericalID(), myEdges2FirstSegments, and SUMOReal.
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().
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 235 of file MELoop.cpp.
References MESegment::getNextSegment(), MSEdge::getNumericalID(), myEdges2FirstSegments, and MSBaseVehicle::succEdge().
Referenced by buildSegmentsFor(), and checkCar().
Compute number of segments per edge (best value stay close to the configured segment length)
Definition at line 254 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 228 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 215 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 73 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 156 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(), MEVehicle::moveRoutePointer(), MSMoveReminder::NOTIFICATION_JUNCTION, 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 150 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 153 of file MELoop.h.
Referenced by checkCar().
leader cars in the segments sorted by exit time
Definition at line 147 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 156 of file MELoop.h.
Referenced by checkCar().