Eclipse SUMO - Simulation of Urban MObility
|
#include <MSStoppingPlaceRerouter.h>
Public Types | |
typedef std::map< MSStoppingPlace *, StoppingPlaceParamMap_t, ComparatorIdLess > | StoppingPlaceMap_t |
typedef std::map< std::string, double > | StoppingPlaceParamMap_t |
typedef std::map< std::string, bool > | StoppingPlaceParamSwitchMap_t |
typedef std::pair< MSStoppingPlace *, bool > | StoppingPlaceVisible |
Public Member Functions | |
virtual StoppingPlaceParamMap_t | collectWeights (SUMOVehicle &veh) |
read target function weights for this vehicle | |
virtual bool | evaluateCustomComponents (SUMOVehicle &veh, double brakeGap, bool newDestination, MSStoppingPlace *alternative, double occupancy, double prob, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, StoppingPlaceParamMap_t &stoppingPlaceValues, ConstMSEdgeVector &newRoute, ConstMSEdgeVector &stoppingPlaceApproach, StoppingPlaceParamMap_t &maxValues, StoppingPlaceParamMap_t &addInput) |
Compute some custom target function components. | |
virtual bool | evaluateDestination (SUMOVehicle &veh, double brakeGap, bool newDestination, MSStoppingPlace *alternative, double occupancy, double prob, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, StoppingPlaceMap_t &stoppingPlaces, std::map< MSStoppingPlace *, ConstMSEdgeVector > &newRoutes, std::map< MSStoppingPlace *, ConstMSEdgeVector > &stoppingPlaceApproaches, StoppingPlaceParamMap_t &maxValues, StoppingPlaceParamMap_t &addInput, const int insertStopIndex=0, const bool keepCurrentStop=true) |
compute the target function for a single alternative | |
virtual double | getLastStepStoppingPlaceOccupancy (MSStoppingPlace *stoppingPlace)=0 |
Return the number of occupied places of the StoppingPlace from the previous time step. | |
virtual int | getNumberStoppingPlaceReroutes (SUMOVehicle &veh)=0 |
ask how many times already the vehicle has been rerouted to another stopping place | |
virtual SUMOAbstractRouter< MSEdge, SUMOVehicle > & | getRouter (SUMOVehicle &veh, const MSEdgeVector &prohibited={}) |
Provide the router to use (MSNet::getRouterTT or MSRoutingEngine) | |
virtual double | getStoppingPlaceCapacity (MSStoppingPlace *stoppingPlace)=0 |
Return the number of places the StoppingPlace provides. | |
virtual double | getStoppingPlaceOccupancy (MSStoppingPlace *stoppingPlace)=0 |
Return the number of occupied places of the StoppingPlace. | |
double | getWeight (SUMOVehicle &veh, const std::string param, const double defaultWeight, const bool warn=false) |
read the value of a stopping place search param, e.g. a component weight factor | |
MSStoppingPlaceRerouter (SumoXMLTag stoppingType, std::string paramPrefix="", bool checkValidity=false, bool checkVisibility=true, StoppingPlaceParamMap_t addEvalParams={}, StoppingPlaceParamSwitchMap_t addInvertParams={}) | |
Constructor. | |
virtual void | rememberBlockedStoppingPlace (SUMOVehicle &veh, const MSStoppingPlace *stoppingPlace, bool blocked)=0 |
store the blocked stopping place in the vehicle | |
virtual void | rememberStoppingPlaceScore (SUMOVehicle &veh, MSStoppingPlace *place, const std::string &score)=0 |
store the stopping place score in the vehicle | |
MSStoppingPlace * | reroute (std::vector< StoppingPlaceVisible > &stoppingPlaceCandidates, const std::vector< double > &probs, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute, StoppingPlaceParamMap_t &scores, const MSEdgeVector &closedEdges={}, const int insertStopIndex=0, const bool keepCurrentStop=true) |
main method to trigger the rerouting to the "best" StoppingPlace according to the custom evaluation function | |
virtual void | resetStoppingPlaceScores (SUMOVehicle &veh)=0 |
forget all stopping place score for this vehicle | |
virtual SUMOTime | sawBlockedStoppingPlace (SUMOVehicle &veh, MSStoppingPlace *place, bool local)=0 |
ask the vehicle when it has seen the stopping place | |
virtual void | setNumberStoppingPlaceReroutes (SUMOVehicle &veh, int value)=0 |
update the number of reroutes for the vehicle | |
virtual bool | useStoppingPlace (MSStoppingPlace *stoppingPlace) |
Whether the stopping place should be included in the search (can be used to add an additional filter) | |
virtual bool | validComponentValues (StoppingPlaceParamMap_t &stoppingPlaceValues) |
Whether the stopping place should be discarded due to its results from the component evaluation (allows to check for min/max thresholds and other non-linear relations) | |
virtual | ~MSStoppingPlaceRerouter () |
Static Public Member Functions | |
static double | getTargetValue (const StoppingPlaceParamMap_t &absValues, const StoppingPlaceParamMap_t &maxValues, const StoppingPlaceParamMap_t &weights, const StoppingPlaceParamSwitchMap_t &norm, const StoppingPlaceParamSwitchMap_t &invert) |
compute the scalar target function value by means of a linear combination of all components/weights after normalising and optionally inverting the values | |
static void | updateMaxValues (StoppingPlaceParamMap_t &stoppingPlaceValues, StoppingPlaceParamMap_t &maxValues) |
keep track of the maximum values of each component | |
Protected Member Functions | |
const MSRouteIterator | determineRerouteOrigin (SUMOVehicle &veh, int insertStopIndex) |
Determine the rerouting origin edge (not necessarily the current edge of the vehicle!) | |
void | readEvaluationWeights (SUMOVehicle &veh, StoppingPlaceParamMap_t &stoppingPlaceParams, StoppingPlaceParamMap_t &stoppingPlaceDefaults, StoppingPlaceParamMap_t &maxValues) |
Ask the vehicle about the relevant rerouting parameters and initiate the maximum value data structure. | |
Protected Attributes | |
bool | myCheckValidity |
const bool | myConsiderDestVisibility |
StoppingPlaceParamMap_t | myEvalParams |
StoppingPlaceParamSwitchMap_t | myInvertParams |
StoppingPlaceParamSwitchMap_t | myNormParams |
const std::string | myParamPrefix |
const SumoXMLTag | myStoppingType |
Private Member Functions | |
MSStoppingPlaceRerouter ()=delete | |
Constructor. | |
Definition at line 128 of file MSStoppingPlaceRerouter.h.
typedef std::map<MSStoppingPlace*, StoppingPlaceParamMap_t, ComparatorIdLess> MSStoppingPlaceRerouter::StoppingPlaceMap_t |
Definition at line 132 of file MSStoppingPlaceRerouter.h.
typedef std::map<std::string, double> MSStoppingPlaceRerouter::StoppingPlaceParamMap_t |
Definition at line 130 of file MSStoppingPlaceRerouter.h.
typedef std::map<std::string, bool> MSStoppingPlaceRerouter::StoppingPlaceParamSwitchMap_t |
Definition at line 131 of file MSStoppingPlaceRerouter.h.
typedef std::pair<MSStoppingPlace*, bool> MSStoppingPlaceRerouter::StoppingPlaceVisible |
Definition at line 133 of file MSStoppingPlaceRerouter.h.
MSStoppingPlaceRerouter::MSStoppingPlaceRerouter | ( | SumoXMLTag | stoppingType, |
std::string | paramPrefix = "" , |
||
bool | checkValidity = false , |
||
bool | checkVisibility = true , |
||
StoppingPlaceParamMap_t | addEvalParams = {} , |
||
StoppingPlaceParamSwitchMap_t | addInvertParams = {} |
||
) |
Constructor.
Definition at line 37 of file MSStoppingPlaceRerouter.cpp.
References myEvalParams, myInvertParams, and myNormParams.
|
inlinevirtual |
Definition at line 139 of file MSStoppingPlaceRerouter.h.
|
privatedelete |
Constructor.
|
virtual |
read target function weights for this vehicle
Definition at line 557 of file MSStoppingPlaceRerouter.cpp.
References getWeight(), and myEvalParams.
Referenced by reroute().
|
inlineprotected |
Determine the rerouting origin edge (not necessarily the current edge of the vehicle!)
Definition at line 288 of file MSStoppingPlaceRerouter.h.
References MSStop::edge, SUMOVehicle::getRerouteOrigin(), SUMOVehicle::getStops(), and MIN2().
Referenced by evaluateDestination().
|
virtual |
Compute some custom target function components.
[in] | veh | the concerned vehicle |
[in] | brakeGap | the distance before which the vehicle cannot stop |
[in] | newDestination | whether the destination changed |
[in] | alternative | the stopping place to evaluate |
[in] | occupancy | occupancy of the stopping place |
[in] | router | the router to use for evaluation if needed |
[in,out] | stoppingPlaceValues | the data structure to write the evaluation values to |
[in] | newRoute | the complete route to the destination passing by the stopping place |
[in] | stoppingPlaceApproach | the route to the stopping place |
[in] | maxValues | the maximum values of the components |
[in] | addInput | external input data |
Reimplemented in MSDevice_StationFinder.
Definition at line 530 of file MSStoppingPlaceRerouter.cpp.
Referenced by evaluateDestination().
|
virtual |
compute the target function for a single alternative
[in] | veh | the concerned vehicle |
[in] | brakeGap | the distance before which the vehicle cannot stop |
[in] | newDestination | whether the destination changed |
[in] | alternative | the stopping place to evaluate |
[in] | occupancy | occupancy of the stopping place |
[in] | prob | the predefined probability of this stopping place |
[in] | router | the router to use for evaluation if needed |
[in,out] | stoppingPlaces | the data structure to write the evaluation values to |
[in,out] | newRoutes | the data structure to write the chosen route to/from the stopping place to |
[in,out] | stoppingPlaceApproaches | the data structure to write the chosen route to the stopping place to |
[in,out] | maxValues | maximum values for all evaluation components |
[in] | addInput | external input data |
[in] | insertStopIndex | the stop index where the new StoppingPlace should be inserted |
[in] | keepCurrentStop | whether the current stop at the given stopp index should still be served after the new one |
Definition at line 389 of file MSStoppingPlaceRerouter.cpp.
References MSRoute::begin(), SUMOAbstractRouter< E, V >::compute(), RGBColor::DEFAULT_COLOR, determineRerouteOrigin(), MSRoute::end(), evaluateCustomComponents(), SUMOVehicle::getArrivalPos(), MSStoppingPlace::getBeginLanePosition(), MSRoute::getColor(), SUMOVehicle::getCurrentRouteEdge(), MSRoute::getDistanceBetween(), MSLane::getEdge(), SUMOTrafficObject::getEdge(), MSRoute::getEdges(), MSStoppingPlace::getEndLanePosition(), Named::getID(), MSNet::getInstance(), MSStoppingPlace::getLane(), MSRoute::getLastEdge(), MSStoppingPlace::getLastFreePos(), MSLane::getLength(), SUMOTrafficObject::getPositionOnLane(), SUMOVehicle::getRoute(), MSLane::getSpeedLimit(), SUMOVehicle::getStopIndices(), getStoppingPlaceCapacity(), getStoppingPlaceOccupancy(), MSRoute::getStops(), MSGlobals::gUsingInternalLanes, MSNet::hasInternalLinks(), MAX2(), myCheckValidity, myParamPrefix, SUMOAbstractRouter< E, V >::recomputeCosts(), rememberStoppingPlaceScore(), SIMSTEP, MSRoute::size(), time2string(), TL, updateMaxValues(), validComponentValues(), and WRITE_WARNINGF.
Referenced by reroute().
|
pure virtual |
Return the number of occupied places of the StoppingPlace from the previous time step.
Implemented in MSTriggeredRerouter, and MSDevice_StationFinder.
Referenced by reroute().
|
pure virtual |
ask how many times already the vehicle has been rerouted to another stopping place
Implemented in MSTriggeredRerouter, and MSDevice_StationFinder.
Referenced by reroute().
|
virtual |
Provide the router to use (MSNet::getRouterTT or MSRoutingEngine)
Reimplemented in MSDevice_StationFinder.
Definition at line 551 of file MSStoppingPlaceRerouter.cpp.
References MSNet::getInstance(), SUMOTrafficObject::getRNGIndex(), and MSNet::getRouterTT().
Referenced by reroute().
|
pure virtual |
Return the number of places the StoppingPlace provides.
Implemented in MSTriggeredRerouter, and MSDevice_StationFinder.
Referenced by evaluateDestination(), and reroute().
|
pure virtual |
Return the number of occupied places of the StoppingPlace.
Implemented in MSTriggeredRerouter, and MSDevice_StationFinder.
Referenced by evaluateDestination(), and reroute().
|
static |
compute the scalar target function value by means of a linear combination of all components/weights after normalising and optionally inverting the values
[in] | absValues | the component values |
[in] | maxValues | max values for all components |
[in] | weights | weight factors for all components |
[in] | norm | which component should be normalised |
[in] | invert | which component should be inverted |
Definition at line 606 of file MSStoppingPlaceRerouter.cpp.
Referenced by reroute().
double MSStoppingPlaceRerouter::getWeight | ( | SUMOVehicle & | veh, |
const std::string | param, | ||
const double | defaultWeight, | ||
const bool | warn = false |
||
) |
read the value of a stopping place search param, e.g. a component weight factor
[in] | veh | the concerned vehicle |
[in] | param | the name of the stopping place search param, excluding the param prefix (e.g. "parking.") |
[in] | defaultWeight | value to return in case the param hasn't been defined for the vehicle |
[in] | warn | whether a warning message shall be issued if the param is not defined for the vehicle |
Definition at line 569 of file MSStoppingPlaceRerouter.cpp.
References Named::getID(), MSVehicleType::getParameter(), SUMOTrafficObject::getParameter(), Parameterised::getParameter(), SUMOTrafficObject::getVehicleType(), Parameterised::hasParameter(), myParamPrefix, TL, StringUtils::toDouble(), toString(), WRITE_MESSAGEF, and WRITE_WARNINGF.
Referenced by collectWeights(), MSDevice_StationFinder::findChargingStation(), readEvaluationWeights(), and reroute().
|
inlineprotected |
Ask the vehicle about the relevant rerouting parameters and initiate the maximum value data structure.
Definition at line 277 of file MSStoppingPlaceRerouter.h.
References getWeight().
|
pure virtual |
store the blocked stopping place in the vehicle
Implemented in MSTriggeredRerouter, and MSDevice_StationFinder.
Referenced by reroute().
|
pure virtual |
store the stopping place score in the vehicle
Implemented in MSTriggeredRerouter, and MSDevice_StationFinder.
Referenced by evaluateDestination(), and reroute().
MSStoppingPlace * MSStoppingPlaceRerouter::reroute | ( | std::vector< StoppingPlaceVisible > & | stoppingPlaceCandidates, |
const std::vector< double > & | probs, | ||
SUMOVehicle & | veh, | ||
bool & | newDestination, | ||
ConstMSEdgeVector & | newRoute, | ||
StoppingPlaceParamMap_t & | scores, | ||
const MSEdgeVector & | closedEdges = {} , |
||
const int | insertStopIndex = 0 , |
||
const bool | keepCurrentStop = true |
||
) |
main method to trigger the rerouting to the "best" StoppingPlace according to the custom evaluation function
[in] | veh | the concerned vehicle |
[in] | stoppingPlaceCandidates | stopping places to choose from and whether they are visible for the vehicle |
[in] | probs | probabilities of all candidate stopping places |
[in] | newDestination | whether the destination changed |
[out] | newRoute | the route to/from the chosen stopping place is stored here |
[in,out] | scores | input score values from external source and get scores of all components of the "best" StoppingPlace |
[in] | closedEdges | edges to avoid during routing |
[in] | insertStopIndex | the stop index where the new StoppingPlace should be inserted |
[in] | keepCurrentStop | whether the current stop at the given stopp index should still be served after the new one |
Definition at line 51 of file MSStoppingPlaceRerouter.cpp.
References collectWeights(), DEBUGCOND, evaluateDestination(), SUMOVehicle::getArrivalPos(), MSStoppingPlace::getBeginLanePosition(), SUMOVehicle::getBrakeGap(), MSLane::getEdge(), SUMOTrafficObject::getEdge(), MSStoppingPlace::getEndLanePosition(), Named::getID(), Named::getIDSecure(), MSStoppingPlace::getLane(), SUMOTrafficObject::getLane(), MSRoute::getLastEdge(), getLastStepStoppingPlaceOccupancy(), SUMOVehicle::getNextParkingArea(), getNumberStoppingPlaceReroutes(), SUMOTrafficObject::getPositionOnLane(), SUMOTrafficObject::getRNG(), SUMOVehicle::getRoute(), getRouter(), getStoppingPlaceCapacity(), getStoppingPlaceOccupancy(), SUMOVehicle::getStops(), getTargetValue(), getWeight(), joinToString(), MIN2(), myConsiderDestVisibility, myInvertParams, myNormParams, myStoppingType, RandHelper::rand(), rememberBlockedStoppingPlace(), rememberStoppingPlaceScore(), resetStoppingPlaceScores(), sawBlockedStoppingPlace(), setNumberStoppingPlaceReroutes(), SIMSTEP, SIMTIME, STEPS2TIME, SUMO_TAG_PARKING_AREA, TIME2STEPS, time2string(), TL, toString(), useStoppingPlace(), and WRITE_WARNINGF.
Referenced by MSDevice_StationFinder::findChargingStation(), and MSTriggeredRerouter::rerouteParkingArea().
|
pure virtual |
forget all stopping place score for this vehicle
Implemented in MSTriggeredRerouter, and MSDevice_StationFinder.
Referenced by reroute().
|
pure virtual |
ask the vehicle when it has seen the stopping place
Implemented in MSTriggeredRerouter, and MSDevice_StationFinder.
Referenced by reroute().
|
pure virtual |
update the number of reroutes for the vehicle
Implemented in MSTriggeredRerouter, and MSDevice_StationFinder.
Referenced by reroute().
|
static |
keep track of the maximum values of each component
[in] | stoppingPlaceValues | the target function component values of a vehicle |
[in,out] | maxValues | stores the maximum values of the given stoppingPlaceValues and previously given maxValues |
Definition at line 596 of file MSStoppingPlaceRerouter.cpp.
Referenced by evaluateDestination().
|
virtual |
Whether the stopping place should be included in the search (can be used to add an additional filter)
Reimplemented in MSDevice_StationFinder.
Definition at line 545 of file MSStoppingPlaceRerouter.cpp.
Referenced by reroute().
|
virtual |
Whether the stopping place should be discarded due to its results from the component evaluation (allows to check for min/max thresholds and other non-linear relations)
Reimplemented in MSDevice_StationFinder.
Definition at line 539 of file MSStoppingPlaceRerouter.cpp.
Referenced by evaluateDestination().
|
protected |
Definition at line 309 of file MSStoppingPlaceRerouter.h.
Referenced by evaluateDestination(), and MSDevice_StationFinder::findChargingStation().
|
protected |
Definition at line 310 of file MSStoppingPlaceRerouter.h.
Referenced by reroute().
|
protected |
Definition at line 311 of file MSStoppingPlaceRerouter.h.
Referenced by collectWeights(), and MSStoppingPlaceRerouter().
|
protected |
Definition at line 313 of file MSStoppingPlaceRerouter.h.
Referenced by MSStoppingPlaceRerouter(), and reroute().
|
protected |
Definition at line 312 of file MSStoppingPlaceRerouter.h.
Referenced by MSStoppingPlaceRerouter(), and reroute().
|
protected |
Definition at line 308 of file MSStoppingPlaceRerouter.h.
Referenced by evaluateDestination(), and getWeight().
|
protected |
Definition at line 307 of file MSStoppingPlaceRerouter.h.
Referenced by reroute().