62#define DEBUGCOND (veh.isSelected())
78 SUMOTime timeThreshold,
const std::string& vTypes) :
83 myUserProbability(prob),
84 myAmInUserMode(false),
85 myTimeThreshold(timeThreshold),
86 myHaveParkProbs(false)
90 for (MSEdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
96 const std::vector<MSLane*>& destLanes = (*j)->getLanes();
97 for (std::vector<MSLane*>::const_iterator i = destLanes.begin(); i != destLanes.end(); ++i) {
98 (*i)->addMoveReminder(
this);
133 if (dest ==
"keepDestination") {
135 }
else if (dest ==
"terminateRoute") {
138 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Destination edge '" + dest +
"' is not known.");
148 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Attribute 'probability' for destination '" + dest +
"' is negative (must not).");
159 if (closed ==
nullptr) {
160 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Edge '" + closed_id +
"' to close is not known.");
173 if (closed ==
nullptr) {
174 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Lane '" + closed_id +
"' to close is not known.");
193 if (routeStr ==
"") {
197 if (route ==
nullptr) {
198 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Route '" + routeStr +
"' does not exist.");
208 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Attribute 'probability' for route '" + routeStr +
"' is negative (must not).");
218 if (parkingarea ==
"") {
223 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Parking area '" + parkingarea +
"' is not known.");
232 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Attribute 'probability' for destination '" + parkingarea +
"' is negative (must not).");
261 std::set<MSEdge*> affected;
263 affected.insert(&l->
getEdge());
269 if (closingBegin < simBegin && ri.end > simBegin) {
294 bool updateVehicles =
false;
296 if (i.begin == currentTime && !(i.closed.empty() && i.closedLanes.empty()) && i.permissions !=
SVCAll) {
297 for (
MSEdge* e : i.closed) {
300 lane->setPermissions(i.permissions, i.id);
303 updateVehicles =
true;
305 for (
MSLane* lane : i.closedLanes) {
308 updateVehicles =
true;
313 if (i.end == currentTime && !(i.closed.empty() && i.closedLanes.empty()) && i.permissions !=
SVCAll) {
314 for (
MSEdge* e : i.closed) {
316 lane->resetPermissions(i.id);
320 updateVehicles =
true;
322 for (
MSLane* lane : i.closedLanes) {
325 updateVehicles =
true;
329 if (updateVehicles) {
333 e->rebuildAllowedTargets();
343 if (i->begin <= time && i->end > time) {
346 i->edgeProbs.getOverallProb() > 0 ||
348 i->routeProbs.getOverallProb() > 0 ||
350 i->parkProbs.getOverallProb() > 0 ||
366 if (i->begin <= time && i->end > time) {
367 if (i->parkProbs.getOverallProb() != 0 || i->edgeProbs.getOverallProb() != 0 || i->routeProbs.getOverallProb() != 0 || !i->closed.empty()) {
402 if (rerouteDef ==
nullptr) {
417 if (rerouteDef->
closedLanes.size() > 0 && !hasReroutingDevice) {
433 bool newDestination =
false;
436 if (newParkingArea !=
nullptr) {
442 if (newDestination) {
457 const double savings = previousCost - routeCost;
466 std::string errorMsg;
471 +
"' could not reroute to new parkingArea '" + newParkingArea->
getID()
481 if (newRoute !=
nullptr) {
484 std::cout <<
" replacedRoute from routeDist " << newRoute->getID() <<
"\n";
490 const MSEdge* newEdge = lastEdge;
492 double newArrivalPos = -1;
493 const bool destUnreachable = std::find(rerouteDef->
closed.begin(), rerouteDef->
closed.end(), lastEdge) != rerouteDef->
closed.end();
494 bool keepDestination =
false;
497 if (rerouteDef->
closed.size() == 0 || destUnreachable) {
500 keepDestination =
true;
508 WRITE_WARNINGF(
TL(
"Cannot keep destination edge '%' for vehicle '%' due to closed edges. Terminating route."), lastEdge->
getID(), veh.
getID());
513 }
else if (newEdge ==
nullptr) {
516 std::cout <<
" could not find new edge!\n";
534 while (edges.size() == 0 && edgeProbs2.
getVals().size() > 0) {
535 newEdge = edgeProbs2.
get();
556 if (
DEBUGCOND) std::cout <<
" rerouting: newDest=" << newEdge->
getID()
558 <<
" useNewRoute=" << useNewRoute <<
" newArrivalPos=" << newArrivalPos <<
" numClosed=" << rerouteDef->
closed.size()
561 if (useNewRoute && newArrivalPos != -1) {
620 return defaultWeight;
642 if (destParkArea ==
nullptr) {
649 for (
auto paVis : parks) {
650 if (paVis.first == destParkArea && paVis.second) {
657 const int parkAnywhere = (int)
getWeight(veh,
"parking.anywhere", -1);
665 if (pav.second && pav.first->getLastStepOccupancy() == pav.first->getCapacity()) {
678 double bestDist = std::numeric_limits<double>::max();
687 if (distToEnd > brakeGap) {
689 if (distToStart < bestDist) {
690 bestDist = distToStart;
706 if (!destVisible && onTheWay ==
nullptr) {
721 <<
" rerouteParkingArea dest=" << destParkArea->
getID()
723 <<
" newDest=" << newDestination
730 std::map<MSParkingArea*, ConstMSEdgeVector> newRoutes;
731 std::map<MSParkingArea*, ConstMSEdgeVector> parkApproaches;
734 weights[
"probability"] =
getWeight(veh,
"parking.probability.weight", 0.0);
737 weights[
"capacity"] =
getWeight(veh,
"parking.capacity.weight", 0.0);
740 weights[
"absfreespace"] =
getWeight(veh,
"parking.absfreespace.weight", 0.0);
743 weights[
"relfreespace"] =
getWeight(veh,
"parking.relfreespace.weight", 0.0);
746 weights[
"distanceto"] =
getWeight(veh,
"parking.distanceto.weight",
getWeight(veh,
"parking.distance.weight", 1.0));
749 weights[
"timeto"] =
getWeight(veh,
"parking.timeto.weight", 0.0);
752 weights[
"distancefrom"] =
getWeight(veh,
"parking.distancefrom.weight", 0.0);
755 weights[
"timefrom"] =
getWeight(veh,
"parking.timefrom.weight", 0.0);
760 maxValues[
"probability"] = 0.0;
761 maxValues[
"capacity"] = 0.0;
762 maxValues[
"absfreespace"] = 0.0;
763 maxValues[
"relfreespace"] = 0.0;
764 maxValues[
"distanceto"] = 0.0;
765 maxValues[
"timeto"] = 0.0;
766 maxValues[
"distancefrom"] = 0.0;
767 maxValues[
"timefrom"] = 0.0;
778 if (onTheWay !=
nullptr) {
780 if (newDestination) {
781 newRoute.push_back(veh.
getEdge());
783 bool valid =
addParkValues(veh, brakeGap, newDestination, onTheWay, onTheWay->
getLastStepOccupancy(), 1, router, parkAreas, newRoutes, parkApproaches, maxValues);
785 WRITE_WARNINGF(
TL(
"Parkingarea '%' along the way cannot be used by vehicle '%' for unknown reason"), onTheWay->
getID(), veh.
getID());
788 newRoute = newRoutes[onTheWay];
793 int numAlternatives = 0;
794 std::vector<std::tuple<SUMOTime, MSParkingArea*, int> > blockedTimes;
800 const double parkingFrustration =
getWeight(veh,
"parking.frustration", 100);
801 const double parkingKnowledge =
getWeight(veh,
"parking.knowledge", 0);
803 for (
int i = 0; i < (int)parks.size(); ++i) {
807 const bool visible = parks[i].second || (pa == destParkArea && destVisible);
814 if (blockedTime >= 0 &&
SIMSTEP - blockedTime < parkingMemory) {
817 blockedTimes.push_back(std::make_tuple(blockedTime, pa, i));
820 std::cout <<
" altPA=" << pa->
getID() <<
" was blocked at " <<
time2string(blockedTime) <<
"\n";
825 if (paOccupancy < pa->getCapacity()) {
826 if (
addParkValues(veh, brakeGap, newDestination, pa, paOccupancy, probs[i], router, parkAreas, newRoutes, parkApproaches, maxValues)) {
829 }
else if (visible) {
835 if (numAlternatives == 0) {
837 std::sort(blockedTimes.begin(), blockedTimes.end(),
838 [](std::tuple<SUMOTime, MSParkingArea*, int>
const & t1, std::tuple<SUMOTime, MSParkingArea*, int>
const & t2) {
839 if (std::get<0>(t1) < std::get<0>(t2)) {
842 if (std::get<0>(t1) == std::get<0>(t2)) {
843 if (std::get<1>(t1)->
getID() < std::get<1>(t2)->
getID()) {
846 if (std::get<1>(t1)->
getID() == std::get<1>(t2)->
getID()) {
847 return std::get<2>(t1) < std::get<2>(t2);
853 for (
auto item : blockedTimes) {
855 double prob = probs[std::get<2>(item)];
859 if (
addParkValues(veh, brakeGap, newDestination, pa, paOccupancy, prob, router, parkAreas, newRoutes, parkApproaches, maxValues)) {
862 std::cout <<
" altPA=" << pa->
getID() <<
" targeting occupied pa based on blockTime " <<
STEPS2TIME(std::get<0>(item)) <<
" among " << blockedTimes.size() <<
" alternatives\n";
870 if (numAlternatives == 0) {
872 std::vector<std::pair<SUMOTime, MSParkingArea*> > candidates;
874 if (pav.first == destParkArea) {
882 candidates.push_back(std::make_pair(dummy, pav.first));
884 std::sort(candidates.begin(), candidates.end(),
885 [](std::tuple<SUMOTime, MSParkingArea*>
const & t1, std::tuple<SUMOTime, MSParkingArea*>
const & t2) {
886 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());
889 for (
auto item : candidates) {
891 if (
addParkValues(veh, brakeGap, newDestination, pa, 0, 1, router, parkAreas, newRoutes, parkApproaches, maxValues)) {
894 std::cout <<
" altPA=" << pa->
getID() <<
" targeting occupied pa (based on pure randomness) among " << candidates.size() <<
" alternatives\n";
908 std::cout <<
" maxValues=" <<
joinToString(maxValues,
" ",
":") <<
"\n";
913 double minParkingCost = 0.0;
915 for (MSParkingAreaMap_t::iterator it = parkAreas.begin(); it != parkAreas.end(); ++it) {
919 if (weights[
"probability"] > 0 && maxValues[
"probability"] > 0.0) {
921 bool dominated =
false;
922 double endPos = it->first->getEndLanePosition();
924 assert(to1.size() > 0);
925 for (
auto altPa : parkAreas) {
926 if (altPa.first == it->first) {
930 assert(to2.size() > 0);
931 if (to1.size() > to2.size()) {
932 if (std::equal(to2.begin(), to2.end(), to1.begin())) {
938 }
else if (to1 == to2 && endPos > altPa.first->getEndLanePosition()) {
948 parkValues[
"probability"] = 1.0 - prob / maxValues[
"probability"];
951 parkValues[
"probability"] = 1.0;
955 parkValues[
"probability"] = 0;
958 parkValues[
"capacity"] = maxValues[
"capacity"] > 0.0 ? 1.0 - parkValues[
"capacity"] / maxValues[
"capacity"] : 0.0;
959 parkValues[
"absfreespace"] = maxValues[
"absfreespace"] > 0.0 ? 1.0 - parkValues[
"absfreespace"] / maxValues[
"absfreespace"] : 0.0;
960 parkValues[
"relfreespace"] = maxValues[
"relfreespace"] > 0.0 ? 1.0 - parkValues[
"relfreespace"] / maxValues[
"relfreespace"] : 0.0;
962 parkValues[
"distanceto"] = maxValues[
"distanceto"] > 0.0 ? parkValues[
"distanceto"] / maxValues[
"distanceto"] : 0.0;
963 parkValues[
"timeto"] = maxValues[
"timeto"] > 0.0 ? parkValues[
"timeto"] / maxValues[
"timeto"] : 0.0;
965 parkValues[
"distancefrom"] = maxValues[
"distancefrom"] > 0.0 ? parkValues[
"distancefrom"] / maxValues[
"distancefrom"] : 0.0;
966 parkValues[
"timefrom"] = maxValues[
"timefrom"] > 0.0 ? parkValues[
"timefrom"] / maxValues[
"timefrom"] : 0.0;
969 double parkingCost = 0.0;
972 for (ParkingParamMap_t::iterator pc = parkValues.begin(); pc != parkValues.end(); ++pc) {
973 parkingCost += weights[pc->first] * pc->second;
982 if (nearParkArea ==
nullptr || parkingCost < minParkingCost) {
983 minParkingCost = parkingCost;
984 nearParkArea = it->first;
985 newRoute = newRoutes[nearParkArea];
990 std::cout <<
" altPA=" << it->first->
getID() <<
" score=" << parkingCost <<
" vals=" <<
joinToString(parkValues,
" ",
":") <<
"\n";
998 std::cout <<
SIMTIME <<
" rerouter=" << getID() <<
" veh=" << veh.getID() <<
" rerouteParkingArea dest=" << destParkArea->getID() <<
" sufficient space\n";
1009 return nearParkArea;
1018 std::map<MSParkingArea*, ConstMSEdgeVector>& newRoutes,
1019 std::map<MSParkingArea*, ConstMSEdgeVector>& parkApproaches,
1038 std::cout <<
" altPA=" << pa->
getID() <<
" vehEdge=" << veh.
getEdge()->
getID() <<
" parkEdge " << parkEdge->
getID() <<
" edgesToPark=" << edgesToPark.size() <<
"\n";
1042 if (edgesToPark.size() > 0) {
1044 if (rerouteOrigin != veh.
getEdge()) {
1045 edgesToPark.insert(edgesToPark.begin(), veh.
getEdge());
1048 parkApproaches[pa] = edgesToPark;
1052 int nextDestinationIndex = route.
size() - 1;
1053 if (!newDestination) {
1054 std::vector<std::pair<int, double> > stopIndices = veh.
getStopIndices();
1055 if (stopIndices.size() > 1) {
1056 nextDestinationIndex = stopIndices[1].first;
1057 nextDestination = route.
getEdges()[nextDestinationIndex];
1058 nextPos = stopIndices[1].second;
1061 router.
compute(parkEdge, parkPos, nextDestination, nextPos, &veh,
MSNet::getInstance()->getCurrentTimeStep(), edgesFromPark,
true);
1069 if (edgesFromPark.size() > 0 || newDestination) {
1071 parkValues[
"probability"] = prob;
1073 if (parkValues[
"probability"] > maxValues[
"probability"]) {
1074 maxValues[
"probability"] = parkValues[
"probability"];
1077 parkValues[
"capacity"] = (double)(pa->
getCapacity());
1078 parkValues[
"absfreespace"] = (double)(pa->
getCapacity() - paOccupancy);
1080 parkValues[
"relfreespace"] = parkValues[
"absfreespace"] /
MAX2(1.0, parkValues[
"capacity"]);
1082 if (parkValues[
"capacity"] > maxValues[
"capacity"]) {
1083 maxValues[
"capacity"] = parkValues[
"capacity"];
1086 if (parkValues[
"absfreespace"] > maxValues[
"absfreespace"]) {
1087 maxValues[
"absfreespace"] = parkValues[
"absfreespace"];
1090 if (parkValues[
"relfreespace"] > maxValues[
"relfreespace"]) {
1091 maxValues[
"relfreespace"] = parkValues[
"relfreespace"];
1094 MSRoute routeToPark(route.
getID() +
"!topark#1", edgesToPark,
false,
1103 routeToPark.
begin(), routeToPark.
end() - 1, includeInternalLengths);
1105 if (parkValues[
"distanceto"] == std::numeric_limits<double>::max()) {
1106 WRITE_WARNINGF(
TL(
"Invalid distance computation for vehicle '%' to parkingArea '%' at time=%."),
1112 const double distToEnd = parkValues[
"distanceto"] - toPos + endPos;
1115 std::cout <<
" " << veh.
getID() <<
" candidate=" << pa->
getID()
1116 <<
" distanceTo=" << parkValues[
"distanceto"]
1117 <<
" brakeGap=" << brakeGap
1118 <<
" routeToPark=" <<
toString(edgesToPark)
1121 <<
" toPos=" << toPos
1123 <<
" distToEnd=" << distToEnd
1128 if (distToEnd < brakeGap) {
1132 std::cout <<
" altPA=" << pa->
getID() <<
" too close to brake (dist=" << distToEnd <<
" brakeGap=" << brakeGap <<
"\n";
1141 if (parkValues[
"distanceto"] > maxValues[
"distanceto"]) {
1142 maxValues[
"distanceto"] = parkValues[
"distanceto"];
1145 if (parkValues[
"timeto"] > maxValues[
"timeto"]) {
1146 maxValues[
"timeto"] = parkValues[
"timeto"];
1151 if (newDestination) {
1152 parkValues[
"distancefrom"] = 0;
1153 parkValues[
"timefrom"] = 0;
1155 MSRoute routeFromPark(route.
getID() +
"!frompark#1", edgesFromPark,
false,
1159 routeFromPark.
begin(), routeFromPark.
end() - 1, includeInternalLengths);
1160 if (parkValues[
"distancefrom"] == std::numeric_limits<double>::max()) {
1161 WRITE_WARNINGF(
TL(
"Invalid distance computation for vehicle '%' from parkingArea '%' at time=%."),
1166 newEdges.insert(newEdges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
1167 newEdges.insert(newEdges.end(), route.
begin() + nextDestinationIndex + 1, route.
end());
1170 if (parkValues[
"distancefrom"] > maxValues[
"distancefrom"]) {
1171 maxValues[
"distancefrom"] = parkValues[
"distancefrom"];
1174 if (parkValues[
"timefrom"] > maxValues[
"timefrom"]) {
1175 maxValues[
"timefrom"] = parkValues[
"timefrom"];
1178 parkAreas[pa] = parkValues;
1179 newRoutes[pa] = newEdges;
1190 std::cout <<
" altPA=" << pa->
getID() <<
" disconnected\n";
1204 for (
auto vTypeDist : vTypeDists) {
1219 std::set<MSEdge*> parkingRerouterEdges;
1220 std::map<MSParkingArea*, std::string, ComparatorIdLess> targetedParkingArea;
1222 bool hasParkingReroute =
false;
1225 hasParkingReroute =
true;
1227 targetedParkingArea[pav.first] = rr.first;
1231 if (hasParkingReroute) {
1232 parkingRerouterEdges.insert(rr.second->myEdges.begin(), rr.second->myEdges.end());
1235 for (
const auto& item : targetedParkingArea) {
1236 if (parkingRerouterEdges.count(&item.first->getLane().getEdge()) == 0) {
1237 WRITE_WARNINGF(
TL(
"ParkingArea '%' is targeted by rerouter '%' but doesn't have it's own rerouter. This may cause parking search to abort."),
1238 item.first->getID(), item.second);
std::vector< const MSEdge * > ConstMSEdgeVector
std::vector< MSEdge * > MSEdgeVector
#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)
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 destination 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, int queueIndex=-1)
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.
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
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
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
RandomDistributor< ConstMSRoutePtr > myCurrentRouteProb
new routes with probabilities
double getUserProbability() const
Returns the rerouting probability given by the user.
static MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute)
std::vector< MSLane * > myCurrentClosedLanes
List of closed lanes.
bool myHaveParkProbs
whether this rerouter has loaded parkingReroute definitions
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.
static 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)
determine attributes of candiate parking area for scoring
static MSEdge mySpecialDest_terminateRoute
virtual void myEndElement(int element)
Called when a closing tag occurs.
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.
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
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.
static double getWeight(SUMOVehicle &veh, const std::string param, const double defaultWeight)
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.
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.
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 ConstMSEdgeVector::const_iterator getRerouteOrigin() const =0
Returns the starting point for reroutes (usually the current edge)
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 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 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 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 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.
RandomDistributor< ConstMSRoutePtr > routeProbs
The distributions of new routes to use.
SUMOTime end
The end time these definitions are valid.
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations 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.