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

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

#include <MSRoutingEngine.h>

Collaboration diagram for MSRoutingEngine:
[legend]

Static Public Member Functions

static void addEdgeTravelTime (const MSEdge &edge, const SUMOTime travelTime)
 record actual travel time for an edge
 
static void cleanup ()
 deletes the router instance
 
static double getAssumedSpeed (const MSEdge *edge, const SUMOVehicle *veh)
 return current travel speed assumption
 
static ConstMSRoutePtr getCachedRoute (const std::pair< const MSEdge *, const MSEdge * > &key)
 return the cached route or nullptr on miss
 
static double getEffort (const MSEdge *const e, const SUMOVehicle *const v, double t)
 Returns the effort to pass an edge.
 
static double getEffortBike (const MSEdge *const e, const SUMOVehicle *const v, double t)
 
static double getEffortExtra (const MSEdge *const e, const SUMOVehicle *const v, double t)
 
static MSTransportableRoutergetIntermodalRouterTT (const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector())
 return the person router instance
 
static SUMOTime getLastAdaptation ()
 Information when the last edge weight adaptation occurred.
 
static MSVehicleRoutergetRouterTT (const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
 return the vehicle router instance
 
static bool hasEdgeUpdates ()
 returns whether any edge weight updates will take place
 
static void initEdgeWeights (SUMOVehicleClass svc)
 initialize the edge weights if not done before
 
static void initRouter (SUMOVehicle *vehicle=nullptr)
 
static void initWeightUpdate ()
 intialize period edge weight update
 
static bool isEnabled ()
 returns whether any routing actions take place
 
static void reroute (MSTransportable &t, const SUMOTime currentTime, const std::string &info, const bool onInit=false, const bool silent=false, const MSEdgeVector &prohibited=MSEdgeVector())
 initiate the person rerouting, create router / thread pool on first use
 
static void reroute (SUMOVehicle &vehicle, const SUMOTime currentTime, const std::string &info, const bool onInit=false, const bool silent=false, const MSEdgeVector &prohibited=MSEdgeVector())
 initiate the rerouting, create router / thread pool on first use
 
static void setEdgeTravelTime (const MSEdge *const edge, const double travelTime)
 adapt the known travel time for an edge
 
static bool withTaz ()
 whether taz-routing is enabled
 

Static Public Attributes

static SUMOAbstractRouter< MSEdge, SUMOVehicle >::Operation myEffortFunc = &MSRoutingEngine::getEffort
 

Private Types

typedef std::pair< SUMOTime, int > TimeAndCount
 

Private Member Functions

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

Static Private Member Functions

static void _initEdgeWeights (std::vector< double > &edgeSpeeds, std::vector< std::vector< double > > &pastEdgeSpeeds)
 initialized edge speed storage into the given containers
 
static SumoRNGgetThreadRNG ()
 returns RNG associated with the current thread
 
Network state adaptation
static SUMOTime adaptEdgeEfforts (SUMOTime currentTime)
 Adapt edge efforts by the current edge states.
 
static double patchSpeedForTurns (const MSEdge *edge, double currSpeed)
 

Static Private Attributes

static SUMOTime myAdaptationInterval = -1
 At which time interval the edge weights get updated.
 
static int myAdaptationSteps
 The number of steps for averaging edge speeds (ring-buffer)
 
static int myAdaptationStepsIndex = 0
 The current index in the pastEdgeSpeed ring-buffer.
 
static double myAdaptationWeight
 Information which weight prior edge efforts have.
 
static bool myBikeSpeeds
 whether separate speeds for bicycles shall be tracked
 
static std::map< std::pair< const MSEdge *, const MSEdge * >, ConstMSRoutePtrmyCachedRoutes
 The container of pre-calculated routes.
 
static std::vector< double > myEdgeBikeSpeeds
 
static double myEdgePriorityRange
 the difference between maximum and minimum priority for all edges
 
static std::vector< double > myEdgeSpeeds
 The container of edge speeds.
 
static std::vector< TimeAndCountmyEdgeTravelTimes
 Sum of travel times experienced by equipped vehicles for each edge.
 
static CommandmyEdgeWeightSettingCommand = nullptr
 The weights adaptation/overwriting command.
 
static bool myHaveRoutingThreads
 
static SUMOTime myLastAdaptation = -1
 Information when the last edge weight adaptation occurred.
 
static double myMinEdgePriority
 Minimum priority for all edges.
 
static std::vector< std::vector< double > > myPastEdgeBikeSpeeds
 
static std::vector< std::vector< double > > myPastEdgeSpeeds
 The container of past edge speeds (when using a simple moving average)
 
static double myPriorityFactor
 Coefficient for factoring edge priority into routing weight.
 
static MSRouterProvidermyRouterProvider = nullptr
 The router to use.
 
static std::map< std::thread::id, SumoRNG * > myThreadRNGs
 
static bool myWithTaz
 whether taz shall be used at initial rerouting
 

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 66 of file MSRoutingEngine.h.

Member Typedef Documentation

◆ TimeAndCount

typedef std::pair<SUMOTime, int> MSRoutingEngine::TimeAndCount
private

Definition at line 221 of file MSRoutingEngine.h.

Constructor & Destructor Documentation

◆ MSRoutingEngine()

MSRoutingEngine::MSRoutingEngine ( const MSRoutingEngine )
private

Invalidated copy constructor.

Member Function Documentation

◆ _initEdgeWeights()

void MSRoutingEngine::_initEdgeWeights ( std::vector< double > &  edgeSpeeds,
std::vector< std::vector< double > > &  pastEdgeSpeeds 
)
staticprivate

◆ 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 222 of file MSRoutingEngine.cpp.

References OutputDevice::closeTag(), DEBUG_COND, DELTA_T, OutputDevice::getDeviceByOption(), MSNet::getEdgeControl(), MSEdgeControl::getEdges(), getEffortBike(), MSNet::getInstance(), OptionsCont::getOptions(), MSGlobals::gWeightsSeparateTurns, initEdgeWeights(), OptionsCont::isSet(), myAdaptationInterval, myAdaptationSteps, myAdaptationStepsIndex, myAdaptationWeight, myBikeSpeeds, myCachedRoutes, myEdgeBikeSpeeds, myEdgeSpeeds, myEffortFunc, myLastAdaptation, myPastEdgeBikeSpeeds, myPastEdgeSpeeds, OutputDevice::openTag(), patchSpeedForTurns(), SIMTIME, STEPS2TIME, SUMO_ATTR_BEGIN, SUMO_ATTR_END, SUMO_ATTR_ID, SUMO_TAG_EDGE, SUMO_TAG_INTERVAL, SVC_BICYCLE, SVC_PASSENGER, and OutputDevice::writeAttr().

Referenced by initWeightUpdate().

Here is the caller graph for this function:

◆ addEdgeTravelTime()

void MSRoutingEngine::addEdgeTravelTime ( const MSEdge edge,
const SUMOTime  travelTime 
)
static

record actual travel time for an edge

Definition at line 517 of file MSRoutingEngine.cpp.

References MSEdge::getNumericalID(), and myEdgeTravelTimes.

Referenced by MSDevice_Routing::notifyEnter().

Here is the caller graph for this function:

◆ cleanup()

void MSRoutingEngine::cleanup ( )
static

deletes the router instance

Definition at line 573 of file MSRoutingEngine.cpp.

References MSGlobals::gNumThreads, myAdaptationInterval, myAdaptationStepsIndex, myCachedRoutes, myEdgeBikeSpeeds, myEdgeSpeeds, myEdgeTravelTimes, myPastEdgeBikeSpeeds, myPastEdgeSpeeds, and myRouterProvider.

Referenced by MSDevice::cleanupAll().

Here is the caller graph for this function:

◆ getAssumedSpeed()

double MSRoutingEngine::getAssumedSpeed ( const MSEdge edge,
const SUMOVehicle veh 
)
static

return current travel speed assumption

Definition at line 216 of file MSRoutingEngine.cpp.

References MSEdge::getLength(), and myEffortFunc.

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

Here is the caller graph for this function:

◆ getCachedRoute()

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

return the cached route or nullptr on miss

Definition at line 368 of file MSRoutingEngine.cpp.

References myCachedRoutes.

Referenced by MSDevice_Routing::preInsertionReroute().

Here is the caller graph for this function:

◆ 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 163 of file MSRoutingEngine.cpp.

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

Referenced by getEffortExtra(), MSDevice_Routing::getParameter(), and initRouter().

Here is the caller graph for this function:

◆ getEffortBike()

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

Definition at line 173 of file MSRoutingEngine.cpp.

References MSEdge::getLength(), MSEdge::getMinimumTravelTime(), MSEdge::getNumericalID(), MAX2(), and myEdgeBikeSpeeds.

Referenced by adaptEdgeEfforts(), and getEffortExtra().

Here is the caller graph for this function:

◆ getEffortExtra()

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

Definition at line 198 of file MSRoutingEngine.cpp.

References getEffort(), getEffortBike(), MSEdge::getPriority(), getThreadRNG(), SUMOTrafficObject::getVClass(), gWeightsRandomFactor, myBikeSpeeds, myEdgePriorityRange, myMinEdgePriority, myPriorityFactor, RandHelper::rand(), and SVC_BICYCLE.

Referenced by MSNet::getTravelTime(), and initRouter().

Here is the caller graph for this function:

◆ getIntermodalRouterTT()

MSTransportableRouter & MSRoutingEngine::getIntermodalRouterTT ( const int  rngIndex,
const MSEdgeVector prohibited = MSEdgeVector() 
)
static

return the person router instance

Definition at line 549 of file MSRoutingEngine.cpp.

References MSNet::getEdgeControl(), MSNet::getInstance(), RouterProvider< E, L, N, V >::getIntermodalRouter(), MFXWorkerThread::Pool::getWorkers(), MSGlobals::gNumThreads, initEdgeWeights(), initRouter(), initWeightUpdate(), myRouterProvider, MFXWorkerThread::Pool::size(), SVC_PEDESTRIAN, and UNUSED_PARAMETER.

Referenced by reroute(), and MSTriggeredRerouter::triggerRouting().

Here is the caller graph for this function:

◆ getLastAdaptation()

static SUMOTime MSRoutingEngine::getLastAdaptation ( )
inlinestatic

Information when the last edge weight adaptation occurred.

Definition at line 80 of file MSRoutingEngine.h.

References myLastAdaptation.

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

Here is the caller graph for this function:

◆ getRouterTT()

◆ getThreadRNG()

SumoRNG * MSRoutingEngine::getThreadRNG ( )
staticprivate

returns RNG associated with the current thread

Definition at line 182 of file MSRoutingEngine.cpp.

References myHaveRoutingThreads, myThreadRNGs, and toString().

Referenced by getEffortExtra().

Here is the caller graph for this function:

◆ hasEdgeUpdates()

static bool MSRoutingEngine::hasEdgeUpdates ( )
inlinestatic

returns whether any edge weight updates will take place

Definition at line 75 of file MSRoutingEngine.h.

References myEdgeWeightSettingCommand.

Referenced by MSDevice_Routing::MSDevice_Routing().

Here is the caller graph for this function:

◆ initEdgeWeights()

void MSRoutingEngine::initEdgeWeights ( SUMOVehicleClass  svc)
static

initialize the edge weights if not done before

Definition at line 106 of file MSRoutingEngine.cpp.

References _initEdgeWeights(), myBikeSpeeds, myEdgeBikeSpeeds, myEdgeSpeeds, myPastEdgeBikeSpeeds, myPastEdgeSpeeds, and SVC_BICYCLE.

Referenced by adaptEdgeEfforts(), getIntermodalRouterTT(), getRouterTT(), MSDevice_Routing::reroute(), and MSTransportableDevice_Routing::reroute().

Here is the caller graph for this function:

◆ initRouter()

◆ initWeightUpdate()

◆ isEnabled()

static bool MSRoutingEngine::isEnabled ( )
inlinestatic

returns whether any routing actions take place

Definition at line 104 of file MSRoutingEngine.h.

References myAdaptationInterval, and myWithTaz.

Referenced by MSInsertionControl::determineCandidates(), and MSInsertionControl::emitVehicles().

Here is the caller graph for this function:

◆ operator=()

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

Invalidated assignment operator.

◆ patchSpeedForTurns()

double MSRoutingEngine::patchSpeedForTurns ( const MSEdge edge,
double  currSpeed 
)
staticprivate

Definition at line 300 of file MSRoutingEngine.cpp.

References DEBUG_COND, Named::getID(), MSEdge::getLength(), MSEdge::getViaSuccessors(), MSGlobals::gWeightsSeparateTurns, MAX2(), myAdaptationSteps, myAdaptationStepsIndex, myEdgeSpeeds, myEdgeTravelTimes, myPastEdgeSpeeds, SIMTIME, and STEPS2TIME.

Referenced by adaptEdgeEfforts().

Here is the caller graph for this function:

◆ reroute() [1/2]

void MSRoutingEngine::reroute ( MSTransportable t,
const SUMOTime  currentTime,
const std::string &  info,
const bool  onInit = false,
const bool  silent = false,
const MSEdgeVector prohibited = MSEdgeVector() 
)
static

◆ reroute() [2/2]

void MSRoutingEngine::reroute ( SUMOVehicle vehicle,
const SUMOTime  currentTime,
const std::string &  info,
const bool  onInit = false,
const bool  silent = false,
const MSEdgeVector prohibited = MSEdgeVector() 
)
static

initiate the rerouting, create router / thread pool on first use

Definition at line 445 of file MSRoutingEngine.cpp.

References MFXWorkerThread::Pool::add(), MSNet::getEdgeControl(), MSNet::getInstance(), SUMOTrafficObject::getVClass(), RouterProvider< E, L, N, V >::getVehicleRouter(), initRouter(), myRouterProvider, myWithTaz, SUMOVehicle::reroute(), and MFXWorkerThread::Pool::size().

Referenced by MSDevice_Routing::reroute(), MSTransportableDevice_Routing::reroute(), and MSRailSignal::LinkInfo::reroute().

Here is the caller graph for this function:

◆ setEdgeTravelTime()

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

adapt the known travel time for an edge

Definition at line 512 of file MSRoutingEngine.cpp.

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

Referenced by MSDevice_Routing::setParameter().

Here is the caller graph for this function:

◆ withTaz()

static bool MSRoutingEngine::withTaz ( )
inlinestatic

whether taz-routing is enabled

Definition at line 140 of file MSRoutingEngine.h.

References myWithTaz.

Referenced by MSDevice_Routing::notifyEnter().

Here is the caller graph for this function:

Field Documentation

◆ myAdaptationInterval

SUMOTime MSRoutingEngine::myAdaptationInterval = -1
staticprivate

At which time interval the edge weights get updated.

Definition at line 210 of file MSRoutingEngine.h.

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

◆ myAdaptationSteps

int MSRoutingEngine::myAdaptationSteps
staticprivate

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

Definition at line 216 of file MSRoutingEngine.h.

Referenced by _initEdgeWeights(), adaptEdgeEfforts(), initWeightUpdate(), and patchSpeedForTurns().

◆ myAdaptationStepsIndex

int MSRoutingEngine::myAdaptationStepsIndex = 0
staticprivate

The current index in the pastEdgeSpeed ring-buffer.

Definition at line 219 of file MSRoutingEngine.h.

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

◆ myAdaptationWeight

double MSRoutingEngine::myAdaptationWeight
staticprivate

Information which weight prior edge efforts have.

Definition at line 207 of file MSRoutingEngine.h.

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

◆ myBikeSpeeds

bool MSRoutingEngine::myBikeSpeeds
staticprivate

whether separate speeds for bicycles shall be tracked

Definition at line 238 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), getEffortExtra(), initEdgeWeights(), and initRouter().

◆ myCachedRoutes

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

The container of pre-calculated routes.

Definition at line 247 of file MSRoutingEngine.h.

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

◆ myEdgeBikeSpeeds

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

Definition at line 225 of file MSRoutingEngine.h.

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

◆ myEdgePriorityRange

double MSRoutingEngine::myEdgePriorityRange
staticprivate

the difference between maximum and minimum priority for all edges

Definition at line 255 of file MSRoutingEngine.h.

Referenced by _initEdgeWeights(), and getEffortExtra().

◆ myEdgeSpeeds

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

◆ myEdgeTravelTimes

std::vector< MSRoutingEngine::TimeAndCount > MSRoutingEngine::myEdgeTravelTimes
staticprivate

Sum of travel times experienced by equipped vehicles for each edge.

Definition at line 228 of file MSRoutingEngine.h.

Referenced by _initEdgeWeights(), addEdgeTravelTime(), cleanup(), initWeightUpdate(), and patchSpeedForTurns().

◆ myEdgeWeightSettingCommand

Command * MSRoutingEngine::myEdgeWeightSettingCommand = nullptr
staticprivate

The weights adaptation/overwriting command.

Definition at line 204 of file MSRoutingEngine.h.

Referenced by hasEdgeUpdates(), and initWeightUpdate().

◆ myEffortFunc

SUMOAbstractRouter< MSEdge, SUMOVehicle >::Operation MSRoutingEngine::myEffortFunc = &MSRoutingEngine::getEffort
static

Definition at line 134 of file MSRoutingEngine.h.

Referenced by adaptEdgeEfforts(), getAssumedSpeed(), and initRouter().

◆ myHaveRoutingThreads

bool MSRoutingEngine::myHaveRoutingThreads
staticprivate

Definition at line 244 of file MSRoutingEngine.h.

Referenced by getThreadRNG(), and initRouter().

◆ myLastAdaptation

SUMOTime MSRoutingEngine::myLastAdaptation = -1
staticprivate

Information when the last edge weight adaptation occurred.

Definition at line 213 of file MSRoutingEngine.h.

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

◆ myMinEdgePriority

double MSRoutingEngine::myMinEdgePriority
staticprivate

Minimum priority for all edges.

Definition at line 253 of file MSRoutingEngine.h.

Referenced by _initEdgeWeights(), and getEffortExtra().

◆ myPastEdgeBikeSpeeds

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

Definition at line 232 of file MSRoutingEngine.h.

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

◆ myPastEdgeSpeeds

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

The container of past edge speeds (when using a simple moving average)

Definition at line 231 of file MSRoutingEngine.h.

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

◆ myPriorityFactor

double MSRoutingEngine::myPriorityFactor
staticprivate

Coefficient for factoring edge priority into routing weight.

Definition at line 250 of file MSRoutingEngine.h.

Referenced by _initEdgeWeights(), getEffortExtra(), and initRouter().

◆ myRouterProvider

MSRouterProvider * MSRoutingEngine::myRouterProvider = nullptr
staticprivate

The router to use.

Definition at line 241 of file MSRoutingEngine.h.

Referenced by cleanup(), getIntermodalRouterTT(), getRouterTT(), initRouter(), and reroute().

◆ myThreadRNGs

std::map< std::thread::id, SumoRNG * > MSRoutingEngine::myThreadRNGs
staticprivate

Definition at line 243 of file MSRoutingEngine.h.

Referenced by getThreadRNG().

◆ myWithTaz

bool MSRoutingEngine::myWithTaz
staticprivate

whether taz shall be used at initial rerouting

Definition at line 235 of file MSRoutingEngine.h.

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


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