62 #define DEBUGCOND (veh.isSelected())
78 double prob,
const std::string& file,
bool off,
80 const std::string& vTypes) :
86 myUserProbability(prob),
87 myAmInUserMode(false),
88 myTimeThreshold(timeThreshold) {
91 for (MSEdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
97 const std::vector<MSLane*>& destLanes = (*j)->getLanes();
98 for (std::vector<MSLane*>::const_iterator i = destLanes.begin(); i != destLanes.end(); ++i) {
99 (*i)->addMoveReminder(
this);
129 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": No destination edge id given.");
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 ==
"") {
219 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": No parking area id given.");
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).");
260 std::set<MSEdge*> affected;
262 affected.insert(&l->
getEdge());
268 if (closingBegin < simBegin && ri.end > simBegin) {
293 bool updateVehicles =
false;
295 if (i.begin == currentTime && !(i.closed.empty() && i.closedLanes.empty()) && i.permissions !=
SVCAll) {
296 for (
MSEdge* e : i.closed) {
299 lane->setPermissions(i.permissions, i.id);
302 updateVehicles =
true;
304 for (
MSLane* lane : i.closedLanes) {
307 updateVehicles =
true;
312 if (i.end == currentTime && !(i.closed.empty() && i.closedLanes.empty()) && i.permissions !=
SVCAll) {
313 for (
MSEdge* e : i.closed) {
315 lane->resetPermissions(i.id);
319 updateVehicles =
true;
321 for (
MSLane* lane : i.closedLanes) {
324 updateVehicles =
true;
328 if (updateVehicles) {
332 e->rebuildAllowedTargets();
342 if (i->begin <= time && i->end > time) {
345 i->edgeProbs.getOverallProb() > 0 ||
347 i->routeProbs.getOverallProb() > 0 ||
349 i->parkProbs.getOverallProb() > 0 ||
365 if (i->begin <= time && i->end > time) {
366 if (i->parkProbs.getOverallProb() != 0 || i->edgeProbs.getOverallProb() != 0 || i->routeProbs.getOverallProb() != 0 || !i->closed.empty()) {
401 if (rerouteDef ==
nullptr) {
413 if (rerouteDef->
closedLanes.size() > 0 && !hasReroutingDevice) {
419 #ifdef DEBUG_REROUTER
429 bool newDestination =
false;
432 if (newParkingArea !=
nullptr) {
438 if (newDestination) {
453 const double savings = previousCost - routeCost;
462 std::string errorMsg;
467 +
"' could not reroute to new parkingArea '" + newParkingArea->
getID()
477 if (newRoute !=
nullptr) {
478 #ifdef DEBUG_REROUTER
480 std::cout <<
" replacedRoute from routeDist " << newRoute->
getID() <<
"\n";
486 const MSEdge* newEdge = lastEdge;
488 double newArrivalPos = -1;
489 const bool destUnreachable = std::find(rerouteDef->
closed.begin(), rerouteDef->
closed.end(), lastEdge) != rerouteDef->
closed.end();
490 bool keepDestination =
false;
493 if (rerouteDef->
closed.size() == 0 || destUnreachable) {
496 keepDestination =
true;
504 WRITE_WARNING(
"Cannot keep destination edge '" + lastEdge->
getID() +
"' for vehicle '" + veh.
getID() +
"' due to closed edges. Terminating route.");
509 }
else if (newEdge ==
nullptr) {
510 #ifdef DEBUG_REROUTER
512 std::cout <<
" could not find new edge!\n";
530 while (edges.size() == 0 && edgeProbs2.
getVals().size() > 0) {
531 newEdge = edgeProbs2.
get();
551 #ifdef DEBUG_REROUTER
552 if (
DEBUGCOND) std::cout <<
" rerouting: newDest=" << newEdge->
getID()
554 <<
" useNewRoute=" << useNewRoute <<
" newArrivalPos=" << newArrivalPos <<
" numClosed=" << rerouteDef->
closed.size()
557 if (useNewRoute && newArrivalPos != -1) {
616 return defaultWeight;
638 if (destParkArea ==
nullptr) {
643 bool destVisible =
false;
644 for (
auto paVis : parks) {
645 if (paVis.first == destParkArea
655 const int parkAnywhere = (int)
getWeight(veh,
"parking.anywhere", -1);
663 if (pav.second && pav.first->getLastStepOccupancy() == pav.first->getCapacity()) {
676 double bestDist = std::numeric_limits<double>::max();
685 if (distToEnd > brakeGap) {
687 if (distToStart < bestDist) {
688 bestDist = distToStart;
704 if (!destVisible && onTheWay ==
nullptr) {
719 <<
" rerouteParkingArea dest=" << destParkArea->
getID()
721 <<
" newDest=" << newDestination
727 std::map<MSParkingArea*, ConstMSEdgeVector> newRoutes;
728 std::map<MSParkingArea*, ConstMSEdgeVector> parkApproaches;
731 weights[
"probability"] =
getWeight(veh,
"parking.probability.weight", 0.0);
734 weights[
"capacity"] =
getWeight(veh,
"parking.capacity.weight", 0.0);
737 weights[
"absfreespace"] =
getWeight(veh,
"parking.absfreespace.weight", 0.0);
740 weights[
"relfreespace"] =
getWeight(veh,
"parking.relfreespace.weight", 0.0);
743 weights[
"distanceto"] =
getWeight(veh,
"parking.distanceto.weight",
getWeight(veh,
"parking.distance.weight", 1.0));
746 weights[
"timeto"] =
getWeight(veh,
"parking.timeto.weight", 0.0);
749 weights[
"distancefrom"] =
getWeight(veh,
"parking.distancefrom.weight", 0.0);
752 weights[
"timefrom"] =
getWeight(veh,
"parking.timefrom.weight", 0.0);
757 maxValues[
"probability"] = 0.0;
758 maxValues[
"capacity"] = 0.0;
759 maxValues[
"absfreespace"] = 0.0;
760 maxValues[
"relfreespace"] = 0.0;
761 maxValues[
"distanceto"] = 0.0;
762 maxValues[
"timeto"] = 0.0;
763 maxValues[
"distancefrom"] = 0.0;
764 maxValues[
"timefrom"] = 0.0;
775 if (onTheWay !=
nullptr) {
777 if (newDestination) {
778 newRoute.push_back(veh.
getEdge());
780 bool valid =
addParkValues(veh, brakeGap, newDestination, onTheWay, onTheWay->
getLastStepOccupancy(), 1, router, parkAreas, newRoutes, parkApproaches, maxValues);
782 WRITE_WARNING(
"Parkingarea '" + onTheWay->
getID() +
"' along the way cannot be used by vehicle '" + veh.
getID() +
"' for unknown reason");
785 newRoute = newRoutes[onTheWay];
790 int numAlternatives = 0;
791 std::vector<std::tuple<SUMOTime, MSParkingArea*, int> > blockedTimes;
797 const double parkingFrustration =
getWeight(veh,
"parking.frustration", 100);
798 const double parkingKnowledge =
getWeight(veh,
"parking.knowledge", 0);
800 for (
int i = 0; i < (int)parks.size(); ++i) {
804 const bool visible = parks[i].second || (pa == destParkArea && destVisible);
811 if (blockedTime >= 0 &&
SIMSTEP - blockedTime < parkingMemory) {
814 blockedTimes.push_back(std::make_tuple(blockedTime, pa, i));
817 std::cout <<
" altPA=" << pa->
getID() <<
" was blocked at " <<
time2string(blockedTime) <<
"\n";
822 if (paOccupancy < pa->getCapacity()) {
823 if (
addParkValues(veh, brakeGap, newDestination, pa, paOccupancy, probs[i], router, parkAreas, newRoutes, parkApproaches, maxValues)) {
826 }
else if (visible) {
832 if (numAlternatives == 0) {
834 std::sort(blockedTimes.begin(), blockedTimes.end(),
835 [](std::tuple<SUMOTime, MSParkingArea*, int>
const & t1, std::tuple<SUMOTime, MSParkingArea*, int>
const & t2) {
836 if (std::get<0>(t1) < std::get<0>(t2)) {
839 if (std::get<0>(t1) == std::get<0>(t2)) {
840 if (std::get<1>(t1)->
getID() < std::get<1>(t2)->
getID()) {
843 if (std::get<1>(t1)->
getID() == std::get<1>(t2)->
getID()) {
844 return std::get<2>(t1) < std::get<2>(t2);
850 for (
auto item : blockedTimes) {
852 double prob = probs[std::get<2>(item)];
856 if (
addParkValues(veh, brakeGap, newDestination, pa, paOccupancy, prob, router, parkAreas, newRoutes, parkApproaches, maxValues)) {
862 if (numAlternatives == 0) {
864 std::vector<std::pair<SUMOTime, MSParkingArea*> > candidates;
866 if (pav.first == destParkArea) {
874 candidates.push_back(std::make_pair(dummy, pav.first));
876 std::sort(candidates.begin(), candidates.end(),
877 [](std::tuple<SUMOTime, MSParkingArea*>
const & t1, std::tuple<SUMOTime, MSParkingArea*>
const & t2) {
878 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());
881 for (
auto item : candidates) {
883 if (
addParkValues(veh, brakeGap, newDestination, pa, 0, 1, router, parkAreas, newRoutes, parkApproaches, maxValues)) {
895 std::cout <<
" maxValues=" <<
joinToString(maxValues,
" ",
":") <<
"\n";
900 double minParkingCost = 0.0;
902 for (MSParkingAreaMap_t::iterator it = parkAreas.begin(); it != parkAreas.end(); ++it) {
906 if (weights[
"probability"] > 0 && maxValues[
"probability"] > 0.0) {
908 bool dominated =
false;
909 double endPos = it->first->getEndLanePosition();
911 assert(to1.size() > 0);
912 for (
auto altPa : parkAreas) {
913 if (altPa.first == it->first) {
917 assert(to2.size() > 0);
918 if (to1.size() > to2.size()) {
919 if (std::equal(to2.begin(), to2.end(), to1.begin())) {
925 }
else if (to1 == to2 && endPos > altPa.first->getEndLanePosition()) {
935 parkValues[
"probability"] = 1.0 - prob / maxValues[
"probability"];
938 parkValues[
"probability"] = 1.0;
942 parkValues[
"probability"] = 0;
945 parkValues[
"capacity"] = maxValues[
"capacity"] > 0.0 ? 1.0 - parkValues[
"capacity"] / maxValues[
"capacity"] : 0.0;
946 parkValues[
"absfreespace"] = maxValues[
"absfreespace"] > 0.0 ? 1.0 - parkValues[
"absfreespace"] / maxValues[
"absfreespace"] : 0.0;
947 parkValues[
"relfreespace"] = maxValues[
"relfreespace"] > 0.0 ? 1.0 - parkValues[
"relfreespace"] / maxValues[
"relfreespace"] : 0.0;
949 parkValues[
"distanceto"] = maxValues[
"distanceto"] > 0.0 ? parkValues[
"distanceto"] / maxValues[
"distanceto"] : 0.0;
950 parkValues[
"timeto"] = maxValues[
"timeto"] > 0.0 ? parkValues[
"timeto"] / maxValues[
"timeto"] : 0.0;
952 parkValues[
"distancefrom"] = maxValues[
"distancefrom"] > 0.0 ? parkValues[
"distancefrom"] / maxValues[
"distancefrom"] : 0.0;
953 parkValues[
"timefrom"] = maxValues[
"timefrom"] > 0.0 ? parkValues[
"timefrom"] / maxValues[
"timefrom"] : 0.0;
956 double parkingCost = 0.0;
959 for (ParkingParamMap_t::iterator pc = parkValues.begin(); pc != parkValues.end(); ++pc) {
960 parkingCost += weights[pc->first] * pc->second;
969 if (nearParkArea ==
nullptr || parkingCost < minParkingCost) {
970 minParkingCost = parkingCost;
971 nearParkArea = it->first;
972 newRoute = newRoutes[nearParkArea];
977 std::cout <<
" altPA=" << it->first->
getID() <<
" score=" << parkingCost <<
" vals=" <<
joinToString(parkValues,
" ",
":") <<
"\n";
985 std::cout <<
SIMTIME <<
" rerouter=" << getID() <<
" veh=" << veh.getID() <<
" rerouteParkingArea dest=" << destParkArea->getID() <<
" sufficient space\n";
1005 std::map<MSParkingArea*, ConstMSEdgeVector>& newRoutes,
1006 std::map<MSParkingArea*, ConstMSEdgeVector>& parkApproaches,
1023 #ifdef DEBUG_PARKING
1025 std::cout <<
" altPA=" << pa->
getID() <<
" vehEdge=" << veh.
getEdge()->
getID() <<
" parkEdge " << parkEdge->
getID() <<
" edgesToPark=" << edgesToPark.size() <<
"\n";
1029 if (edgesToPark.size() > 0) {
1031 if (rerouteOrigin != veh.
getEdge()) {
1032 edgesToPark.insert(edgesToPark.begin(), veh.
getEdge());
1035 parkApproaches[pa] = edgesToPark;
1039 int nextDestinationIndex = route.
size() - 1;
1040 if (!newDestination) {
1041 std::vector<std::pair<int, double> > stopIndices = veh.
getStopIndices();
1042 if (stopIndices.size() > 1) {
1043 nextDestinationIndex = stopIndices[1].first;
1044 nextDestination = route.
getEdges()[nextDestinationIndex];
1045 nextPos = stopIndices[1].second;
1048 router.
compute(parkEdge, parkPos, nextDestination, nextPos, &veh,
MSNet::getInstance()->getCurrentTimeStep(), edgesFromPark,
true);
1050 #ifdef DEBUG_PARKING
1056 if (edgesFromPark.size() > 0 || newDestination) {
1058 parkValues[
"probability"] = prob;
1060 if (parkValues[
"probability"] > maxValues[
"probability"]) {
1061 maxValues[
"probability"] = parkValues[
"probability"];
1064 parkValues[
"capacity"] = (double)(pa->
getCapacity());
1065 parkValues[
"absfreespace"] = (double)(pa->
getCapacity() - paOccupancy);
1067 parkValues[
"relfreespace"] = parkValues[
"absfreespace"] /
MAX2(1.0, parkValues[
"capacity"]);
1069 if (parkValues[
"capacity"] > maxValues[
"capacity"]) {
1070 maxValues[
"capacity"] = parkValues[
"capacity"];
1073 if (parkValues[
"absfreespace"] > maxValues[
"absfreespace"]) {
1074 maxValues[
"absfreespace"] = parkValues[
"absfreespace"];
1077 if (parkValues[
"relfreespace"] > maxValues[
"relfreespace"]) {
1078 maxValues[
"relfreespace"] = parkValues[
"relfreespace"];
1081 MSRoute routeToPark(route.
getID() +
"!topark#1", edgesToPark,
false,
1090 routeToPark.
begin(), routeToPark.
end() - 1, includeInternalLengths);
1092 if (parkValues[
"distanceto"] == std::numeric_limits<double>::max()) {
1093 WRITE_WARNINGF(
"Invalid distance computation for vehicle '%' to parkingArea '%' at time=%.",
1097 #ifdef DEBUG_PARKING
1099 std::cout <<
" " << veh.
getID() <<
" candidate=" << pa->
getID()
1100 <<
" distanceTo=" << parkValues[
"distanceto"]
1101 <<
" brakeGap=" << brakeGap
1102 <<
" routeToPark=" <<
toString(edgesToPark)
1109 const double distToEnd = parkValues[
"distanceto"] - toPos + pa->
getEndLanePosition();
1110 if (distToEnd < brakeGap) {
1112 #ifdef DEBUG_PARKING
1114 std::cout <<
" altPA=" << pa->
getID() <<
" too close to brake (dist=" << distToEnd <<
" brakeGap=" << brakeGap <<
"\n";
1123 if (parkValues[
"distanceto"] > maxValues[
"distanceto"]) {
1124 maxValues[
"distanceto"] = parkValues[
"distanceto"];
1127 if (parkValues[
"timeto"] > maxValues[
"timeto"]) {
1128 maxValues[
"timeto"] = parkValues[
"timeto"];
1133 if (newDestination) {
1134 parkValues[
"distancefrom"] = 0;
1135 parkValues[
"timefrom"] = 0;
1137 MSRoute routeFromPark(route.
getID() +
"!frompark#1", edgesFromPark,
false,
1141 routeFromPark.
begin(), routeFromPark.
end() - 1, includeInternalLengths);
1142 if (parkValues[
"distancefrom"] == std::numeric_limits<double>::max()) {
1143 WRITE_WARNINGF(
"Invalid distance computation for vehicle '%' from parkingArea '%' at time=%.",
1148 newEdges.insert(newEdges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
1149 newEdges.insert(newEdges.end(), route.
begin() + nextDestinationIndex + 1, route.
end());
1152 if (parkValues[
"distancefrom"] > maxValues[
"distancefrom"]) {
1153 maxValues[
"distancefrom"] = parkValues[
"distancefrom"];
1156 if (parkValues[
"timefrom"] > maxValues[
"timefrom"]) {
1157 maxValues[
"timefrom"] = parkValues[
"timefrom"];
1160 parkAreas[pa] = parkValues;
1161 newRoutes[pa] = newEdges;
1170 #ifdef DEBUG_PARKING
1172 std::cout <<
" altPA=" << pa->
getID() <<
" disconnected\n";
1186 for (
auto vTypeDist : vTypeDists) {
1201 std::set<MSEdge*> parkingRerouterEdges;
1202 std::map<MSParkingArea*, std::string, ComparatorIdLess> targetedParkingArea;
1204 bool hasParkingReroute =
false;
1207 hasParkingReroute =
true;
1209 targetedParkingArea[pav.first] = rr.first;
1213 if (hasParkingReroute) {
1214 parkingRerouterEdges.insert(rr.second->myEdges.begin(), rr.second->myEdges.end());
1217 for (
const auto& item : targetedParkingArea) {
1218 if (parkingRerouterEdges.count(&item.first->getLane().getEdge()) == 0) {
1219 WRITE_WARNINGF(
"ParkingArea '%' is targeted by rerouter '%' but doesn't have it's own rerouter. This may cause parking search to abort.",
1220 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()
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).
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
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.
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
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 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.
const ConstMSEdgeVector & getEdges() const
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.
An abstract device that changes the state of the micro simulation.
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;.
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
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, double prob, const std::string &file, bool off, SUMOTime timeThreshold, const std::string &vTypes)
Constructor.
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
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.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
const std::vector< T > & getVals() const
Returns the members of the distribution.
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.
bool remove(T val)
Removes a value with an assigned probability from the distribution.
void clear()
Clears 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, 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.
SAX-handler base for SUMO-files.
Representation of a vehicle, person, or container.
virtual SUMOTime getWaitingTime() const =0
virtual bool isVehicle() const
Whether it is a vehicle.
virtual SumoRNG * getRNG() const =0
Returns the associated RNG for this object.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
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 std::vector< std::pair< int, double > > getStopIndices() const =0
return list of route indices and stop positions for the remaining stops
virtual const MSRoute & getRoute() const =0
Returns the current route.
virtual MSParkingArea * getNextParkingArea()=0
virtual void rememberParkingAreaScore(const MSParkingArea *pa, const std::string &score)=0
virtual bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)=0
Replaces a stop.
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 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 const std::vector< MSTransportable * > & getPersons() const =0
retrieve riding persons
virtual int getNumberParkingReroutes() const =0
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
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 const MSEdge * getRerouteOrigin() const =0
Returns the starting point for reroutes (usually the current edge)
virtual void rememberBlockedParkingArea(const MSParkingArea *pa, bool local)=0
virtual SUMOTime sawBlockedParkingArea(const MSParkingArea *pa, bool local) const =0
virtual void resetParkingAreaScores()=0
virtual double getBrakeGap(bool delayed=false) const =0
get distance for coming to a stop (used for rerouting checks)
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle's desired arrivalPos for its current route.
virtual void setNumberParkingReroutes(int value)=0
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.