SUMO - Simulation of Urban MObility
MSRoutingEngine Class Reference

A device that performs vehicle rerouting based on current edge speeds. More...

#include <MSRoutingEngine.h>

Collaboration diagram for MSRoutingEngine:
Collaboration graph

Static Public Member Functions

static void cleanup ()
 deletes the router instance More...
 
static double getAssumedSpeed (const MSEdge *edge)
 return current travel speed assumption More...
 
static const MSRoutegetCachedRoute (const std::pair< const MSEdge *, const MSEdge *> &key)
 return the cached route or nullptr on miss More...
 
static double getEffort (const MSEdge *const e, const SUMOVehicle *const v, double t)
 Returns the effort to pass an edge. More...
 
static SUMOTime getLastAdaptation ()
 Information when the last edge weight adaptation occurred. More...
 
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT (const MSEdgeVector &prohibited=MSEdgeVector())
 return the router instance More...
 
static bool hasEdgeUpdates ()
 returns whether any routing actions take place More...
 
static void initEdgeWeights ()
 initialize the edge weights if not done before More...
 
static void initWeightUpdate ()
 intialize period edge weight update More...
 
static bool isEnabled ()
 returns whether any routing actions take place More...
 
static void reroute (SUMOVehicle &vehicle, const SUMOTime currentTime, const bool onInit)
 initiate the rerouting, create router / thread pool on first use More...
 
static void setEdgeTravelTime (const MSEdge *const edge, const double travelTime)
 adapt the known travel time for an edge More...
 

Private Member Functions

 MSRoutingEngine (const MSRoutingEngine &)
 Invalidated copy constructor. More...
 
MSRoutingEngineoperator= (const MSRoutingEngine &)
 Invalidated assignment operator. More...
 

Static Private Member Functions

Network state adaptation
static SUMOTime adaptEdgeEfforts (SUMOTime currentTime)
 Adapt edge efforts by the current edge states. More...
 

Static Private Attributes

static SUMOTime myAdaptationInterval = -1
 At which time interval the edge weights get updated. More...
 
static int myAdaptationSteps
 The number of steps for averaging edge speeds (ring-buffer) More...
 
static int myAdaptationStepsIndex = 0
 The current index in the pastEdgeSpeed ring-buffer. More...
 
static double myAdaptationWeight
 Information which weight prior edge efforts have. More...
 
static std::map< std::pair< const MSEdge *, const MSEdge * >, const MSRoute * > myCachedRoutes
 The container of pre-calculated routes. More...
 
static std::vector< double > myEdgeSpeeds
 The container of edge speeds. More...
 
static CommandmyEdgeWeightSettingCommand = nullptr
 The weights adaptation/overwriting command. More...
 
static SUMOTime myLastAdaptation = -1
 Information when the last edge weight adaptation occurred. More...
 
static std::vector< std::vector< double > > myPastEdgeSpeeds
 The container of edge speeds. More...
 
static double myRandomizeWeightsFactor = 0
 Whether to disturb edge weights dynamically. More...
 
static SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouter = nullptr
 The router to use. More...
 
static AStarRouter< MSEdge, SUMOVehicle, SUMOAbstractRouterPermissions< MSEdge, SUMOVehicle > > * myRouterWithProhibited = nullptr
 The router to use by rerouter elements. More...
 
static bool myWithTaz
 whether taz shall be used at initial rerouting More...
 

Detailed Description

A device that performs vehicle rerouting based on current edge speeds.

The routing-device system consists of in-vehicle devices that perform a routing and a simulation-wide (static) methods for colecting edge weights.

The edge weights container "myEdgeSpeeds" is pre-initialised as soon as one device is built and is kept updated via an event that adapts it to the current mean speed on the simulated network's edges.

A device is assigned to a vehicle using the common explicit/probability - procedure.

A device computes a new route for a vehicle as soon as the vehicle is inserted (within "enterLaneAtInsertion") - and, if the given period is larger than 0 - each x time steps where x is the period. This is triggered by an event that executes "wrappedRerouteCommandExecute".

Definition at line 64 of file MSRoutingEngine.h.

Constructor & Destructor Documentation

◆ MSRoutingEngine()

MSRoutingEngine::MSRoutingEngine ( const MSRoutingEngine )
private

Invalidated copy constructor.

Member Function Documentation

◆ adaptEdgeEfforts()

SUMOTime MSRoutingEngine::adaptEdgeEfforts ( SUMOTime  currentTime)
staticprivate

Adapt edge efforts by the current edge states.

This method is called by the event handler at the end of a simulation step. The current edge weights are combined with the previously stored.

Parameters
[in]currentTimeThe current simulation time
Returns
The offset to the next call (always 1 in this case - edge weights are updated each time step)
Todo:
Describe how the weights are adapted
See also
MSEventHandler
StaticCommand

Definition at line 149 of file MSRoutingEngine.cpp.

References OutputDevice::closeTag(), DELTA_T, OutputDevice::getDeviceByOption(), MSNet::getEdgeControl(), MSEdgeControl::getEdges(), MSNet::getInstance(), OptionsCont::getOptions(), initEdgeWeights(), myAdaptationInterval, myAdaptationSteps, myAdaptationStepsIndex, myAdaptationWeight, myCachedRoutes, myEdgeSpeeds, myLastAdaptation, myPastEdgeSpeeds, OutputDevice::openTag(), STEPS2TIME, SUMO_ATTR_BEGIN, SUMO_ATTR_END, SUMO_ATTR_ID, SUMO_TAG_EDGE, SUMO_TAG_INTERVAL, and OutputDevice::writeAttr().

Referenced by initWeightUpdate(), and isEnabled().

◆ cleanup()

void MSRoutingEngine::cleanup ( )
static

◆ getAssumedSpeed()

double MSRoutingEngine::getAssumedSpeed ( const MSEdge edge)
static

return current travel speed assumption

Definition at line 143 of file MSRoutingEngine.cpp.

References getEffort(), and MSEdge::getLength().

Referenced by MSEdge::getRoutingSpeed(), and isEnabled().

◆ getCachedRoute()

const MSRoute * MSRoutingEngine::getCachedRoute ( const std::pair< const MSEdge *, const MSEdge *> &  key)
static

return the cached route or nullptr on miss

Definition at line 205 of file MSRoutingEngine.cpp.

References myCachedRoutes.

Referenced by getLastAdaptation(), and MSDevice_Routing::preInsertionReroute().

◆ getEffort()

double MSRoutingEngine::getEffort ( const MSEdge *const  e,
const SUMOVehicle *const  v,
double  t 
)
static

Returns the effort to pass an edge.

This method is given to the used router in order to obtain the efforts to pass an edge from the internal edge weights container.

The time is not used, here, as the current simulation state is used in an aggregated way.

Parameters
[in]eThe edge for which the effort to be passed shall be returned
[in]vThe vehicle that is rerouted
[in]tThe time for which the effort shall be returned
Returns
The effort (time to pass in this case) for an edge
See also
DijkstraRouter_ByProxi

Definition at line 129 of file MSRoutingEngine.cpp.

References MSEdge::getLength(), MSEdge::getMinimumTravelTime(), MSEdge::getNumericalID(), MAX2(), myEdgeSpeeds, myRandomizeWeightsFactor, NUMERICAL_EPS, and RandHelper::rand().

Referenced by getAssumedSpeed(), MSDevice_Routing::getParameter(), getRouterTT(), isEnabled(), and reroute().

◆ getLastAdaptation()

static SUMOTime MSRoutingEngine::getLastAdaptation ( )
inlinestatic

Information when the last edge weight adaptation occurred.

Definition at line 78 of file MSRoutingEngine.h.

References cleanup(), getCachedRoute(), myLastAdaptation, reroute(), and setEdgeTravelTime().

Referenced by MSPersonDevice_Routing::reroute(), and MSDevice_Routing::reroute().

◆ getRouterTT()

◆ hasEdgeUpdates()

static bool MSRoutingEngine::hasEdgeUpdates ( )
inlinestatic

returns whether any routing actions take place

Definition at line 73 of file MSRoutingEngine.h.

References myEdgeWeightSettingCommand.

Referenced by MSDevice_Routing::MSDevice_Routing(), and MSPersonDevice_Routing::MSPersonDevice_Routing().

◆ initEdgeWeights()

◆ initWeightUpdate()

◆ isEnabled()

static bool MSRoutingEngine::isEnabled ( )
inlinestatic

◆ operator=()

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

Invalidated assignment operator.

Referenced by isEnabled().

◆ reroute()

◆ setEdgeTravelTime()

void MSRoutingEngine::setEdgeTravelTime ( const MSEdge *const  edge,
const double  travelTime 
)
static

adapt the known travel time for an edge

Definition at line 305 of file MSRoutingEngine.cpp.

References MSEdge::getLength(), MSEdge::getNumericalID(), and myEdgeSpeeds.

Referenced by getLastAdaptation(), and MSDevice_Routing::setParameter().

Field Documentation

◆ myAdaptationInterval

SUMOTime MSRoutingEngine::myAdaptationInterval = -1
staticprivate

At which time interval the edge weights get updated.

Definition at line 206 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), cleanup(), initWeightUpdate(), isEnabled(), and reroute().

◆ myAdaptationSteps

int MSRoutingEngine::myAdaptationSteps
staticprivate

The number of steps for averaging edge speeds (ring-buffer)

Definition at line 212 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), initEdgeWeights(), and initWeightUpdate().

◆ myAdaptationStepsIndex

int MSRoutingEngine::myAdaptationStepsIndex = 0
staticprivate

The current index in the pastEdgeSpeed ring-buffer.

Definition at line 215 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), and cleanup().

◆ myAdaptationWeight

double MSRoutingEngine::myAdaptationWeight
staticprivate

Information which weight prior edge efforts have.

Definition at line 203 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), and initWeightUpdate().

◆ myCachedRoutes

std::map< std::pair< const MSEdge *, const MSEdge * >, const MSRoute * > MSRoutingEngine::myCachedRoutes
staticprivate

The container of pre-calculated routes.

Definition at line 233 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), cleanup(), and getCachedRoute().

◆ myEdgeSpeeds

std::vector< double > MSRoutingEngine::myEdgeSpeeds
staticprivate

The container of edge speeds.

Definition at line 200 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), cleanup(), getEffort(), initEdgeWeights(), initWeightUpdate(), and setEdgeTravelTime().

◆ myEdgeWeightSettingCommand

Command * MSRoutingEngine::myEdgeWeightSettingCommand = nullptr
staticprivate

The weights adaptation/overwriting command.

Definition at line 197 of file MSRoutingEngine.h.

Referenced by hasEdgeUpdates(), and initWeightUpdate().

◆ myLastAdaptation

SUMOTime MSRoutingEngine::myLastAdaptation = -1
staticprivate

Information when the last edge weight adaptation occurred.

Definition at line 209 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), getLastAdaptation(), initEdgeWeights(), and initWeightUpdate().

◆ myPastEdgeSpeeds

std::vector< std::vector< double > > MSRoutingEngine::myPastEdgeSpeeds
staticprivate

The container of edge speeds.

Definition at line 218 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), cleanup(), and initEdgeWeights().

◆ myRandomizeWeightsFactor

double MSRoutingEngine::myRandomizeWeightsFactor = 0
staticprivate

Whether to disturb edge weights dynamically.

Definition at line 230 of file MSRoutingEngine.h.

Referenced by getEffort(), and initEdgeWeights().

◆ myRouter

SUMOAbstractRouter< MSEdge, SUMOVehicle > * MSRoutingEngine::myRouter = nullptr
staticprivate

The router to use.

Definition at line 224 of file MSRoutingEngine.h.

Referenced by cleanup(), isEnabled(), and reroute().

◆ myRouterWithProhibited

AStarRouter< MSEdge, SUMOVehicle, SUMOAbstractRouterPermissions< MSEdge, SUMOVehicle > > * MSRoutingEngine::myRouterWithProhibited = nullptr
staticprivate

The router to use by rerouter elements.

Definition at line 227 of file MSRoutingEngine.h.

Referenced by cleanup(), and getRouterTT().

◆ myWithTaz

bool MSRoutingEngine::myWithTaz
staticprivate

whether taz shall be used at initial rerouting

Definition at line 221 of file MSRoutingEngine.h.

Referenced by cleanup(), initWeightUpdate(), isEnabled(), and reroute().


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