62#define DEBUGCOND (veh.isSelected())
78 SUMOTime timeThreshold,
const std::string& vTypes) :
83 myUserProbability(prob),
84 myAmInUserMode(false),
85 myTimeThreshold(timeThreshold) {
88 for (MSEdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
94 const std::vector<MSLane*>& destLanes = (*j)->getLanes();
95 for (std::vector<MSLane*>::const_iterator i = destLanes.begin(); i != destLanes.end(); ++i) {
96 (*i)->addMoveReminder(
this);
127 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": No destination edge id given.");
131 if (dest ==
"keepDestination") {
133 }
else if (dest ==
"terminateRoute") {
136 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Destination edge '" + dest +
"' is not known.");
146 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Attribute 'probability' for destination '" + dest +
"' is negative (must not).");
157 if (closed ==
nullptr) {
158 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Edge '" + closed_id +
"' to close is not known.");
171 if (closed ==
nullptr) {
172 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Lane '" + closed_id +
"' to close is not known.");
191 if (routeStr ==
"") {
195 if (route ==
nullptr) {
196 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Route '" + routeStr +
"' does not exist.");
206 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Attribute 'probability' for route '" + routeStr +
"' is negative (must not).");
216 if (parkingarea ==
"") {
217 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": No parking area id given.");
221 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Parking area '" + parkingarea +
"' is not known.");
230 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Attribute 'probability' for destination '" + parkingarea +
"' is negative (must not).");
258 std::set<MSEdge*> affected;
260 affected.insert(&l->
getEdge());
266 if (closingBegin < simBegin && ri.end > simBegin) {
291 bool updateVehicles =
false;
293 if (i.begin == currentTime && !(i.closed.empty() && i.closedLanes.empty()) && i.permissions !=
SVCAll) {
294 for (
MSEdge* e : i.closed) {
297 lane->setPermissions(i.permissions, i.id);
300 updateVehicles =
true;
302 for (
MSLane* lane : i.closedLanes) {
305 updateVehicles =
true;
310 if (i.end == currentTime && !(i.closed.empty() && i.closedLanes.empty()) && i.permissions !=
SVCAll) {
311 for (
MSEdge* e : i.closed) {
313 lane->resetPermissions(i.id);
317 updateVehicles =
true;
319 for (
MSLane* lane : i.closedLanes) {
322 updateVehicles =
true;
326 if (updateVehicles) {
330 e->rebuildAllowedTargets();
340 if (i->begin <= time && i->end > time) {
343 i->edgeProbs.getOverallProb() > 0 ||
345 i->routeProbs.getOverallProb() > 0 ||
347 i->parkProbs.getOverallProb() > 0 ||
363 if (i->begin <= time && i->end > time) {
364 if (i->parkProbs.getOverallProb() != 0 || i->edgeProbs.getOverallProb() != 0 || i->routeProbs.getOverallProb() != 0 || !i->closed.empty()) {
399 if (rerouteDef ==
nullptr) {
414 if (rerouteDef->
closedLanes.size() > 0 && !hasReroutingDevice) {
430 bool newDestination =
false;
433 if (newParkingArea !=
nullptr) {
439 if (newDestination) {
454 const double savings = previousCost - routeCost;
463 std::string errorMsg;
468 +
"' could not reroute to new parkingArea '" + newParkingArea->
getID()
478 if (newRoute !=
nullptr) {
481 std::cout <<
" replacedRoute from routeDist " << newRoute->
getID() <<
"\n";
487 const MSEdge* newEdge = lastEdge;
489 double newArrivalPos = -1;
490 const bool destUnreachable = std::find(rerouteDef->
closed.begin(), rerouteDef->
closed.end(), lastEdge) != rerouteDef->
closed.end();
491 bool keepDestination =
false;
494 if (rerouteDef->
closed.size() == 0 || destUnreachable) {
497 keepDestination =
true;
505 WRITE_WARNING(
"Cannot keep destination edge '" + lastEdge->
getID() +
"' for vehicle '" + veh.
getID() +
"' due to closed edges. Terminating route.");
510 }
else if (newEdge ==
nullptr) {
513 std::cout <<
" could not find new edge!\n";
531 while (edges.size() == 0 && edgeProbs2.
getVals().size() > 0) {
532 newEdge = edgeProbs2.
get();
553 if (
DEBUGCOND) std::cout <<
" rerouting: newDest=" << newEdge->
getID()
555 <<
" useNewRoute=" << useNewRoute <<
" newArrivalPos=" << newArrivalPos <<
" numClosed=" << rerouteDef->
closed.size()
558 if (useNewRoute && newArrivalPos != -1) {
617 return defaultWeight;
639 if (destParkArea ==
nullptr) {
644 bool destVisible =
false;
645 for (
auto paVis : parks) {
646 if (paVis.first == destParkArea
656 const int parkAnywhere = (int)
getWeight(veh,
"parking.anywhere", -1);
664 if (pav.second && pav.first->getLastStepOccupancy() == pav.first->getCapacity()) {
677 double bestDist = std::numeric_limits<double>::max();
686 if (distToEnd > brakeGap) {
688 if (distToStart < bestDist) {
689 bestDist = distToStart;
705 if (!destVisible && onTheWay ==
nullptr) {
720 <<
" rerouteParkingArea dest=" << destParkArea->
getID()
722 <<
" newDest=" << newDestination
729 std::map<MSParkingArea*, ConstMSEdgeVector> newRoutes;
730 std::map<MSParkingArea*, ConstMSEdgeVector> parkApproaches;
733 weights[
"probability"] =
getWeight(veh,
"parking.probability.weight", 0.0);
736 weights[
"capacity"] =
getWeight(veh,
"parking.capacity.weight", 0.0);
739 weights[
"absfreespace"] =
getWeight(veh,
"parking.absfreespace.weight", 0.0);
742 weights[
"relfreespace"] =
getWeight(veh,
"parking.relfreespace.weight", 0.0);
745 weights[
"distanceto"] =
getWeight(veh,
"parking.distanceto.weight",
getWeight(veh,
"parking.distance.weight", 1.0));
748 weights[
"timeto"] =
getWeight(veh,
"parking.timeto.weight", 0.0);
751 weights[
"distancefrom"] =
getWeight(veh,
"parking.distancefrom.weight", 0.0);
754 weights[
"timefrom"] =
getWeight(veh,
"parking.timefrom.weight", 0.0);
759 maxValues[
"probability"] = 0.0;
760 maxValues[
"capacity"] = 0.0;
761 maxValues[
"absfreespace"] = 0.0;
762 maxValues[
"relfreespace"] = 0.0;
763 maxValues[
"distanceto"] = 0.0;
764 maxValues[
"timeto"] = 0.0;
765 maxValues[
"distancefrom"] = 0.0;
766 maxValues[
"timefrom"] = 0.0;
777 if (onTheWay !=
nullptr) {
779 if (newDestination) {
780 newRoute.push_back(veh.
getEdge());
782 bool valid =
addParkValues(veh, brakeGap, newDestination, onTheWay, onTheWay->
getLastStepOccupancy(), 1, router, parkAreas, newRoutes, parkApproaches, maxValues);
784 WRITE_WARNING(
"Parkingarea '" + onTheWay->
getID() +
"' along the way cannot be used by vehicle '" + veh.
getID() +
"' for unknown reason");
787 newRoute = newRoutes[onTheWay];
792 int numAlternatives = 0;
793 std::vector<std::tuple<SUMOTime, MSParkingArea*, int> > blockedTimes;
799 const double parkingFrustration =
getWeight(veh,
"parking.frustration", 100);
800 const double parkingKnowledge =
getWeight(veh,
"parking.knowledge", 0);
802 for (
int i = 0; i < (int)parks.size(); ++i) {
806 const bool visible = parks[i].second || (pa == destParkArea && destVisible);
813 if (blockedTime >= 0 &&
SIMSTEP - blockedTime < parkingMemory) {
816 blockedTimes.push_back(std::make_tuple(blockedTime, pa, i));
819 std::cout <<
" altPA=" << pa->
getID() <<
" was blocked at " <<
time2string(blockedTime) <<
"\n";
824 if (paOccupancy < pa->getCapacity()) {
825 if (
addParkValues(veh, brakeGap, newDestination, pa, paOccupancy, probs[i], router, parkAreas, newRoutes, parkApproaches, maxValues)) {
828 }
else if (visible) {
834 if (numAlternatives == 0) {
836 std::sort(blockedTimes.begin(), blockedTimes.end(),
837 [](std::tuple<SUMOTime, MSParkingArea*, int>
const & t1, std::tuple<SUMOTime, MSParkingArea*, int>
const & t2) {
838 if (std::get<0>(t1) < std::get<0>(t2)) {
841 if (std::get<0>(t1) == std::get<0>(t2)) {
842 if (std::get<1>(t1)->
getID() < std::get<1>(t2)->
getID()) {
845 if (std::get<1>(t1)->
getID() == std::get<1>(t2)->
getID()) {
846 return std::get<2>(t1) < std::get<2>(t2);
852 for (
auto item : blockedTimes) {
854 double prob = probs[std::get<2>(item)];
858 if (
addParkValues(veh, brakeGap, newDestination, pa, paOccupancy, prob, router, parkAreas, newRoutes, parkApproaches, maxValues)) {
861 std::cout <<
" altPA=" << pa->
getID() <<
" targeting occupied pa based on blockTime " <<
STEPS2TIME(std::get<0>(item)) <<
" among " << blockedTimes.size() <<
" alternatives\n";
869 if (numAlternatives == 0) {
871 std::vector<std::pair<SUMOTime, MSParkingArea*> > candidates;
873 if (pav.first == destParkArea) {
881 candidates.push_back(std::make_pair(dummy, pav.first));
883 std::sort(candidates.begin(), candidates.end(),
884 [](std::tuple<SUMOTime, MSParkingArea*>
const & t1, std::tuple<SUMOTime, MSParkingArea*>
const & t2) {
885 return std::get<0>(t1) < std::get<0>(t2) || (std::get<0>(t1) == std::get<0>(t2) && std::get<1>(t1)->getID() < std::get<1>(t2)->getID());
888 for (
auto item : candidates) {
890 if (
addParkValues(veh, brakeGap, newDestination, pa, 0, 1, router, parkAreas, newRoutes, parkApproaches, maxValues)) {
893 std::cout <<
" altPA=" << pa->
getID() <<
" targeting occupied pa (based on pure randomness) among " << candidates.size() <<
" alternatives\n";
907 std::cout <<
" maxValues=" <<
joinToString(maxValues,
" ",
":") <<
"\n";
912 double minParkingCost = 0.0;
914 for (MSParkingAreaMap_t::iterator it = parkAreas.begin(); it != parkAreas.end(); ++it) {
918 if (weights[
"probability"] > 0 && maxValues[
"probability"] > 0.0) {
920 bool dominated =
false;
921 double endPos = it->first->getEndLanePosition();
923 assert(to1.size() > 0);
924 for (
auto altPa : parkAreas) {
925 if (altPa.first == it->first) {
929 assert(to2.size() > 0);
930 if (to1.size() > to2.size()) {
931 if (std::equal(to2.begin(), to2.end(), to1.begin())) {
937 }
else if (to1 == to2 && endPos > altPa.first->getEndLanePosition()) {
947 parkValues[
"probability"] = 1.0 - prob / maxValues[
"probability"];
950 parkValues[
"probability"] = 1.0;
954 parkValues[
"probability"] = 0;
957 parkValues[
"capacity"] = maxValues[
"capacity"] > 0.0 ? 1.0 - parkValues[
"capacity"] / maxValues[
"capacity"] : 0.0;
958 parkValues[
"absfreespace"] = maxValues[
"absfreespace"] > 0.0 ? 1.0 - parkValues[
"absfreespace"] / maxValues[
"absfreespace"] : 0.0;
959 parkValues[
"relfreespace"] = maxValues[
"relfreespace"] > 0.0 ? 1.0 - parkValues[
"relfreespace"] / maxValues[
"relfreespace"] : 0.0;
961 parkValues[
"distanceto"] = maxValues[
"distanceto"] > 0.0 ? parkValues[
"distanceto"] / maxValues[
"distanceto"] : 0.0;
962 parkValues[
"timeto"] = maxValues[
"timeto"] > 0.0 ? parkValues[
"timeto"] / maxValues[
"timeto"] : 0.0;
964 parkValues[
"distancefrom"] = maxValues[
"distancefrom"] > 0.0 ? parkValues[
"distancefrom"] / maxValues[
"distancefrom"] : 0.0;
965 parkValues[
"timefrom"] = maxValues[
"timefrom"] > 0.0 ? parkValues[
"timefrom"] / maxValues[
"timefrom"] : 0.0;
968 double parkingCost = 0.0;
971 for (ParkingParamMap_t::iterator pc = parkValues.begin(); pc != parkValues.end(); ++pc) {
972 parkingCost += weights[pc->first] * pc->second;
981 if (nearParkArea ==
nullptr || parkingCost < minParkingCost) {
982 minParkingCost = parkingCost;
983 nearParkArea = it->first;
984 newRoute = newRoutes[nearParkArea];
989 std::cout <<
" altPA=" << it->first->
getID() <<
" score=" << parkingCost <<
" vals=" <<
joinToString(parkValues,
" ",
":") <<
"\n";
997 std::cout <<
SIMTIME <<
" rerouter=" << getID() <<
" veh=" << veh.getID() <<
" rerouteParkingArea dest=" << destParkArea->getID() <<
" sufficient space\n";
1008 return nearParkArea;
1017 std::map<MSParkingArea*, ConstMSEdgeVector>& newRoutes,
1018 std::map<MSParkingArea*, ConstMSEdgeVector>& parkApproaches,
1037 std::cout <<
" altPA=" << pa->
getID() <<
" vehEdge=" << veh.
getEdge()->
getID() <<
" parkEdge " << parkEdge->
getID() <<
" edgesToPark=" << edgesToPark.size() <<
"\n";
1041 if (edgesToPark.size() > 0) {
1043 if (rerouteOrigin != veh.
getEdge()) {
1044 edgesToPark.insert(edgesToPark.begin(), veh.
getEdge());
1047 parkApproaches[pa] = edgesToPark;
1051 int nextDestinationIndex = route.
size() - 1;
1052 if (!newDestination) {
1053 std::vector<std::pair<int, double> > stopIndices = veh.
getStopIndices();
1054 if (stopIndices.size() > 1) {
1055 nextDestinationIndex = stopIndices[1].first;
1056 nextDestination = route.
getEdges()[nextDestinationIndex];
1057 nextPos = stopIndices[1].second;
1060 router.
compute(parkEdge, parkPos, nextDestination, nextPos, &veh,
MSNet::getInstance()->getCurrentTimeStep(), edgesFromPark,
true);
1068 if (edgesFromPark.size() > 0 || newDestination) {
1070 parkValues[
"probability"] = prob;
1072 if (parkValues[
"probability"] > maxValues[
"probability"]) {
1073 maxValues[
"probability"] = parkValues[
"probability"];
1076 parkValues[
"capacity"] = (double)(pa->
getCapacity());
1077 parkValues[
"absfreespace"] = (double)(pa->
getCapacity() - paOccupancy);
1079 parkValues[
"relfreespace"] = parkValues[
"absfreespace"] /
MAX2(1.0, parkValues[
"capacity"]);
1081 if (parkValues[
"capacity"] > maxValues[
"capacity"]) {
1082 maxValues[
"capacity"] = parkValues[
"capacity"];
1085 if (parkValues[
"absfreespace"] > maxValues[
"absfreespace"]) {
1086 maxValues[
"absfreespace"] = parkValues[
"absfreespace"];
1089 if (parkValues[
"relfreespace"] > maxValues[
"relfreespace"]) {
1090 maxValues[
"relfreespace"] = parkValues[
"relfreespace"];
1093 MSRoute routeToPark(route.
getID() +
"!topark#1", edgesToPark,
false,
1102 routeToPark.
begin(), routeToPark.
end() - 1, includeInternalLengths);
1104 if (parkValues[
"distanceto"] == std::numeric_limits<double>::max()) {
1105 WRITE_WARNINGF(
TL(
"Invalid distance computation for vehicle '%' to parkingArea '%' at time=%."),
1111 const double distToEnd = parkValues[
"distanceto"] - toPos + endPos;
1114 std::cout <<
" " << veh.
getID() <<
" candidate=" << pa->
getID()
1115 <<
" distanceTo=" << parkValues[
"distanceto"]
1116 <<
" brakeGap=" << brakeGap
1117 <<
" routeToPark=" <<
toString(edgesToPark)
1120 <<
" toPos=" << toPos
1122 <<
" distToEnd=" << distToEnd
1127 if (distToEnd < brakeGap) {
1131 std::cout <<
" altPA=" << pa->
getID() <<
" too close to brake (dist=" << distToEnd <<
" brakeGap=" << brakeGap <<
"\n";
1140 if (parkValues[
"distanceto"] > maxValues[
"distanceto"]) {
1141 maxValues[
"distanceto"] = parkValues[
"distanceto"];
1144 if (parkValues[
"timeto"] > maxValues[
"timeto"]) {
1145 maxValues[
"timeto"] = parkValues[
"timeto"];
1150 if (newDestination) {
1151 parkValues[
"distancefrom"] = 0;
1152 parkValues[
"timefrom"] = 0;
1154 MSRoute routeFromPark(route.
getID() +
"!frompark#1", edgesFromPark,
false,
1158 routeFromPark.
begin(), routeFromPark.
end() - 1, includeInternalLengths);
1159 if (parkValues[
"distancefrom"] == std::numeric_limits<double>::max()) {
1160 WRITE_WARNINGF(
TL(
"Invalid distance computation for vehicle '%' from parkingArea '%' at time=%."),
1165 newEdges.insert(newEdges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
1166 newEdges.insert(newEdges.end(), route.
begin() + nextDestinationIndex + 1, route.
end());
1169 if (parkValues[
"distancefrom"] > maxValues[
"distancefrom"]) {
1170 maxValues[
"distancefrom"] = parkValues[
"distancefrom"];
1173 if (parkValues[
"timefrom"] > maxValues[
"timefrom"]) {
1174 maxValues[
"timefrom"] = parkValues[
"timefrom"];
1177 parkAreas[pa] = parkValues;
1178 newRoutes[pa] = newEdges;
1189 std::cout <<
" altPA=" << pa->
getID() <<
" disconnected\n";
1203 for (
auto vTypeDist : vTypeDists) {
1218 std::set<MSEdge*> parkingRerouterEdges;
1219 std::map<MSParkingArea*, std::string, ComparatorIdLess> targetedParkingArea;
1221 bool hasParkingReroute =
false;
1224 hasParkingReroute =
true;
1226 targetedParkingArea[pav.first] = rr.first;
1230 if (hasParkingReroute) {
1231 parkingRerouterEdges.insert(rr.second->myEdges.begin(), rr.second->myEdges.end());
1234 for (
const auto& item : targetedParkingArea) {
1235 if (parkingRerouterEdges.count(&item.first->getLane().getEdge()) == 0) {
1236 WRITE_WARNINGF(
TL(
"ParkingArea '%' is targeted by rerouter '%' but doesn't have it's own rerouter. This may cause parking search to abort."),
1237 item.first->getID(), item.second);
std::vector< const MSEdge * > ConstMSEdgeVector
std::vector< MSEdge * > MSEdgeVector
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
const SVCPermissions SVCAll
all VClasses are allowed
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
@ SVC_AUTHORITY
authorities vehicles
@ GIVEN
The arrival position is given.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_ROUTE_PROB_REROUTE
probability of route of a reroute
@ SUMO_TAG_DEST_PROB_REROUTE
probability of destiny of a reroute
@ SUMO_TAG_CLOSING_LANE_REROUTE
lane of a reroute of type closing
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
A single mesoscopic segment (cell)
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
A device that performs vehicle rerouting based on current edge speeds.
A road/street connecting two junctions.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
void rebuildAllowedLanes(const bool onInit=false)
double getLength() const
return the length of the edge
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....
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
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Representation of a lane in the micro simulation.
void resetPermissions(long long transientID)
void setPermissions(SVCPermissions permissions, long long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
MSEdge & getEdge() const
Returns the lane's edge.
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.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
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.
bool hasInternalLinks() const
return whether the network contains internal links
A lane area vehicles can halt at.
int getCapacity() const
Returns the area capacity.
double getLastFreePos(const SUMOVehicle &forVehicle, double brakePos=0) const
Returns the last free position on this stop.
int getLastStepOccupancy() const
Returns the area occupancy at the end of the last simulation step.
int getOccupancy() const
Returns the area occupancy.
int size() const
Returns the number of edges to pass.
const ConstMSEdgeVector & getEdges() const
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
const MSEdge * getLastEdge() const
returns the destination edge
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes....
bool containsAnyOf(const MSEdgeVector &edgelist) const
const RGBColor & getColor() const
Returns the color.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
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.
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.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes the reminder.
RandomDistributor< ParkingAreaVisible > myCurrentParkProb
new destinations with probabilities
double getUserProbability() const
Returns the rerouting probability given by the user.
std::vector< MSLane * > myCurrentClosedLanes
List of closed lanes.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, double prob, bool off, SUMOTime timeThreshold, const std::string &vTypes)
Constructor.
void setUserUsageProbability(double prob)
Sets the probability with which a vehicle is rerouted given by the user.
SVCPermissions myCurrentPermissions
List of permissions for closed edges.
MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute) const
static MSEdge mySpecialDest_terminateRoute
virtual void myEndElement(int element)
Called when a closing tag occurs.
bool addParkValues(SUMOVehicle &veh, double brakeGap, bool newDestination, MSParkingArea *pa, double paOccupancy, double prob, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, MSParkingAreaMap_t &parkAreas, std::map< MSParkingArea *, ConstMSEdgeVector > &newRoutes, std::map< MSParkingArea *, ConstMSEdgeVector > &parkApproaches, ParkingParamMap_t &maxValues) const
determine attributes of candiate parking area for scoring
const RerouteInterval * getCurrentReroute(SUMOTime time, SUMOVehicle &veh) const
Returns the rerouting definition valid for the given time and vehicle, 0 if none.
std::pair< MSParkingArea *, bool > ParkingAreaVisible
double myProbability
The probability and the user-given probability.
virtual ~MSTriggeredRerouter()
Destructor.
bool inUserMode() const
Returns whether the user is setting the rerouting probability.
std::map< std::string, double > ParkingParamMap_t
std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
MSEdgeVector myCurrentClosed
List of closed edges.
static void checkParkingRerouteConsistency()
issues warning for incomplete parkingReroute relationships
RandomDistributor< MSEdge * > myCurrentEdgeProb
new destinations with probabilities
static std::map< std::string, MSTriggeredRerouter * > myInstances
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
double getWeight(SUMOVehicle &veh, const std::string param, const double defaultWeight) const
SUMOTime myCurrentIntervalBegin
The first and the last time steps of the interval.
SUMOTime myCurrentIntervalEnd
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
const MSEdgeVector myEdges
edges where vehicles are notified
RandomDistributor< const MSRoute * > myCurrentRouteProb
new routes with probabilities
static MSEdge mySpecialDest_keepDestination
special destination values
double getProbability() const
Returns the rerouting probability.
std::map< MSParkingArea *, ParkingParamMap_t, ComparatorIdLess > MSParkingAreaMap_t
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
const std::set< std::string > getVTypeDistributionMembership(const std::string &id) const
Return the distribution IDs the vehicle type is a member of.
const std::string & getOriginalID() const
Returns the id of the original vehicle type if this is a vehicle specific type, the id otherwise.
const SUMOVTypeParameter & getParameter() const
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.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
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.
void clear()
Clears the distribution.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
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...
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.
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 SUMOTime getWaitingTime() const =0
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 SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual SumoRNG * getRNG() const =0
Returns the associated RNG for this object.
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
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 const MSEdge * getRerouteOrigin() const =0
Returns the starting point for reroutes (usually the current edge)
virtual void rememberParkingAreaScore(const MSParkingArea *pa, const std::string &score)=0
virtual bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)=0
Replaces a stop.
virtual MSParkingArea * getNextParkingArea()=0
virtual SUMOTime getAccumulatedWaitingTime() const =0
virtual int getRNGIndex() const =0
virtual bool replaceRoute(const MSRoute *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 int getNumberParkingReroutes() const =0
virtual const std::vector< MSTransportable * > & getPersons() const =0
retrieve riding persons
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual void replaceParameter(const SUMOVehicleParameter *newParameter)=0
Replaces the vehicle's parameter.
virtual void rememberBlockedParkingArea(const MSParkingArea *pa, bool local)=0
virtual SUMOTime sawBlockedParkingArea(const MSParkingArea *pa, bool local) const =0
virtual void resetParkingAreaScores()=0
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual double getBrakeGap(bool delayed=false) const =0
get distance for coming to a stop (used for rerouting checks)
virtual std::vector< std::pair< int, double > > getStopIndices() const =0
return list of route indices and stop positions for the remaining stops
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.
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
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
A wrapper for a Command function.
SUMOTime begin
The begin time these definitions are valid.
SUMOTime end
The end time these definitions are valid.
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations to use.
RandomDistributor< const MSRoute * > routeProbs
The distributions of new routes to use.
MSEdgeVector closedLanesAffected
The list of edges that are affect by closed lanes.
RandomDistributor< ParkingAreaVisible > parkProbs
The distributions of new parking areas to use as destinations.
SVCPermissions permissions
The permissions to use.
MSEdgeVector closed
The list of closed edges.
std::vector< MSLane * > closedLanes
The list of closed lanes.