68#define DEBUGCOND(veh) (veh.isSelected())
73#define DEFAULT_PRIO_OVERTAKER 1
74#define DEFAULT_PRIO_OVERTAKEN 0.001
89 const MSEdgeVector& edges,
double prob,
bool off,
bool optional,
90 SUMOTime timeThreshold,
const std::string& vTypes,
const Position& pos,
const double radius) :
96 myUserProbability(prob),
97 myAmInUserMode(false),
98 myAmOptional(optional),
101 myTimeThreshold(timeThreshold),
102 myHaveParkProbs(false),
103 myHaveClosingUntil(false)
107 for (
const MSEdge*
const e : edges) {
111 for (
MSLane*
const lane : e->getLanes()) {
112 lane->addMoveReminder(
this);
122 myPosition = edges.front()->getLanes()[0]->getShape()[0];
156 if (dest ==
"keepDestination") {
158 }
else if (dest ==
"terminateRoute") {
171 throw ProcessError(
TLF(
"rerouter '%': Attribute 'probability' for destination '%' is negative (must not).",
getID(), dest));
181 if (closedEdge ==
nullptr) {
200 if (closedLane ==
nullptr) {
217 if (routeStr ==
"") {
218 throw ProcessError(
TLF(
"rerouter '%': routeProbReroute has no alternative route id.",
getID()));
221 if (route ==
nullptr) {
222 throw ProcessError(
TLF(
"rerouter '%': Alternative route '%' does not exist.",
getID(), routeStr));
232 throw ProcessError(
TLF(
"rerouter '%': Attribute 'probability' for alternative route '%' is negative (must not).",
getID(), routeStr));
240 if (parkingarea ==
"") {
241 throw ProcessError(
TLF(
"rerouter '%': parkingAreaReroute requires a parkingArea id.",
getID()));
254 throw ProcessError(
TLF(
"rerouter '%': Attribute 'probability' for parkingArea '%' is negative (must not).",
getID(), parkingarea));
269 if (via ==
nullptr) {
279 throw ProcessError(
TLF(
"rerouter '%': Attribute 'probability' for via '%' is negative (must not).",
getID(), viaID));
289 for (
const std::string& edgeID : attrs.
get<std::vector<std::string> >(
SUMO_ATTR_MAIN,
getID().c_str(), ok)) {
291 if (edge ==
nullptr) {
294 oloc.
main.push_back(edge);
295 oloc.
cMain.push_back(edge);
299 if (edge ==
nullptr) {
302 oloc.
siding.push_back(edge);
309 for (
auto it = oloc.
cSiding.begin(); it != oloc.
cSiding.end(); it++) {
327 if (stop ==
nullptr) {
339 bool allowAll =
true;
355 affected.insert(&settings.first->getEdge());
361 if (closingBegin < simBegin && myParsedRerouteInterval.end > simBegin) {
381 bool updateVehicles =
false;
383 if (i.begin == currentTime && !(i.closed.empty() && i.closedLanes.empty()) ) {
384 for (
const auto& settings : i.closed) {
386 for (
MSLane* lane : settings.first->getLanes()) {
388 lane->setPermissions(settings.second.first, i.id);
390 settings.first->rebuildAllowedLanes();
391 updateVehicles =
true;
394 for (std::pair<MSLane*, SVCPermissions> settings : i.closedLanes) {
395 settings.first->setPermissions(settings.second, i.id);
396 settings.first->getEdge().rebuildAllowedLanes();
397 updateVehicles =
true;
402 if (i.end == currentTime && !(i.closed.empty() && i.closedLanes.empty()) ) {
403 for (
auto settings : i.closed) {
405 for (
MSLane* lane : settings.first->getLanes()) {
406 lane->resetPermissions(i.id);
409 settings.first->rebuildAllowedLanes();
410 updateVehicles =
true;
413 for (std::pair<MSLane*, SVCPermissions> settings : i.closedLanes) {
414 settings.first->resetPermissions(i.id);
415 settings.first->getEdge().rebuildAllowedLanes();
416 updateVehicles =
true;
420 if (updateVehicles) {
425 e->rebuildAllowedTargets();
435 if (ri.begin <= time && ri.end > time) {
438 ri.edgeProbs.getOverallProb() > 0 ||
440 ri.routeProbs.getOverallProb() > 0 ||
442 ri.parkProbs.getOverallProb() > 0 ||
444 ri.stopAlternatives.size() > 0) {
447 if (!ri.closed.empty() || !ri.closedLanesAffected.empty() || !ri.overtakeLocations.empty()) {
448 const std::set<SUMOTrafficObject::NumericalID>& edgeIndices = obj.
getUpcomingEdgeIDs();
449 if (
affected(edgeIndices, ri.getClosedEdges())
450 ||
affected(edgeIndices, ri.closedLanesAffected)) {
454 if (
affected(edgeIndices, oloc.main)) {
469 if (ri.begin <= time && ri.end > time) {
470 if (ri.edgeProbs.getOverallProb() != 0 || ri.routeProbs.getOverallProb() != 0 || ri.parkProbs.getOverallProb() != 0
471 || !ri.closed.empty() || !ri.closedLanesAffected.empty() || !ri.overtakeLocations.empty()) {
514 if (rerouteDef ==
nullptr) {
545 bool newDestination =
false;
549 if (newParkingArea !=
nullptr) {
552 p->rerouteParkingArea(oldParkingArea, newParkingArea);
571 const double savings = previousCost - routeCost;
577 std::string errorMsg;
588 +
"' could not reroute to new parkingArea '" + newParkingArea->
getID()
604 double bestSavings = -std::numeric_limits<double>::max();
608 std::pair<const SUMOVehicle*, MSRailSignal*> best_overtaker_signal(
nullptr,
nullptr);
611 std::vector<std::pair<int, int> > sortedLocs;
614 if (veh.
getLength() > oloc.sidingLength) {
618 if (mainStart == oldEdges.end()
627 sortedLocs.push_back(std::make_pair(-(
int)(mainStart - veh.
getCurrentRouteEdge()), index));
629 std::sort(sortedLocs.begin(), sortedLocs.end());
630 for (
const auto& item : sortedLocs) {
634 std::pair<const SUMOVehicle*, MSRailSignal*> overtaker_signal =
overtakingTrain(veh, mainStart, oloc, netSaving);
635 if (overtaker_signal.first !=
nullptr && netSaving > bestSavings) {
636 bestSavings = netSaving;
638 best_overtaker_signal = overtaker_signal;
639 bestMainStart = mainStart;
640#ifdef DEBUG_OVERTAKING
641 std::cout <<
" newBest index=" << bestIndex <<
" saving=" << bestSavings <<
"\n";
645 if (bestIndex >= 0) {
654 newEdges.insert(newEdges.end(), oloc.
siding.begin(), oloc.
siding.end());
655 newEdges.insert(newEdges.end(), bestMainStart + oloc.
main.size(), oldEdges.end());
677 if (newRoute !=
nullptr) {
680 std::cout <<
" replacedRoute from routeDist " << newRoute->getID() <<
"\n";
686 const MSEdge* newEdge = lastEdge;
688 double newArrivalPos = -1;
690 const bool destUnreachable = std::find(closed.begin(), closed.end(), lastEdge) != closed.end();
691 bool keepDestination =
false;
696 assert(newEdge !=
nullptr);
698 keepDestination =
true;
706 WRITE_WARNINGF(
TL(
"Cannot keep destination edge '%' for vehicle '%' due to closed edges. Terminating route."), lastEdge->
getID(), tObject.
getID());
714 std::vector<MSTransportableRouter::TripItem> items;
723 WRITE_WARNINGF(
TL(
"Periodic rerouting and rerouting mode 8 for vehicle '%' are incompatible with closingReroute attribute 'until' in rerouter (vehicle may return to an invalid route."),
736 ok = veh.
reroute(now,
getID(), router,
false,
false, canChangeDest, newEdge);
738 if (!ok && !keepDestination && canChangeDest) {
742 while (!ok && edgeProbs2.
getVals().size() > 0) {
743 newEdge = edgeProbs2.
get();
757 ok = veh.
reroute(now,
getID(), router,
false,
false,
true, newEdge);
768 if (!rerouteDef->
isVia) {
770 if (
DEBUGCOND(tObject)) std::cout <<
" rerouting: newDest=" << newEdge->
getID()
772 <<
" newArrivalPos=" << newArrivalPos <<
" numClosed=" << rerouteDef->
closed.size()
773 <<
" destUnreachable=" << destUnreachable <<
" containsClosed=" << veh.
getRoute().
containsAnyOf(closed) <<
"\n";
775 if (ok && newArrivalPos != -1) {
789 if (!rerouteDef->
isVia) {
792 if (!it.edges.empty() && !edges.empty() && edges.back() == it.edges.front()) {
795 edges.insert(edges.end(), std::make_move_iterator(it.edges.begin()), std::make_move_iterator(it.edges.end()));
796 if (!edges.empty()) {
806 if (!prohibited.empty()) {
811 if (rerouteDef->
isVia && newEdge != lastEdge) {
814 if (!edges.empty()) {
820 router.
compute(newEdge, lastEdge, &veh, now, edges);
827 if (
DEBUGCOND(tObject)) std::cout <<
" rerouting: newDest=" << newEdge->
getID()
829 <<
" useNewRoute=" << useNewRoute <<
" newArrivalPos=" << newArrivalPos <<
" numClosed=" << rerouteDef->
closed.size()
830 <<
" destUnreachable=" << destUnreachable <<
" containsClosed=" << veh.
getRoute().
containsAnyOf(closed) <<
"\n";
832 if (useNewRoute && newArrivalPos != -1) {
838 bool success = !items.empty();
849 if (!it.edges.empty() && !edges.empty() && edges.back() == it.edges.front()) {
852 edges.insert(edges.end(), std::make_move_iterator(it.edges.begin()), std::make_move_iterator(it.edges.end()));
854 if (!edges.empty()) {
862 if (!prohibited.empty()) {
969 if (destStoppingPlace ==
nullptr) {
973 std::vector<StoppingPlaceVisible> parks;
975 if (cand.first->accepts(&veh)) {
976 parks.push_back(cand);
984std::pair<const SUMOVehicle*, MSRailSignal*>
986 ConstMSEdgeVector::const_iterator mainStart,
1003 auto itOnMain2 = route2.end();
1007 if (itOnMain2 != route2.end()) {
1013 auto itOnMain = mainStart + mainIndex;
1014 double timeToMain = 0;
1016 timeToMain += (*it)->getMinimumTravelTime(&veh);
1020 double timeToLastSignal2 = timeToMain2;
1022 timeToMain2 += (*it)->getMinimumTravelTime(veh2);
1025 timeToLastSignal2 = timeToMain2;
1026#ifdef DEBUG_OVERTAKING
1027 std::cout <<
" lastBeforeMain2 " << signal->getID() <<
"\n";
1031 double exitMainTime = timeToMain;
1032 double exitMainBlockTime2 = timeToMain2;
1033 double commonTime = 0;
1034 double commonTime2 = 0;
1036 auto exitMain2 = itOnMain2;
1038 const MSEdge* common =
nullptr;
1040 double vMinCommon2 = (*itOnMain2)->getVehicleMaxSpeed(veh2);
1041 while (itOnMain2 != route2.end()
1042 && itOnMain != route.end()
1043 && *itOnMain == *itOnMain2) {
1049 const bool onMain = nCommon < (int)
main.size() - mainIndex;
1051 exitMainTime = timeToMain + commonTime;
1053 if (firstAfterMain ==
nullptr) {
1054 exitMainBlockTime2 = timeToMain2 + commonTime2;
1058 if (!onMain && firstAfterMain ==
nullptr) {
1059 firstAfterMain = signal;
1060#ifdef DEBUG_OVERTAKING
1061 std::cout <<
" firstAfterMain " << signal->
getID() <<
"\n";
1071 commonTime += veh.
getLength() / vMaxLast;
1072 exitMainBlockTime2 += veh2->
getLength() / vMaxLast2;
1073 exitMain2 +=
MIN2(nCommon, (
int)
main.size() - mainIndex);
1074 double timeLoss2 =
MAX2(0.0, timeToMain + veh.
getLength() / oloc.
siding.front()->getVehicleMaxSpeed(&veh) - timeToLastSignal2);
1075 const double saving = timeToMain + commonTime - (timeToMain2 + commonTime2) - timeLoss2;
1076 const double loss = exitMainBlockTime2 - exitMainTime;
1081 netSaving = prio2 * (saving - accelTimeLoss2) - prio * (loss + accelTimeLoss);
1082#ifdef DEBUG_OVERTAKING
1084 <<
" sidingStart=" << oloc.
siding.front()->getID()
1085 <<
" ttm=" << timeToMain <<
" ttm2=" << timeToMain2
1086 <<
" nCommon=" << nCommon <<
" cT=" << commonTime <<
" cT2=" << commonTime2
1087 <<
" em=" << exitMainTime <<
" emb2=" << exitMainBlockTime2
1088 <<
" ttls2=" << timeToLastSignal2
1089 <<
" saving=" << saving <<
" loss=" << loss
1090 <<
" atl=" << accelTimeLoss <<
" atl2=" << accelTimeLoss2 <<
" tl2=" << timeLoss2
1091 <<
" prio=" << prio <<
" prio2=" << prio2 <<
" netSaving=" << netSaving <<
"\n";
1096 return std::make_pair(veh2, s);
1102 return std::make_pair(
nullptr,
nullptr);
1109#ifdef DEBUG_REROUTER
1122 if (sp == item.first) {
1128 if (cur ==
nullptr) {
1132#ifdef DEBUG_REROUTER
1136 if (stopped.empty()) {
1158 stoppedDuration = 0;
1160 stoppedDuration =
MAX2(stoppedDuration, veh->getStopDuration());
1163 if (stoppedDuration < 0) {
1169#ifdef DEBUG_REROUTER
1170 std::cout <<
SIMTIME <<
" " <<
getID() <<
" ego=" << ego.
getID() <<
" stopFree=" << stopFree <<
" scheduledArrival=" <<
time2string(scheduledArrival) <<
"\n";
1172 if (stopFree < scheduledArrival) {
1179#ifdef DEBUG_REROUTER
1180 std::cout <<
SIMTIME <<
" " <<
getID() <<
" ego=" << ego.
getID() <<
" stopFree=" << stopFree <<
" estimatedArrival=" <<
time2string(estimatedArrival) <<
"\n";
1182 if (stopFree < estimatedArrival) {
1188 bool newDestination;
1193#ifdef DEBUG_REROUTER
1196 if (alternative !=
nullptr) {
1233 std::string errorMsg;
1236 +
"' could not perform stationReroute to '" + alternative->
getID()
1249 if (signal !=
nullptr) {
1252 }
while (it != begin);
1260 for (
const MSLink* link : edge->
getLanes().front()->getLinkCont()) {
1261 if (link->getTLLogic() !=
nullptr) {
1275 for (
auto vTypeDist : vTypeDists) {
1287 for (
const MSEdge*
const e : closed) {
1288 if (edgeIndices.count(e->getNumericalID()) > 0) {
1301 std::set<MSEdge*> parkingRerouterEdges;
1302 std::map<MSParkingArea*, std::string, ComparatorIdLess> targetedParkingArea;
1304 bool hasParkingReroute =
false;
1306 if (interval.parkProbs.getOverallProb() > 0) {
1307 hasParkingReroute =
true;
1309 targetedParkingArea[
dynamic_cast<MSParkingArea*
>(pav.first)] = rr.first;
1313 if (hasParkingReroute) {
1314 parkingRerouterEdges.insert(rr.second->myEdges.begin(), rr.second->myEdges.end());
1317 for (
const auto& item : targetedParkingArea) {
1318 if (parkingRerouterEdges.count(&item.first->getLane().getEdge()) == 0) {
1319 WRITE_WARNINGF(
TL(
"ParkingArea '%' is targeted by rerouter '%' but doesn't have its own rerouter. This may cause parking search to abort."),
1320 item.first->getID(), item.second);
std::vector< const MSEdge * > ConstMSEdgeVector
std::vector< MSEdge * > MSEdgeVector
ConstMSEdgeVector::const_iterator MSRouteIterator
#define DEFAULT_PRIO_OVERTAKEN
#define DEFAULT_PRIO_OVERTAKER
assume that a faster train has more priority and a slower train doesn't matter
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::shared_ptr< const MSRoute > ConstMSRoutePtr
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
constexpr SUMOTime TIME2STEPS(double x)
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SVC_AUTHORITY
authorities vehicles
@ GIVEN
The arrival position is given.
@ DEFAULT
No information given; use default.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ SUMO_TAG_VIA_PROB_REROUTE
probability of a via reroute
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destination of a reroute
@ SUMO_TAG_OVERTAKING_REROUTE
decision point for rerouting to be overtaken
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
@ SUMO_TAG_STATION_REROUTE
decision point for switching trainStop/busStop within a station
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
const double INVALID_DOUBLE
invalid double
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
int main(int argc, char *argv[])
bool compute(const E *from, const E *to, const double departPos, const std::string &originStopID, const double arrivalPos, const std::string &stopID, const double speed, const V *const vehicle, const SUMOVTypeParameter &pars, const SVCPermissions modeSet, const SUMOTime msTime, std::vector< TripItem > &into, const double externalFactor=0.)
Builds the route between the given edges using the minimum effort at the given time The definition of...
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
void addDetector(MSMoveReminder *data, int queueIndex=-1)
Adds a data collector for a detector to this segment.
The base class for microscopic and mesoscopic vehicles.
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
bool replaceStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
virtual double getStopDelay() const
Returns the estimated public transport stop (departure) delay in seconds.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
void replaceParameter(const SUMOVehicleParameter *newParameter)
replace the vehicle parameter (deleting the old one)
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
double getLength() const
Returns the vehicle's length.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
virtual std::pair< double, double > estimateTimeToNextStop() const
return time (s) and distance to the next stop
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
const MSStop & getNextStop() const
virtual double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
SUMOTime getStopDuration() const
get remaining stop duration or 0 if the vehicle isn't stopped
const MSRoute & getRoute() const
Returns the current route.
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
bool isStopped() const
Returns whether the vehicle is at a stop.
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
A device that performs vehicle rerouting based on current edge speeds.
SUMOTime getPeriod() const
A road/street connecting two junctions.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const MSJunction * getToJunction() const
double getLength() const
return the length of the edge
double getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
static int gNumSimThreads
how many threads to use for simulation
SumoXMLNodeType getType() const
return the type of this Junction
Representation of a lane in the micro simulation.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
MSTransportableRouter & getIntermodalRouter(int rngIndex, const int routingMode=0, const Prohibitions &prohibited={}) const
MSVehicleRouter & getRouterTT(int rngIndex, const Prohibitions &prohibited={}) const
void setPermissionsFound()
Labels the network to contain vehicle class permissions.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
A lane area vehicles can halt at.
int getLastStepOccupancyIncludingRemoteReservations(const SUMOVehicle *forVehicle) const
bool isReservable() const
whether vehicles may reserve a slot for this parkingArea
void addSpaceReservation(const SUMOVehicle *veh)
api for reserving spaces at this parkingArea
int getOccupancyIncludingRemoteReservations(const SUMOVehicle *forVehicle) const
void removeSpaceReservation(const SUMOVehicle *veh)
void addConstraint(const std::string &tripId, MSRailSignalConstraint *constraint)
register constraint for signal switching
const ConstMSEdgeVector & getEdges() const
MSRouteIterator end() const
Returns the end of the list of edges to pass.
bool containsAnyOf(const MSEdgeVector &edgelist) const
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
double getCosts() const
Returns the costs of the route.
static MSVehicleRouter & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const Prohibitions &prohibited={})
return the vehicle router instance
static MSTransportableRouter & getIntermodalRouterTT(const int rngIndex, const Prohibitions &prohibited={})
return the person router instance
std::vector< MSStoppingPlace * > getPlaces() const
return all stoppingPlaces associated with this stop
bool joinTriggered
whether coupling another vehicle (train) the vehicle continue
SUMOTime getMinDuration(SUMOTime time) const
return minimum stop duration when starting stop at time
bool reached
Information whether the stop has been reached.
MSRouteIterator edge
The edge in the route to stop at.
const SUMOVehicleParameter::Stop pars
The stop parameter.
A lane area vehicles can halt at.
std::vector< const SUMOVehicle * > getStoppedVehicles() const
get list of vehicles waiting at this stop
double getBeginLanePosition() const
Returns the begin position of this stop.
SumoXMLTag getElement() const
return the type of this stopping place
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
std::map< std::string, double > StoppingPlaceParamMap_t
MSStoppingPlace * rerouteStoppingPlace(MSStoppingPlace *destStoppingPlace, const std::vector< StoppingPlaceVisible > &stoppingPlaceCandidates, const std::vector< double > &probs, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute, StoppingPlaceParamMap_t &scores, const Prohibitions &closedEdges={}, const int insertStopIndex=0, const bool keepCurrentStop=true)
main method to trigger the rerouting to the "best" StoppingPlace according to the custom evaluation f...
std::pair< MSStoppingPlace *, bool > StoppingPlaceVisible
The parent class for traffic light logics.
SUMOTime setPermissions(const SUMOTime currentTime)
Sets the edge permission if there are any defined in the closingEdge.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Tries to reroute the vehicle.
int getNumberStoppingPlaceReroutes(SUMOVehicle &veh)
ask how many times already the vehicle has been rerouted to another stopping place
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Triggers rerouting (once) for vehicles that are already on the edge when the rerouter activates.
static MSRailSignal * findSignal(ConstMSEdgeVector::const_iterator begin, ConstMSEdgeVector::const_iterator end)
find the last downstream signal on the given route
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes the reminder.
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, double prob, bool off, bool optional, SUMOTime timeThreshold, const std::string &vTypes, const Position &pos, const double radius)
Constructor.
double getStoppingPlaceOccupancy(MSStoppingPlace *sp, const SUMOVehicle *veh)
Return the number of occupied places of the stopping place.
double getUserProbability() const
Returns the rerouting probability given by the user.
static const double DEFAULT_MAXDELAY
MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute)
search for an alternative ParkingArea
bool myHaveParkProbs
whether this rerouter has loaded parkingReroute definitions
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
bool myHaveClosingUntil
whether closed edges with known duration are loaded
bool myAmOptional
Information whether the rerouting will only take place on request.
static bool affected(const std::set< SUMOTrafficObject::NumericalID > &edgeIndices, const MSEdgeVector &closed)
void setUserUsageProbability(double prob)
Sets the probability with which a vehicle is rerouted given by the user.
Position myPosition
Where are we located in the network.
std::pair< const SUMOVehicle *, MSRailSignal * > overtakingTrain(const SUMOVehicle &veh, ConstMSEdgeVector::const_iterator mainStart, const OvertakeLocation &oloc, double &netSaving)
determine whether veh should switch from main to siding to be overtaken and return the overtaking veh...
void rememberStoppingPlaceScore(SUMOVehicle &veh, MSStoppingPlace *parkingArea, const std::string &score)
store the score of the ParkingArea in the vehicle
void rememberBlockedStoppingPlace(SUMOVehicle &veh, const MSStoppingPlace *parkingArea, bool blocked)
store the blocked ParkingArea in the vehicle
static MSEdge mySpecialDest_terminateRoute
virtual void myEndElement(int element)
Called when a closing tag occurs.
void checkStopSwitch(MSBaseVehicle &veh, const MSTriggeredRerouter::RerouteInterval *def)
consider switching the location of the upcoming stop
void resetClosedEdges(bool hasReroutingDevice, const SUMOTrafficObject &o)
reset router after closing edges
bool triggerRouting(SUMOTrafficObject &veh, MSMoveReminder::Notification reason)
double myRadius
At which distance are we activated.
void resetStoppingPlaceScores(SUMOVehicle &veh)
reset all stored ParkingArea scores for this vehicle
double myProbability
The probability and the user-given probability.
SUMOTime sawBlockedStoppingPlace(SUMOVehicle &veh, MSStoppingPlace *parkingArea, bool local)
get the time the ParkingArea was considered full from this vehicle
virtual ~MSTriggeredRerouter()
Destructor.
bool inUserMode() const
Returns whether the user is setting the rerouting probability.
void setNumberStoppingPlaceReroutes(SUMOVehicle &veh, int value)
update the number of reroutes for the vehicle
std::set< const MSStoppingPlace * > myBlockedStoppingPlaces
double getStoppingPlaceCapacity(MSStoppingPlace *sp)
Return the number of places the stopping place provides.
std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
const RerouteInterval * getCurrentReroute(SUMOTime time, SUMOTrafficObject &obj) const
Returns the rerouting definition valid for the given time and object, nullptr if none.
static void checkParkingRerouteConsistency()
issues warning for incomplete parkingReroute relationships
static std::map< std::string, MSTriggeredRerouter * > myInstances
bool applies(const SUMOTrafficObject &obj) const
Checks whether the detector measures objects of the given type.
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
static MSRailSignal * getRailSignal(const MSEdge *edge)
return railsignal at that edge or nullptr
const MSEdgeVector myEdges
edges where vehicles are notified
std::map< const MSEdge *, RouterProhibition > Prohibitions
static MSEdge mySpecialDest_keepDestination
special destination values
RerouteInterval myParsedRerouteInterval
used during loading
double getProbability() const
Returns the rerouting probability.
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
double getLastStepStoppingPlaceOccupancy(MSStoppingPlace *sp, const SUMOVehicle *veh)
Return the number of occupied places of the stopping place from the previous time step.
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
The class responsible for building and deletion of vehicles.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
const std::set< std::string > getVTypeDistributionMembership(const std::string &id) const
Return the distribution IDs the vehicle type is a member of.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
const std::string & getOriginalID() const
Returns the id of the original vehicle type if this is a vehicle specific type, the id otherwise.
Base class for objects which have an id.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
static OptionsCont & getOptions()
Retrieves the options.
A point in 2D or 3D with translation and scaling methods.
static const Position INVALID
used to indicate that a position is valid
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Represents a generic random distribution.
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
T get(SumoRNG *which=nullptr) const
Draw a sample of the distribution.
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
const std::vector< T > & getVals() const
Returns the members of the distribution.
bool remove(T val)
Removes a value with an assigned probability from the distribution.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
Representation of a vehicle, person, or container.
virtual bool ignoreTransientPermissions() const
Returns whether this object is ignoring transient permission changes (during routing)
virtual bool isVehicle() const
Whether it is a vehicle.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual const SUMOVTypeParameter & getVTypeParameter() const =0
Returns the object's "vehicle" type parameter.
virtual int getRNGIndex() const =0
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or nullptr if not.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)=0
Replaces the current route by the given one.
virtual SUMOTime getWaitingTime(const bool accumulated=false) const =0
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual double getMaxSpeed() const =0
Returns the object's maximum speed (minimum of technical and desired maximum speed)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual SumoRNG * getRNG() const =0
Returns the associated RNG for this object.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
double getFloatParam(const std::string ¶mName, const bool required=false, const double deflt=INVALID_DOUBLE, bool checkDist=true) const
Retrieve a floating point parameter for the traffic object.
virtual const std::set< NumericalID > getUpcomingEdgeIDs() const =0
returns the numerical IDs of edges to be used (possibly of future stages)
virtual void setRoutingMode(int value)=0
Sets routing behavior.
virtual const MSEdge * getEdge() const =0
Returns the (normal) route edge the object is currently at.
virtual const MSEdge * getRerouteDestination() const =0
Returns the end point for reroutes (usually the last edge of the route)
virtual int getRoutingMode() const =0
return routing mode (configures router choice but also handling of transient permission changes)
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
virtual bool reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false, const MSEdge *sink=nullptr)=0
Performs a rerouting using the given router.
virtual SUMOTime sawBlockedParkingArea(const MSStoppingPlace *pa, bool local) const =0
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true, std::string *msgReturn=nullptr)=0
Replaces the current route by the given edges.
virtual bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)=0
Replaces a stop.
virtual bool hasStops() const =0
Returns whether the vehicle has to stop somewhere.
virtual MSParkingArea * getNextParkingArea()=0
virtual void rememberParkingAreaScore(const MSStoppingPlace *pa, const std::string &score)=0
virtual void rememberBlockedParkingArea(const MSStoppingPlace *pa, bool local)=0
virtual double getLength() const =0
Returns the vehicles's length.
virtual int getNumberParkingReroutes() const =0
virtual const std::vector< MSTransportable * > & getPersons() const =0
retrieve riding persons
virtual void replaceParameter(const SUMOVehicleParameter *newParameter)=0
Replaces the vehicle's parameter.
virtual void resetParkingAreaScores()=0
virtual const MSStop & getNextStop() const =0
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle's desired arrivalPos for its current route.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual void setNumberParkingReroutes(int value)=0
virtual const MSRoute & getRoute() const =0
Returns the current route.
virtual bool abortNextStop(int nextStopIndex=0)=0
deletes the next stop at the given index if it exists
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
std::string parkingarea
(Optional) parking area if one is assigned to the stop
double startPos
The stopping position start.
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::string overheadWireSegment
(Optional) overhead line segment if one is assigned to the stop
SUMOTime until
The time at which the vehicle may continue its journey.
double endPos
The stopping position end.
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string containerstop
(Optional) container stop if one is assigned to the stop
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
double arrivalPos
(optional) The position the vehicle shall arrive on
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
A scoped lock which only triggers on condition.
std::vector< std::string > getVector()
return vector of strings
A wrapper for a Command function.
TRACI_CONST int ROUTING_MODE_IGNORE_TRANSIENT_PERMISSIONS
double sidingLength
The usable length of the siding.
MSEdgeVector main
The list of main edges (const and non-const for different usage)
bool defer
whether the decision to use this siding should be deferred
ConstMSEdgeVector cSiding
double minSaving
The threshold in savings for triggering reroute.
MSEdgeVector siding
The list of siding edges.
MSRailSignal * sidingExit
The rail signal at the end of the siding.
SUMOTime begin
The begin time these definitions are valid.
RandomDistributor< MSStoppingPlaceRerouter::StoppingPlaceVisible > parkProbs
The distributions of new parking areas to use as destinations.
std::vector< MSStoppingPlaceRerouter::StoppingPlaceVisible > stopAlternatives
RandomDistributor< ConstMSRoutePtr > routeProbs
The distributions of new routes to use.
MSEdgeVector getClosedEdges() const
SUMOTime end
The end time these definitions are valid.
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations or vias to use.
std::map< MSLane *, SVCPermissions > closedLanes
The list of closed lanes to their permissions.
bool isVia
The edge probs are vias and not destinations.
Prohibitions getClosed() const
MSEdgeVector closedLanesAffected
The list of edges that are affected by closed lanes.
bool permissionsAllowAll
The permissions are all SVCAll.
std::map< MSEdge *, std::pair< SVCPermissions, double > > closed
The map of closed edges to their permissions and expected end of closing.
std::vector< OvertakeLocation > overtakeLocations