62 #define DEBUGCOND (veh.isSelected())
78 const MSEdgeVector& edges,
double prob,
bool off,
bool optional,
84 myUserProbability(prob),
85 myAmInUserMode(false),
86 myAmOptional(optional),
88 myTimeThreshold(timeThreshold),
89 myHaveParkProbs(false) {
92 for (
const MSEdge*
const e : edges) {
96 for (
MSLane*
const lane : e->getLanes()) {
97 lane->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).");
158 if (closed ==
nullptr) {
159 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Edge '" + closed_id +
"' to close is not known.");
172 if (closed ==
nullptr) {
173 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).");
214 if (parkingarea ==
"") {
219 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Parking area '" + parkingarea +
"' is not known.");
228 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Attribute 'probability' for destination '" + parkingarea +
"' is negative (must not).");
243 if (via ==
nullptr) {
244 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Via edge '" + viaID +
"' is not known.");
253 throw ProcessError(
"MSTriggeredRerouter " +
getID() +
": Attribute 'probability' for via '" + viaID +
"' is negative (must not).");
278 if (closingBegin < simBegin && myParsedRerouteInterval.end > simBegin) {
298 bool updateVehicles =
false;
300 if (i.begin == currentTime && !(i.closed.empty() && i.closedLanes.empty()) && i.permissions !=
SVCAll) {
301 for (
MSEdge*
const e : i.closed) {
304 lane->setPermissions(i.permissions, i.id);
307 updateVehicles =
true;
309 for (
MSLane*
const lane : i.closedLanes) {
312 updateVehicles =
true;
317 if (i.end == currentTime && !(i.closed.empty() && i.closedLanes.empty()) && i.permissions !=
SVCAll) {
318 for (
MSEdge*
const e : i.closed) {
320 lane->resetPermissions(i.id);
324 updateVehicles =
true;
326 for (
MSLane* lane : i.closedLanes) {
329 updateVehicles =
true;
333 if (updateVehicles) {
337 e->rebuildAllowedTargets();
347 if (ri.begin <= time && ri.end > time) {
350 ri.edgeProbs.getOverallProb() > 0 ||
352 ri.routeProbs.getOverallProb() > 0 ||
354 ri.parkProbs.getOverallProb() > 0) {
357 if (!ri.closed.empty() || !ri.closedLanesAffected.empty()) {
358 const std::set<SUMOTrafficObject::NumericalID>& edgeIndices = obj.
getUpcomingEdgeIDs();
359 if (
affected(edgeIndices, ri.closed) ||
affected(edgeIndices, ri.closedLanesAffected)) {
372 if (ri.begin <= time && ri.end > time) {
373 if (ri.edgeProbs.getOverallProb() != 0 || ri.routeProbs.getOverallProb() != 0 || ri.parkProbs.getOverallProb() != 0
374 || !ri.closed.empty() || !ri.closedLanesAffected.empty()) {
414 if (rerouteDef ==
nullptr) {
429 if (rerouteDef->
closedLanes.size() > 0 && !hasReroutingDevice) {
433 #ifdef DEBUG_REROUTER
435 std::cout <<
SIMTIME <<
" veh=" << veh.getID() <<
" check rerouter " <<
getID() <<
" lane=" <<
Named::getIDSecure(veh.getLane()) <<
" edge=" << veh.getEdge()->getID() <<
" finalEdge=" << lastEdge->
getID() <<
" arrivalPos=" << veh.getArrivalPos() <<
"\n";
447 bool newDestination =
false;
450 if (newParkingArea !=
nullptr) {
456 if (newDestination) {
471 const double savings = previousCost - routeCost;
480 std::string errorMsg;
485 +
"' could not reroute to new parkingArea '" + newParkingArea->
getID()
495 if (newRoute !=
nullptr) {
496 #ifdef DEBUG_REROUTER
498 std::cout <<
" replacedRoute from routeDist " << newRoute->getID() <<
"\n";
504 const MSEdge* newEdge = lastEdge;
506 double newArrivalPos = -1;
507 const bool destUnreachable = std::find(rerouteDef->
closed.begin(), rerouteDef->
closed.end(), lastEdge) != rerouteDef->
closed.end();
508 bool keepDestination =
false;
511 if (rerouteDef->
closed.empty() || destUnreachable || rerouteDef->
isVia) {
513 assert(newEdge !=
nullptr);
515 keepDestination =
true;
523 WRITE_WARNINGF(
TL(
"Cannot keep destination edge '%' for vehicle '%' due to closed edges. Terminating route."), lastEdge->
getID(), tObject.
getID());
531 std::vector<MSTransportableRouter::TripItem> items;
544 while (edges.size() == 0 && edgeProbs2.
getVals().size() > 0) {
545 newEdge = edgeProbs2.
get();
559 if (!rerouteDef->
isVia) {
565 #ifdef DEBUG_REROUTER
566 if (
DEBUGCOND) std::cout <<
" rerouting: newDest=" << newEdge->
getID()
568 <<
" useNewRoute=" << useNewRoute <<
" newArrivalPos=" << newArrivalPos <<
" numClosed=" << rerouteDef->
closed.size()
571 if (useNewRoute && newArrivalPos != -1) {
585 if (!rerouteDef->
isVia) {
588 if (!it.edges.empty() && !edges.empty() && edges.back() == it.edges.front()) {
591 edges.insert(edges.end(), std::make_move_iterator(it.edges.begin()), std::make_move_iterator(it.edges.end()));
592 if (!edges.empty()) {
604 if (rerouteDef->
isVia) {
607 if (!edges.empty()) {
613 router.
compute(newEdge, lastEdge, &veh, now, edges);
619 #ifdef DEBUG_REROUTER
620 if (
DEBUGCOND) std::cout <<
" rerouting: newDest=" << newEdge->
getID()
622 <<
" useNewRoute=" << useNewRoute <<
" newArrivalPos=" << newArrivalPos <<
" numClosed=" << rerouteDef->
closed.size()
625 if (useNewRoute && newArrivalPos != -1) {
631 bool success = !items.empty();
642 if (!it.edges.empty() && !edges.empty() && edges.back() == it.edges.front()) {
645 edges.insert(edges.end(), std::make_move_iterator(it.edges.begin()), std::make_move_iterator(it.edges.end()));
647 if (!edges.empty()) {
710 return defaultWeight;
732 if (destParkArea ==
nullptr) {
739 for (
auto paVis : parks) {
740 if (paVis.first == destParkArea && paVis.second) {
747 const int parkAnywhere = (int)
getWeight(veh,
"parking.anywhere", -1);
755 if (pav.second && pav.first->getLastStepOccupancy() == pav.first->getCapacity()) {
768 double bestDist = std::numeric_limits<double>::max();
777 if (distToEnd > brakeGap) {
779 if (distToStart < bestDist) {
780 bestDist = distToStart;
796 if (!destVisible && onTheWay ==
nullptr) {
811 <<
" rerouteParkingArea dest=" << destParkArea->
getID()
813 <<
" newDest=" << newDestination
820 std::map<MSParkingArea*, ConstMSEdgeVector> newRoutes;
821 std::map<MSParkingArea*, ConstMSEdgeVector> parkApproaches;
824 weights[
"probability"] =
getWeight(veh,
"parking.probability.weight", 0.0);
827 weights[
"capacity"] =
getWeight(veh,
"parking.capacity.weight", 0.0);
830 weights[
"absfreespace"] =
getWeight(veh,
"parking.absfreespace.weight", 0.0);
833 weights[
"relfreespace"] =
getWeight(veh,
"parking.relfreespace.weight", 0.0);
836 weights[
"distanceto"] =
getWeight(veh,
"parking.distanceto.weight",
getWeight(veh,
"parking.distance.weight", 1.0));
839 weights[
"timeto"] =
getWeight(veh,
"parking.timeto.weight", 0.0);
842 weights[
"distancefrom"] =
getWeight(veh,
"parking.distancefrom.weight", 0.0);
845 weights[
"timefrom"] =
getWeight(veh,
"parking.timefrom.weight", 0.0);
850 maxValues[
"probability"] = 0.0;
851 maxValues[
"capacity"] = 0.0;
852 maxValues[
"absfreespace"] = 0.0;
853 maxValues[
"relfreespace"] = 0.0;
854 maxValues[
"distanceto"] = 0.0;
855 maxValues[
"timeto"] = 0.0;
856 maxValues[
"distancefrom"] = 0.0;
857 maxValues[
"timefrom"] = 0.0;
868 if (onTheWay !=
nullptr) {
870 if (newDestination) {
871 newRoute.push_back(veh.
getEdge());
873 bool valid =
addParkValues(veh, brakeGap, newDestination, onTheWay, onTheWay->
getLastStepOccupancy(), 1, router, parkAreas, newRoutes, parkApproaches, maxValues);
875 WRITE_WARNINGF(
TL(
"Parkingarea '%' along the way cannot be used by vehicle '%' for unknown reason"), onTheWay->
getID(), veh.
getID());
878 newRoute = newRoutes[onTheWay];
883 int numAlternatives = 0;
884 std::vector<std::tuple<SUMOTime, MSParkingArea*, int> > blockedTimes;
890 const double parkingFrustration =
getWeight(veh,
"parking.frustration", 100);
891 const double parkingKnowledge =
getWeight(veh,
"parking.knowledge", 0);
893 for (
int i = 0; i < (int)parks.size(); ++i) {
897 const bool visible = parks[i].second || (pa == destParkArea && destVisible);
904 if (blockedTime >= 0 &&
SIMSTEP - blockedTime < parkingMemory) {
907 blockedTimes.push_back(std::make_tuple(blockedTime, pa, i));
910 std::cout <<
" altPA=" << pa->
getID() <<
" was blocked at " <<
time2string(blockedTime) <<
"\n";
915 if (paOccupancy < pa->getCapacity()) {
916 if (
addParkValues(veh, brakeGap, newDestination, pa, paOccupancy, probs[i], router, parkAreas, newRoutes, parkApproaches, maxValues)) {
919 }
else if (visible) {
925 if (numAlternatives == 0) {
927 std::sort(blockedTimes.begin(), blockedTimes.end(),
928 [](std::tuple<SUMOTime, MSParkingArea*, int>
const & t1, std::tuple<SUMOTime, MSParkingArea*, int>
const & t2) {
929 if (std::get<0>(t1) < std::get<0>(t2)) {
932 if (std::get<0>(t1) == std::get<0>(t2)) {
933 if (std::get<1>(t1)->
getID() < std::get<1>(t2)->
getID()) {
936 if (std::get<1>(t1)->
getID() == std::get<1>(t2)->
getID()) {
937 return std::get<2>(t1) < std::get<2>(t2);
943 for (
auto item : blockedTimes) {
945 double prob = probs[std::get<2>(item)];
949 if (
addParkValues(veh, brakeGap, newDestination, pa, paOccupancy, prob, router, parkAreas, newRoutes, parkApproaches, maxValues)) {
952 std::cout <<
" altPA=" << pa->
getID() <<
" targeting occupied pa based on blockTime " <<
STEPS2TIME(std::get<0>(item)) <<
" among " << blockedTimes.size() <<
" alternatives\n";
960 if (numAlternatives == 0) {
962 std::vector<std::pair<SUMOTime, MSParkingArea*> > candidates;
964 if (pav.first == destParkArea) {
972 candidates.push_back(std::make_pair(dummy, pav.first));
974 std::sort(candidates.begin(), candidates.end(),
975 [](std::tuple<SUMOTime, MSParkingArea*>
const & t1, std::tuple<SUMOTime, MSParkingArea*>
const & t2) {
976 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());
979 for (
auto item : candidates) {
981 if (
addParkValues(veh, brakeGap, newDestination, pa, 0, 1, router, parkAreas, newRoutes, parkApproaches, maxValues)) {
984 std::cout <<
" altPA=" << pa->
getID() <<
" targeting occupied pa (based on pure randomness) among " << candidates.size() <<
" alternatives\n";
998 std::cout <<
" maxValues=" <<
joinToString(maxValues,
" ",
":") <<
"\n";
1003 double minParkingCost = 0.0;
1005 for (MSParkingAreaMap_t::iterator it = parkAreas.begin(); it != parkAreas.end(); ++it) {
1009 if (weights[
"probability"] > 0 && maxValues[
"probability"] > 0.0) {
1011 bool dominated =
false;
1012 double endPos = it->first->getEndLanePosition();
1014 assert(to1.size() > 0);
1015 for (
auto altPa : parkAreas) {
1016 if (altPa.first == it->first) {
1020 assert(to2.size() > 0);
1021 if (to1.size() > to2.size()) {
1022 if (std::equal(to2.begin(), to2.end(), to1.begin())) {
1028 }
else if (to1 == to2 && endPos > altPa.first->getEndLanePosition()) {
1038 parkValues[
"probability"] = 1.0 - prob / maxValues[
"probability"];
1041 parkValues[
"probability"] = 1.0;
1045 parkValues[
"probability"] = 0;
1048 parkValues[
"capacity"] = maxValues[
"capacity"] > 0.0 ? 1.0 - parkValues[
"capacity"] / maxValues[
"capacity"] : 0.0;
1049 parkValues[
"absfreespace"] = maxValues[
"absfreespace"] > 0.0 ? 1.0 - parkValues[
"absfreespace"] / maxValues[
"absfreespace"] : 0.0;
1050 parkValues[
"relfreespace"] = maxValues[
"relfreespace"] > 0.0 ? 1.0 - parkValues[
"relfreespace"] / maxValues[
"relfreespace"] : 0.0;
1052 parkValues[
"distanceto"] = maxValues[
"distanceto"] > 0.0 ? parkValues[
"distanceto"] / maxValues[
"distanceto"] : 0.0;
1053 parkValues[
"timeto"] = maxValues[
"timeto"] > 0.0 ? parkValues[
"timeto"] / maxValues[
"timeto"] : 0.0;
1055 parkValues[
"distancefrom"] = maxValues[
"distancefrom"] > 0.0 ? parkValues[
"distancefrom"] / maxValues[
"distancefrom"] : 0.0;
1056 parkValues[
"timefrom"] = maxValues[
"timefrom"] > 0.0 ? parkValues[
"timefrom"] / maxValues[
"timefrom"] : 0.0;
1059 double parkingCost = 0.0;
1062 for (ParkingParamMap_t::iterator pc = parkValues.begin(); pc != parkValues.end(); ++pc) {
1063 parkingCost += weights[pc->first] * pc->second;
1072 if (nearParkArea ==
nullptr || parkingCost < minParkingCost) {
1073 minParkingCost = parkingCost;
1074 nearParkArea = it->first;
1075 newRoute = newRoutes[nearParkArea];
1078 #ifdef DEBUG_PARKING
1080 std::cout <<
" altPA=" << it->first->
getID() <<
" score=" << parkingCost <<
" vals=" <<
joinToString(parkValues,
" ",
":") <<
"\n";
1086 #ifdef DEBUG_PARKING
1088 std::cout <<
SIMTIME <<
" rerouter=" << getID() <<
" veh=" << veh.getID() <<
" rerouteParkingArea dest=" << destParkArea->getID() <<
" sufficient space\n";
1093 #ifdef DEBUG_PARKING
1099 return nearParkArea;
1108 std::map<MSParkingArea*, ConstMSEdgeVector>& newRoutes,
1109 std::map<MSParkingArea*, ConstMSEdgeVector>& parkApproaches,
1126 #ifdef DEBUG_PARKING
1128 std::cout <<
" altPA=" << pa->
getID() <<
" vehEdge=" << veh.
getEdge()->
getID() <<
" parkEdge " << parkEdge->
getID() <<
" edgesToPark=" << edgesToPark.size() <<
"\n";
1132 if (edgesToPark.size() > 0) {
1134 if (rerouteOrigin != veh.
getEdge()) {
1135 edgesToPark.insert(edgesToPark.begin(), veh.
getEdge());
1138 parkApproaches[pa] = edgesToPark;
1142 int nextDestinationIndex = route.
size() - 1;
1143 if (!newDestination) {
1144 std::vector<std::pair<int, double> > stopIndices = veh.
getStopIndices();
1145 if (stopIndices.size() > 1) {
1146 nextDestinationIndex = stopIndices[1].first;
1147 nextDestination = route.
getEdges()[nextDestinationIndex];
1148 nextPos = stopIndices[1].second;
1151 router.
compute(parkEdge, parkPos, nextDestination, nextPos, &veh,
MSNet::getInstance()->getCurrentTimeStep(), edgesFromPark,
true);
1153 #ifdef DEBUG_PARKING
1159 if (edgesFromPark.size() > 0 || newDestination) {
1161 parkValues[
"probability"] = prob;
1163 if (parkValues[
"probability"] > maxValues[
"probability"]) {
1164 maxValues[
"probability"] = parkValues[
"probability"];
1167 parkValues[
"capacity"] = (double)(pa->
getCapacity());
1168 parkValues[
"absfreespace"] = (double)(pa->
getCapacity() - paOccupancy);
1170 parkValues[
"relfreespace"] = parkValues[
"absfreespace"] /
MAX2(1.0, parkValues[
"capacity"]);
1172 if (parkValues[
"capacity"] > maxValues[
"capacity"]) {
1173 maxValues[
"capacity"] = parkValues[
"capacity"];
1176 if (parkValues[
"absfreespace"] > maxValues[
"absfreespace"]) {
1177 maxValues[
"absfreespace"] = parkValues[
"absfreespace"];
1180 if (parkValues[
"relfreespace"] > maxValues[
"relfreespace"]) {
1181 maxValues[
"relfreespace"] = parkValues[
"relfreespace"];
1184 MSRoute routeToPark(route.
getID() +
"!topark#1", edgesToPark,
false,
1193 routeToPark.
begin(), routeToPark.
end() - 1, includeInternalLengths);
1195 if (parkValues[
"distanceto"] == std::numeric_limits<double>::max()) {
1196 WRITE_WARNINGF(
TL(
"Invalid distance computation for vehicle '%' to parkingArea '%' at time=%."),
1202 const double distToEnd = parkValues[
"distanceto"] - toPos + endPos;
1203 #ifdef DEBUG_PARKING
1205 std::cout <<
" " << veh.
getID() <<
" candidate=" << pa->
getID()
1206 <<
" distanceTo=" << parkValues[
"distanceto"]
1207 <<
" brakeGap=" << brakeGap
1208 <<
" routeToPark=" <<
toString(edgesToPark)
1211 <<
" toPos=" << toPos
1213 <<
" distToEnd=" << distToEnd
1218 if (distToEnd < brakeGap) {
1220 #ifdef DEBUG_PARKING
1222 std::cout <<
" altPA=" << pa->
getID() <<
" too close to brake (dist=" << distToEnd <<
" brakeGap=" << brakeGap <<
"\n";
1231 if (parkValues[
"distanceto"] > maxValues[
"distanceto"]) {
1232 maxValues[
"distanceto"] = parkValues[
"distanceto"];
1235 if (parkValues[
"timeto"] > maxValues[
"timeto"]) {
1236 maxValues[
"timeto"] = parkValues[
"timeto"];
1241 if (newDestination) {
1242 parkValues[
"distancefrom"] = 0;
1243 parkValues[
"timefrom"] = 0;
1245 MSRoute routeFromPark(route.
getID() +
"!frompark#1", edgesFromPark,
false,
1249 routeFromPark.
begin(), routeFromPark.
end() - 1, includeInternalLengths);
1250 if (parkValues[
"distancefrom"] == std::numeric_limits<double>::max()) {
1251 WRITE_WARNINGF(
TL(
"Invalid distance computation for vehicle '%' from parkingArea '%' at time=%."),
1256 newEdges.insert(newEdges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
1257 newEdges.insert(newEdges.end(), route.
begin() + nextDestinationIndex + 1, route.
end());
1260 if (parkValues[
"distancefrom"] > maxValues[
"distancefrom"]) {
1261 maxValues[
"distancefrom"] = parkValues[
"distancefrom"];
1264 if (parkValues[
"timefrom"] > maxValues[
"timefrom"]) {
1265 maxValues[
"timefrom"] = parkValues[
"timefrom"];
1268 parkAreas[pa] = parkValues;
1269 newRoutes[pa] = newEdges;
1278 #ifdef DEBUG_PARKING
1280 std::cout <<
" altPA=" << pa->
getID() <<
" disconnected\n";
1294 for (
auto vTypeDist : vTypeDists) {
1306 for (
const MSEdge*
const e : closed) {
1307 if (edgeIndices.count(e->getNumericalID()) > 0) {
1320 std::set<MSEdge*> parkingRerouterEdges;
1321 std::map<MSParkingArea*, std::string, ComparatorIdLess> targetedParkingArea;
1323 bool hasParkingReroute =
false;
1326 hasParkingReroute =
true;
1328 targetedParkingArea[pav.first] = rr.first;
1332 if (hasParkingReroute) {
1333 parkingRerouterEdges.insert(rr.second->myEdges.begin(), rr.second->myEdges.end());
1336 for (
const auto& item : targetedParkingArea) {
1337 if (parkingRerouterEdges.count(&item.first->getLane().getEdge()) == 0) {
1338 WRITE_WARNINGF(
TL(
"ParkingArea '%' is targeted by rerouter '%' but doesn't have its own rerouter. This may cause parking search to abort."),
1339 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_VIA_PROB_REROUTE
probability of a via fora 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)
bool compute(const E *from, const E *to, const double departPos, const std::string &originStopID, const double arrivalPos, const std::string &stopID, const double speed, const V *const vehicle, const SVCPermissions modeSet, const SUMOTime msTime, std::vector< TripItem > &into, const double externalFactor=0.)
Builds the route between the given edges using the minimum effort at the given time The definition of...
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
void addDetector(MSMoveReminder *data, int queueIndex=-1)
Adds a data collector for a detector to this segment.
A device that performs vehicle rerouting based on current edge speeds.
A road/street connecting two junctions.
void rebuildAllowedLanes(const bool onInit=false)
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
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).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
MSTransportableRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, 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.
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
MSVehicleRouter & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
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.
const MSEdge * getLastEdge() const
returns the destination edge
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.
double getDistanceBetween(double fromPos, double toPos, const MSLane *fromLane, const MSLane *toLane, int routePosition=0) const
Compute the distance between 2 given edges on this route, optionally including the length of internal...
const ConstMSEdgeVector & getEdges() const
static MSVehicleRouter & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the vehicle router instance
static MSTransportableRouter & getIntermodalRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector())
return the person 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.
double getUserProbability() const
Returns the rerouting probability given by the user.
static MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute)
bool myHaveParkProbs
whether this rerouter has loaded parkingReroute definitions
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
bool myAmOptional
Information whether the rerouting will only take place on request.
static bool affected(const std::set< SUMOTrafficObject::NumericalID > &edgeIndices, const MSEdgeVector &closed)
void setUserUsageProbability(double prob)
Sets the probability with which a vehicle is rerouted given by the user.
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.
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, double prob, bool off, bool optional, SUMOTime timeThreshold, const std::string &vTypes, const Position &pos)
Constructor.
bool triggerRouting(SUMOTrafficObject &veh, MSMoveReminder::Notification reason)
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)
const RerouteInterval * getCurrentReroute(SUMOTime time, SUMOTrafficObject &obj) const
Returns the rerouting definition valid for the given time and object, nullptr if none.
static void checkParkingRerouteConsistency()
issues warning for incomplete parkingReroute relationships
static std::map< std::string, MSTriggeredRerouter * > myInstances
bool applies(const SUMOTrafficObject &obj) const
Checks whether the detector measures objects of the given type.
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
const MSEdgeVector myEdges
edges where vehicles are notified
static MSEdge mySpecialDest_keepDestination
special destination values
RerouteInterval myParsedRerouteInterval
used during loading
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.
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
A point in 2D or 3D with translation and scaling methods.
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.
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 const std::set< NumericalID > getUpcomingEdgeIDs() const =0
returns the numerical IDs of edges to be used (possibly of future stages)
virtual bool isVehicle() const
Whether it is a vehicle.
virtual MSDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or nullptr if not.
virtual int getRNGIndex() const =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 SUMOTime getWaitingTime(const bool accumulated=false) const =0
virtual SumoRNG * getRNG() const =0
Returns the associated RNG for this object.
virtual double getMaxSpeed() const =0
Returns the object's maximum speed (minimum of technical and desired maximum speed)
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 MSEdge * getRerouteDestination() const =0
Returns the end point for reroutes (usually the last edge of the route)
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 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 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 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.
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 or vias to use.
bool isVia
The edge probs are vias and not destinations.
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.