Eclipse SUMO - Simulation of Urban MObility
MSTriggeredRerouter.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Reroutes vehicles passing an edge
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <algorithm>
31 #include <utils/common/Command.h>
34 #include <utils/common/ToString.h>
41 #include <microsim/MSLane.h>
42 #include <microsim/MSVehicle.h>
43 #include <microsim/MSRoute.h>
44 #include <microsim/MSEdge.h>
46 #include <microsim/MSNet.h>
48 #include <microsim/MSGlobals.h>
49 #include <microsim/MSParkingArea.h>
53 #include "MSTriggeredRerouter.h"
54 
55 #include <mesosim/MELoop.h>
56 #include <mesosim/MESegment.h>
57 
58 //#define DEBUG_REROUTER
59 //#define DEBUG_PARKING
60 #define DEBUGCOND (veh.isSelected())
61 //#define DEBUGCOND (veh.getID() == "")
62 
63 // ===========================================================================
64 // static member defintion
65 // ===========================================================================
66 MSEdge MSTriggeredRerouter::mySpecialDest_keepDestination("MSTriggeredRerouter_keepDestination", -1, EDGEFUNC_UNKNOWN, "", "", -1, 0);
67 MSEdge MSTriggeredRerouter::mySpecialDest_terminateRoute("MSTriggeredRerouter_terminateRoute", -1, EDGEFUNC_UNKNOWN, "", "", -1, 0);
68 
69 // ===========================================================================
70 // method definitions
71 // ===========================================================================
73  const MSEdgeVector& edges,
74  double prob, const std::string& file, bool off,
75  SUMOTime timeThreshold,
76  const std::string& vTypes) :
77  MSTrigger(id),
78  MSMoveReminder(id),
79  SUMOSAXHandler(file),
80  myProbability(prob),
81  myUserProbability(prob),
82  myAmInUserMode(false),
83  myTimeThreshold(timeThreshold) {
84  // build actors
85  for (MSEdgeVector::const_iterator j = edges.begin(); j != edges.end(); ++j) {
88  s->addDetector(this);
89  continue;
90  }
91  const std::vector<MSLane*>& destLanes = (*j)->getLanes();
92  for (std::vector<MSLane*>::const_iterator i = destLanes.begin(); i != destLanes.end(); ++i) {
93  (*i)->addMoveReminder(this);
94  }
95  }
96  if (off) {
97  setUserMode(true);
99  }
100  const std::vector<std::string> vt = StringTokenizer(vTypes).getVector();
101  myVehicleTypes.insert(vt.begin(), vt.end());
102 }
103 
104 
106 }
107 
108 // ------------ loading begin
109 void
111  const SUMOSAXAttributes& attrs) {
112  if (element == SUMO_TAG_INTERVAL) {
113  bool ok = true;
116  }
117  if (element == SUMO_TAG_DEST_PROB_REROUTE) {
118  // by giving probabilities of new destinations
119  // get the destination edge
120  std::string dest = attrs.getStringSecure(SUMO_ATTR_ID, "");
121  if (dest == "") {
122  throw ProcessError("MSTriggeredRerouter " + getID() + ": No destination edge id given.");
123  }
124  MSEdge* to = MSEdge::dictionary(dest);
125  if (to == nullptr) {
126  if (dest == "keepDestination") {
128  } else if (dest == "terminateRoute") {
130  } else {
131  throw ProcessError("MSTriggeredRerouter " + getID() + ": Destination edge '" + dest + "' is not known.");
132  }
133  }
134  // get the probability to reroute
135  bool ok = true;
136  double prob = attrs.getOpt<double>(SUMO_ATTR_PROB, getID().c_str(), ok, 1.);
137  if (!ok) {
138  throw ProcessError();
139  }
140  if (prob < 0) {
141  throw ProcessError("MSTriggeredRerouter " + getID() + ": Attribute 'probability' for destination '" + dest + "' is negative (must not).");
142  }
143  // add
144  myCurrentEdgeProb.add(to, prob);
145  }
146 
147 
148  if (element == SUMO_TAG_CLOSING_REROUTE) {
149  // by closing
150  std::string closed_id = attrs.getStringSecure(SUMO_ATTR_ID, "");
151  MSEdge* closed = MSEdge::dictionary(closed_id);
152  if (closed == nullptr) {
153  throw ProcessError("MSTriggeredRerouter " + getID() + ": Edge '" + closed_id + "' to close is not known.");
154  }
155  myCurrentClosed.push_back(closed);
156  bool ok;
157  const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, getID().c_str(), ok, "", false);
158  const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, getID().c_str(), ok, "");
159  myCurrentPermissions = parseVehicleClasses(allow, disallow);
160  }
161 
162  if (element == SUMO_TAG_CLOSING_LANE_REROUTE) {
163  // by closing lane
164  std::string closed_id = attrs.getStringSecure(SUMO_ATTR_ID, "");
165  MSLane* closed = MSLane::dictionary(closed_id);
166  if (closed == nullptr) {
167  throw ProcessError("MSTriggeredRerouter " + getID() + ": Lane '" + closed_id + "' to close is not known.");
168  }
169  myCurrentClosedLanes.push_back(closed);
170  bool ok;
172  const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, getID().c_str(), ok, "", false);
173  const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, getID().c_str(), ok, "");
174  myCurrentPermissions = parseVehicleClasses(allow, disallow);
175  } else {
176  // lane closing only makes sense if the lane really receives reduced
177  // permissions
179  }
180  }
181 
182  if (element == SUMO_TAG_ROUTE_PROB_REROUTE) {
183  // by explicit rerouting using routes
184  // check if route exists
185  std::string routeStr = attrs.getStringSecure(SUMO_ATTR_ID, "");
186  if (routeStr == "") {
187  throw ProcessError("MSTriggeredRerouter " + getID() + ": No route id given.");
188  }
189  const MSRoute* route = MSRoute::dictionary(routeStr);
190  if (route == nullptr) {
191  throw ProcessError("MSTriggeredRerouter " + getID() + ": Route '" + routeStr + "' does not exist.");
192  }
193 
194  // get the probability to reroute
195  bool ok = true;
196  double prob = attrs.getOpt<double>(SUMO_ATTR_PROB, getID().c_str(), ok, 1.);
197  if (!ok) {
198  throw ProcessError();
199  }
200  if (prob < 0) {
201  throw ProcessError("MSTriggeredRerouter " + getID() + ": Attribute 'probability' for route '" + routeStr + "' is negative (must not).");
202  }
203  // add
204  myCurrentRouteProb.add(route, prob);
205  }
206 
207  if (element == SUMO_TAG_PARKING_ZONE_REROUTE) {
208  // by giving probabilities of new destinations
209  // get the destination edge
210  std::string parkingarea = attrs.getStringSecure(SUMO_ATTR_ID, "");
211  if (parkingarea == "") {
212  throw ProcessError("MSTriggeredRerouter " + getID() + ": No parking area id given.");
213  }
215  if (pa == nullptr) {
216  throw ProcessError("MSTriggeredRerouter " + getID() + ": Parking area '" + parkingarea + "' is not known.");
217  }
218  // get the probability to reroute
219  bool ok = true;
220  const double prob = attrs.getOpt<double>(SUMO_ATTR_PROB, getID().c_str(), ok, 1.);
221  if (!ok) {
222  throw ProcessError();
223  }
224  if (prob < 0) {
225  throw ProcessError("MSTriggeredRerouter " + getID() + ": Attribute 'probability' for destination '" + parkingarea + "' is negative (must not).");
226  }
227  const bool visible = attrs.getOpt<bool>(SUMO_ATTR_VISIBLE, getID().c_str(), ok, false);
228  // add
229  myCurrentParkProb.add(std::make_pair(pa, visible), prob);
230  //MSEdge* to = &(pa->getLane().getEdge());
231  //myCurrentEdgeProb.add(prob, to);
232  }
233 }
234 
235 
236 void
238  if (element == SUMO_TAG_INTERVAL) {
239  RerouteInterval ri;
242  ri.closed = myCurrentClosed;
248  for (auto paVi : ri.parkProbs.getVals()) {
249  paVi.first->setNumAlternatives((int)ri.parkProbs.getVals().size() - 1);
250  }
251  if (ri.closedLanes.size() > 0) {
252  // collect edges that are affect by a closed lane
253  std::set<MSEdge*> affected;
254  for (const MSLane* const l : ri.closedLanes) {
255  affected.insert(&l->getEdge());
256  }
257  ri.closedLanesAffected.insert(ri.closedLanesAffected.begin(), affected.begin(), affected.end());
258  }
259  myCurrentClosed.clear();
260  myCurrentClosedLanes.clear();
264  myIntervals.push_back(ri);
265  myIntervals.back().id = (long long)&myIntervals.back();
266  if (!(ri.closed.empty() && ri.closedLanes.empty()) && ri.permissions != SVCAll) {
269  }
270  }
271 }
272 
273 
274 // ------------ loading end
275 
276 
277 SUMOTime
279  for (std::vector<RerouteInterval>::iterator i = myIntervals.begin(); i != myIntervals.end(); ++i) {
280  if (i->begin == currentTime && !(i->closed.empty() && i->closedLanes.empty()) && i->permissions != SVCAll) {
281  for (MSEdgeVector::iterator e = i->closed.begin(); e != i->closed.end(); ++e) {
282  for (std::vector<MSLane*>::const_iterator l = (*e)->getLanes().begin(); l != (*e)->getLanes().end(); ++l) {
283  //std::cout << SIMTIME << " closing: intervalID=" << i->id << " lane=" << (*l)->getID() << " prevPerm=" << getVehicleClassNames((*l)->getPermissions()) << " new=" << getVehicleClassNames(i->permissions) << "\n";
284  (*l)->setPermissions(i->permissions, i->id);
285  }
286  (*e)->rebuildAllowedLanes();
287  }
288  for (std::vector<MSLane*>::iterator l = i->closedLanes.begin(); l != i->closedLanes.end(); ++l) {
289  (*l)->setPermissions(i->permissions, i->id);
290  (*l)->getEdge().rebuildAllowedLanes();
291  }
294  }
295  if (i->end == currentTime && !(i->closed.empty() && i->closedLanes.empty()) && i->permissions != SVCAll) {
296  for (MSEdgeVector::iterator e = i->closed.begin(); e != i->closed.end(); ++e) {
297  for (std::vector<MSLane*>::const_iterator l = (*e)->getLanes().begin(); l != (*e)->getLanes().end(); ++l) {
298  (*l)->resetPermissions(i->id);
299  //std::cout << SIMTIME << " opening: intervalID=" << i->id << " lane=" << (*l)->getID() << " restore prevPerm=" << getVehicleClassNames((*l)->getPermissions()) << "\n";
300  }
301  (*e)->rebuildAllowedLanes();
302  }
303  for (std::vector<MSLane*>::iterator l = i->closedLanes.begin(); l != i->closedLanes.end(); ++l) {
304  (*l)->resetPermissions(i->id);
305  (*l)->getEdge().rebuildAllowedLanes();
306  }
307  }
308  }
309  return 0;
310 }
311 
312 
315  for (std::vector<RerouteInterval>::const_iterator i = myIntervals.begin(); i != myIntervals.end(); ++i) {
316  if (i->begin <= time && i->end > time) {
317  if (
318  // destProbReroute
319  i->edgeProbs.getOverallProb() > 0 ||
320  // routeProbReroute
321  i->routeProbs.getOverallProb() > 0 ||
322  // parkingZoneReroute
323  i->parkProbs.getOverallProb() > 0 ||
324  // affected by closingReroute
325  veh.getRoute().containsAnyOf(i->closed) ||
326  // affected by closingLaneReroute
327  veh.getRoute().containsAnyOf(i->closedLanesAffected)) {
328  return &*i;
329  }
330  }
331  }
332  return nullptr;
333 }
334 
335 
338  for (std::vector<RerouteInterval>::const_iterator i = myIntervals.begin(); i != myIntervals.end(); ++i) {
339  if (i->begin <= time && i->end > time) {
340  if (i->parkProbs.getOverallProb() != 0 || i->edgeProbs.getOverallProb() != 0 || i->routeProbs.getOverallProb() != 0 || !i->closed.empty()) {
341  return &*i;
342  }
343  }
344  }
345  return nullptr;
346 }
347 
348 
349 bool
351  double /*newPos*/, double /*newSpeed*/) {
352  return notifyEnter(veh, NOTIFICATION_JUNCTION);
353 }
354 
355 
356 bool
358  MSMoveReminder::Notification reason, const MSLane* /* enteredLane */) {
359  return reason == NOTIFICATION_LANE_CHANGE;
360 }
361 
362 
363 bool
365  if (!tObject.isVehicle()) {
366  return false;
367  }
368  SUMOVehicle& veh = static_cast<SUMOVehicle&>(tObject);
369  if (!vehicleApplies(veh)) {
370  return false;
371  }
372  // check whether the vehicle shall be rerouted
374  const MSTriggeredRerouter::RerouteInterval* rerouteDef = getCurrentReroute(time, veh);
375  if (rerouteDef == nullptr) {
376  return true; // an active interval could appear later
377  }
379  if (RandHelper::rand() > prob) {
380  return false; // XXX another interval could appear later but we would have to track whether the current interval was already tried
381  }
383  return true; // waiting time may be reached later
384  }
385  // if we have a closingLaneReroute, only vehicles with a rerouting device can profit from rerouting (otherwise, edge weights will not reflect local jamming)
386  const bool hasReroutingDevice = veh.getDevice(typeid(MSDevice_Routing)) != nullptr;
387  if (rerouteDef->closedLanes.size() > 0 && !hasReroutingDevice) {
388  return true; // an active interval could appear later
389  }
390  // get vehicle params
391  const MSRoute& route = veh.getRoute();
392  const MSEdge* lastEdge = route.getLastEdge();
393 #ifdef DEBUG_REROUTER
394  if (DEBUGCOND) {
395  std::cout << SIMTIME << " veh=" << veh.getID() << " check rerouter " << getID() << " lane=" << veh.getLane()->getID() << " edge=" << veh.getEdge()->getID() << " finalEdge=" << lastEdge->getID() << " arrivalPos=" << veh.getArrivalPos() << "\n";
396  }
397 #endif
398 
399  if (rerouteDef->parkProbs.getOverallProb() > 0) {
400  bool newDestination = false;
401  ConstMSEdgeVector newRoute;
402  MSParkingArea* newParkingArea = rerouteParkingArea(rerouteDef, veh, newDestination, newRoute);
403  if (newParkingArea != nullptr) {
404  // adapt plans of any riders
405  for (MSTransportable* p : veh.getPersons()) {
406  p->rerouteParkingArea(veh.getNextParkingArea(), newParkingArea);
407  }
408 
409  if (newDestination) {
410  // update arrival parameters
411  SUMOVehicleParameter* newParameter = new SUMOVehicleParameter();
412  *newParameter = veh.getParameter();
413  newParameter->arrivalPosProcedure = ARRIVAL_POS_GIVEN;
414  newParameter->arrivalPos = newParkingArea->getEndLanePosition();
415  veh.replaceParameter(newParameter);
416  }
417 
418  SUMOAbstractRouter<MSEdge, SUMOVehicle>& router = hasReroutingDevice
419  ? MSRoutingEngine::getRouterTT(rerouteDef->closed)
420  : MSNet::getInstance()->getRouterTT(rerouteDef->closed);
421  const double routeCost = router.recomputeCosts(newRoute, &veh, MSNet::getInstance()->getCurrentTimeStep());
422  ConstMSEdgeVector prevEdges(veh.getCurrentRouteEdge(), veh.getRoute().end());
423  const double previousCost = router.recomputeCosts(prevEdges, &veh, MSNet::getInstance()->getCurrentTimeStep());
424  const double savings = previousCost - routeCost;
425  //if (getID() == "ego") std::cout << SIMTIME << " pCost=" << previousCost << " cost=" << routeCost
426  // << " prevEdges=" << toString(prevEdges)
427  // << " newEdges=" << toString(edges)
428  // << "\n";
429 
430  std::string errorMsg;
431  if (veh.replaceParkingArea(newParkingArea, errorMsg)) {
432  veh.replaceRouteEdges(newRoute, routeCost, savings, getID() + ":" + toString(SUMO_TAG_PARKING_ZONE_REROUTE), false, false, false);
433  } else {
434  WRITE_WARNING("Vehicle '" + veh.getID() + "' at rerouter '" + getID()
435  + "' could not reroute to new parkingArea '" + newParkingArea->getID()
436  + "' reason=" + errorMsg + ", time=" + time2string(MSNet::getInstance()->getCurrentTimeStep()) + ".");
437  }
438  }
439  return false;
440  }
441 
442  // get rerouting params
443  const MSRoute* newRoute = rerouteDef->routeProbs.getOverallProb() > 0 ? rerouteDef->routeProbs.get() : 0;
444  // we will use the route if given rather than calling our own dijsktra...
445  if (newRoute != nullptr) {
446 #ifdef DEBUG_REROUTER
447  if (DEBUGCOND) {
448  std::cout << " replacedRoute from routeDist " << newRoute->getID() << "\n";
449  }
450 #endif
451  veh.replaceRoute(newRoute, getID());
452  return false; // XXX another interval could appear later but we would have to track whether the currenty interval was already used
453  }
454  const MSEdge* newEdge = lastEdge;
455  // ok, try using a new destination
456  double newArrivalPos = -1;
457  const bool destUnreachable = std::find(rerouteDef->closed.begin(), rerouteDef->closed.end(), lastEdge) != rerouteDef->closed.end();
458  bool keepDestination = false;
459  // if we have a closingReroute, only assign new destinations to vehicles which cannot reach their original destination
460  // if we have a closingLaneReroute, no new destinations should be assigned
461  if (rerouteDef->closed.size() == 0 || destUnreachable) {
462  newEdge = rerouteDef->edgeProbs.getOverallProb() > 0 ? rerouteDef->edgeProbs.get() : route.getLastEdge();
463  if (newEdge == &mySpecialDest_terminateRoute) {
464  keepDestination = true;
465  newEdge = veh.getEdge();
466  newArrivalPos = veh.getPositionOnLane(); // instant arrival
467  } else if (newEdge == &mySpecialDest_keepDestination || newEdge == lastEdge) {
468  if (destUnreachable && rerouteDef->permissions == SVCAll) {
469  // if permissions aren't set vehicles will simply drive through
470  // the closing unless terminated. If the permissions are specified, assume that the user wants
471  // vehicles to stand and wait until the closing ends
472  WRITE_WARNING("Cannot keep destination edge '" + lastEdge->getID() + "' for vehicle '" + veh.getID() + "' due to closed edges. Terminating route.");
473  newEdge = veh.getEdge();
474  } else {
475  newEdge = lastEdge;
476  }
477  } else if (newEdge == nullptr) {
478 #ifdef DEBUG_REROUTER
479  if (DEBUGCOND) {
480  std::cout << " could not find new edge!\n";
481  }
482 #endif
483  assert(false); // this should never happen
484  newEdge = veh.getEdge();
485  }
486  }
487  // we have a new destination, let's replace the vehicle route (if it is affected)
488  if (rerouteDef->closed.size() == 0 || destUnreachable || veh.getRoute().containsAnyOf(rerouteDef->closed)) {
489  ConstMSEdgeVector edges;
490  SUMOAbstractRouter<MSEdge, SUMOVehicle>& router = hasReroutingDevice
491  ? MSRoutingEngine::getRouterTT(rerouteDef->closed)
492  : MSNet::getInstance()->getRouterTT(rerouteDef->closed);
493  router.compute(
494  veh.getEdge(), newEdge, &veh, MSNet::getInstance()->getCurrentTimeStep(), edges);
495  if (edges.size() == 0 && !keepDestination && rerouteDef->edgeProbs.getOverallProb() > 0) {
496  // destination unreachable due to closed intermediate edges. pick among alternative targets
497  RandomDistributor<MSEdge*> edgeProbs2 = rerouteDef->edgeProbs;
498  edgeProbs2.remove(const_cast<MSEdge*>(newEdge));
499  while (edges.size() == 0 && edgeProbs2.getVals().size() > 0) {
500  newEdge = edgeProbs2.get();
501  edgeProbs2.remove(const_cast<MSEdge*>(newEdge));
502  if (newEdge == &mySpecialDest_terminateRoute) {
503  newEdge = veh.getEdge();
504  newArrivalPos = veh.getPositionOnLane(); // instant arrival
505  }
506  if (newEdge == &mySpecialDest_keepDestination && rerouteDef->permissions != SVCAll) {
507  newEdge = lastEdge;
508  break;
509  }
510  router.compute(
511  veh.getEdge(), newEdge, &veh, MSNet::getInstance()->getCurrentTimeStep(), edges);
512  }
513 
514  }
515  const double routeCost = router.recomputeCosts(edges, &veh, MSNet::getInstance()->getCurrentTimeStep());
516  const bool useNewRoute = veh.replaceRouteEdges(edges, routeCost, 0, getID());
517 #ifdef DEBUG_REROUTER
518  if (DEBUGCOND) std::cout << " rerouting: newDest=" << newEdge->getID()
519  << " newEdges=" << toString(edges)
520  << " useNewRoute=" << useNewRoute << " newArrivalPos=" << newArrivalPos << " numClosed=" << rerouteDef->closed.size()
521  << " destUnreachable=" << destUnreachable << " containsClosed=" << veh.getRoute().containsAnyOf(rerouteDef->closed) << "\n";
522 #endif
523  if (useNewRoute && newArrivalPos != -1) {
524  // must be called here because replaceRouteEdges may also set the arrivalPos
525  veh.setArrivalPos(newArrivalPos);
526  }
527  }
528  return false; // XXX another interval could appear later but we would have to track whether the currenty interval was already used
529 }
530 
531 
532 void
534  myAmInUserMode = val;
535 }
536 
537 
538 void
540  myUserProbability = prob;
541 }
542 
543 
544 bool
546  return myAmInUserMode;
547 }
548 
549 
550 double
553 }
554 
555 
556 double
558  return myUserProbability;
559 }
560 
561 
562 double
563 MSTriggeredRerouter::getWeight(SUMOVehicle& veh, const std::string param, const double defaultWeight) const {
564  // get custom vehicle parameter
565  if (veh.getParameter().knowsParameter(param)) {
566  try {
567  return StringUtils::toDouble(veh.getParameter().getParameter(param, "-1"));
568  } catch (...) {
569  WRITE_WARNING("Invalid value '" + veh.getParameter().getParameter(param, "-1") + "' for vehicle parameter '" + param + "'");
570  }
571  } else {
572  // get custom vType parameter
573  if (veh.getVehicleType().getParameter().knowsParameter(param)) {
574  try {
575  return StringUtils::toDouble(veh.getVehicleType().getParameter().getParameter(param, "-1"));
576  } catch (...) {
577  WRITE_WARNING("Invalid value '" + veh.getVehicleType().getParameter().getParameter(param, "-1") + "' for vType parameter '" + param + "'");
578  }
579  }
580  }
581  //WRITE_MESSAGE("Vehicle '" +veh.getID() + "' does not supply vehicle parameter '" + param + "'. Using default of " + toString(defaultWeight) + "\n";
582  return defaultWeight;
583 }
584 
585 
588  SUMOVehicle& veh, bool& newDestination, ConstMSEdgeVector& newRoute) const {
589  // reroute destination from initial parking area to the near parking area
590  // if the next stop is a parking area, it is included in the current
591  // alternative set and if it can be observed to be full
592 
593  MSParkingArea* nearParkArea = nullptr;
594  std::vector<ParkingAreaVisible> parks = rerouteDef->parkProbs.getVals();
595 
596  // get vehicle params
597  MSParkingArea* destParkArea = veh.getNextParkingArea();
598  const MSRoute& route = veh.getRoute();
599 
600  if (destParkArea == nullptr) {
601  // not driving towards a parkingArea
602  return nullptr;
603  }
604 
605  bool destVisible = false;
606  for (auto paVis : parks) {
607  if (paVis.first == destParkArea
608  && (paVis.second
609  // if the vehicle is on the destParkArea edge it is always visible
610  || &(destParkArea->getLane().getEdge()) == veh.getEdge())) {
611  destVisible = true;
612  break;
613  }
614  }
615  if (!destVisible) {
616  // cannot determine destination occupancy
617  return nullptr;
618  }
619  if (destParkArea->getOccupancy() == destParkArea->getCapacity()) {
620  // if the current route ends at the parking area, the new route will
621  // also and at the new area
622  newDestination = (&destParkArea->getLane().getEdge() == route.getLastEdge()
623  && veh.getArrivalPos() >= destParkArea->getBeginLanePosition()
624  && veh.getArrivalPos() <= destParkArea->getEndLanePosition());
625 
626 #ifdef DEBUG_PARKING
627  if (DEBUGCOND) {
628  std::cout << SIMTIME << " veh=" << veh.getID()
629  << " rerouteParkingArea dest=" << destParkArea->getID()
630  << " onDestEdge=" << (&(destParkArea->getLane().getEdge()) == veh.getEdge())
631  << " newDest=" << newDestination
632  << "\n";
633  }
634 #endif
635 
636  typedef std::map<std::string, double> ParkingParamMap_t;
637  typedef std::map<MSParkingArea*, ParkingParamMap_t> MSParkingAreaMap_t;
638 
639  ParkingParamMap_t weights;
640  std::map<MSParkingArea*, ConstMSEdgeVector> newRoutes;
641 
642  // The probability of choosing this area inside the zone
643  weights["probability"] = getWeight(veh, "parking.probability.weight", 0.0);
644 
645  // The capacity of this area
646  weights["capacity"] = getWeight(veh, "parking.capacity.weight", 0.0);
647 
648  // The absolute number of free spaces
649  weights["absfreespace"] = getWeight(veh, "parking.absfreespace.weight", 0.0);
650 
651  // The relative number of free spaces
652  weights["relfreespace"] = getWeight(veh, "parking.relfreespace.weight", 0.0);
653 
654  // The distance to the new parking area
655  weights["distanceto"] = getWeight(veh, "parking.distanceto.weight", getWeight(veh, "parking.distance.weight", 1.0));
656 
657  // The time to reach this area
658  weights["timeto"] = getWeight(veh, "parking.timeto.weight", 0.0);
659 
660  // The distance from the new parking area
661  weights["distancefrom"] = getWeight(veh, "parking.distancefrom.weight", 0.0);
662 
663  // The time to reach the end from this area
664  weights["timefrom"] = getWeight(veh, "parking.timefrom.weight", 0.0);
665 
666  // a map stores maximum values to normalize parking values
667  ParkingParamMap_t maxValues;
668 
669  maxValues["probability"] = 0.0;
670  maxValues["capacity"] = 0.0;
671  maxValues["absfreespace"] = 0.0;
672  maxValues["relfreespace"] = 0.0;
673  maxValues["distanceto"] = 0.0;
674  maxValues["timeto"] = 0.0;
675  maxValues["distancefrom"] = 0.0;
676  maxValues["timefrom"] = 0.0;
677 
678  // a map stores elegible parking areas
679  MSParkingAreaMap_t parkAreas;
680 
682 
683  const std::vector<double>& probs = rerouteDef->parkProbs.getProbs();
684 
685  const double brakeGap = veh.getBrakeGap();
686 
687  for (int i = 0; i < (int)parks.size(); ++i) {
688  MSParkingArea* pa = parks[i].first;
689  const double prob = probs[i];
690  // alternative occupancy is randomized (but never full) if invisible
691  // current destination must be visible at this point
692  int paOccupancy = parks[i].second || pa == destParkArea ? pa->getOccupancy() : RandHelper::rand(pa->getCapacity());
693  if (paOccupancy < pa->getCapacity()) {
694 
695  // a map stores the parking values
696  ParkingParamMap_t parkValues;
697 
698  const RGBColor& c = route.getColor();
699  const MSEdge* parkEdge = &(pa->getLane().getEdge());
700 
701  const bool includeInternalLengths = MSGlobals::gUsingInternalLanes && MSNet::getInstance()->hasInternalLinks();
702 
703  // Compute the route from the current edge to the parking area edge
704  ConstMSEdgeVector edgesToPark;
705  router.compute(veh.getEdge(), parkEdge, &veh, MSNet::getInstance()->getCurrentTimeStep(), edgesToPark);
706 
707  if (edgesToPark.size() > 0) {
708  // Compute the route from the parking area edge to the end of the route
709  ConstMSEdgeVector edgesFromPark;
710 
711  const MSEdge* nextDestination = route.getLastEdge();
712  double nextPos = veh.getArrivalPos();
713  int nextDestinationIndex = route.size() - 1;
714  if (!newDestination) {
715  std::vector<std::pair<int, double> > stopIndices = veh.getStopIndices();
716  if (stopIndices.size() > 1) {
717  nextDestinationIndex = stopIndices[1].first;
718  nextDestination = route.getEdges()[nextDestinationIndex];
719  nextPos = stopIndices[1].second;
720 
721  }
722  if (parkEdge == nextDestination && nextPos < pa->getEndLanePosition()) {
723  router.computeLooped(parkEdge, nextDestination, &veh, MSNet::getInstance()->getCurrentTimeStep(), edgesFromPark);
724  } else {
725  router.compute(parkEdge, nextDestination, &veh, MSNet::getInstance()->getCurrentTimeStep(), edgesFromPark);
726  }
727  }
728 
729  if (edgesFromPark.size() > 0 || newDestination) {
730 
731  parkValues["probability"] = prob;
732 
733  if (parkValues["probability"] > maxValues["probability"]) {
734  maxValues["probability"] = parkValues["probability"];
735  }
736 
737  parkValues["capacity"] = (double)(pa->getCapacity());
738  parkValues["absfreespace"] = (double)(pa->getCapacity() - paOccupancy);
739  parkValues["relfreespace"] = parkValues["absfreespace"] / parkValues["capacity"];
740 
741  if (parkValues["capacity"] > maxValues["capacity"]) {
742  maxValues["capacity"] = parkValues["capacity"];
743  }
744 
745  if (parkValues["absfreespace"] > maxValues["absfreespace"]) {
746  maxValues["absfreespace"] = parkValues["absfreespace"];
747  }
748 
749  if (parkValues["relfreespace"] > maxValues["relfreespace"]) {
750  maxValues["relfreespace"] = parkValues["relfreespace"];
751  }
752 
753  MSRoute routeToPark(route.getID() + "!topark#1", edgesToPark, false, &c == &RGBColor::DEFAULT_COLOR ? nullptr : new RGBColor(c), route.getStops());
754 
755  // The distance from the current edge to the new parking area
756  parkValues["distanceto"] = routeToPark.getDistanceBetween(veh.getPositionOnLane(), pa->getBeginLanePosition(),
757  routeToPark.begin(), routeToPark.end() - 1, includeInternalLengths);
758 
759  //std::cout << SIMTIME << " veh=" << veh.getID() << " candidate=" << pa->getID()
760  // << " distanceTo=" << parkValues["distanceto"]
761  // << " brakeGap=" << brakeGap
762  // << " routeToPark=" << toString(edgesToPark)
763  // << " fromPos=" << veh.getPositionOnLane()
764  // << " tPos=" << pa->getBeginLanePosition()
765  // << "\n";
766  if (parkValues["distanceto"] < brakeGap) {
767  //std::cout << " removed: pa too close\n";
768  // to close to stop for this parkingArea
769  continue;
770  }
771 
772  // The time to reach the new parking area
773  parkValues["timeto"] = router.recomputeCosts(edgesToPark, &veh, MSNet::getInstance()->getCurrentTimeStep());
774 
775  if (parkValues["distanceto"] > maxValues["distanceto"]) {
776  maxValues["distanceto"] = parkValues["distanceto"];
777  }
778 
779  if (parkValues["timeto"] > maxValues["timeto"]) {
780  maxValues["timeto"] = parkValues["timeto"];
781  }
782 
783  ConstMSEdgeVector newEdges = edgesToPark;
784 
785  if (newDestination) {
786  parkValues["distancefrom"] = 0;
787  parkValues["timefrom"] = 0;
788  } else {
789  MSRoute routeFromPark(route.getID() + "!frompark#1", edgesFromPark, false,
790  &c == &RGBColor::DEFAULT_COLOR ? nullptr : new RGBColor(c), route.getStops());
791  // The distance from the new parking area to the end of the route
792  parkValues["distancefrom"] = routeFromPark.getDistanceBetween(pa->getBeginLanePosition(), routeFromPark.getLastEdge()->getLength(),
793  routeFromPark.begin(), routeFromPark.end() - 1, includeInternalLengths);
794  // The time to reach this area
795  parkValues["timefrom"] = router.recomputeCosts(edgesFromPark, &veh, MSNet::getInstance()->getCurrentTimeStep());
796  newEdges.insert(newEdges.end(), edgesFromPark.begin() + 1, edgesFromPark.end());
797  newEdges.insert(newEdges.end(), route.begin() + nextDestinationIndex + 1, route.end());
798  }
799 
800  if (parkValues["distancefrom"] > maxValues["distancefrom"]) {
801  maxValues["distancefrom"] = parkValues["distancefrom"];
802  }
803 
804  if (parkValues["timefrom"] > maxValues["timefrom"]) {
805  maxValues["timefrom"] = parkValues["timefrom"];
806  }
807 
808  parkAreas[pa] = parkValues;
809  newRoutes[pa] = newEdges;
810 
811 #ifdef DEBUG_PARKING
812  if (DEBUGCOND) {
813  std::cout << " altPA=" << pa->getID()
814  << " vals=" << joinToString(parkValues, " ", ":")
815  << "\n";
816  }
817 #endif
818  }
819  }
820  }
821  }
822 
823 #ifdef DEBUG_PARKING
824  if (DEBUGCOND) {
825  std::cout << " maxValues=" << joinToString(maxValues, " ", ":") << "\n";
826  }
827 #endif
828 
829  // minimum cost to get the parking area
830  double minParkingCost = 0.0;
831 
832  for (MSParkingAreaMap_t::iterator it = parkAreas.begin(); it != parkAreas.end(); ++it) {
833  // get the parking values
834  ParkingParamMap_t parkValues = it->second;
835 
836  // normalizing parking values with maximum values (we want to maximize some parameters then we reverse the value)
837  parkValues["probability"] = maxValues["probability"] > 0.0 ? 1.0 - parkValues["probability"] / maxValues["probability"] : 0.0;
838  parkValues["capacity"] = maxValues["capacity"] > 0.0 ? 1.0 - parkValues["capacity"] / maxValues["capacity"] : 0.0;
839  parkValues["absfreespace"] = maxValues["absfreespace"] > 0.0 ? 1.0 - parkValues["absfreespace"] / maxValues["absfreespace"] : 0.0;
840  parkValues["relfreespace"] = maxValues["relfreespace"] > 0.0 ? 1.0 - parkValues["relfreespace"] / maxValues["relfreespace"] : 0.0;
841 
842  parkValues["distanceto"] = maxValues["distanceto"] > 0.0 ? parkValues["distanceto"] / maxValues["distanceto"] : 0.0;
843  parkValues["timeto"] = maxValues["timeto"] > 0.0 ? parkValues["timeto"] / maxValues["timeto"] : 0.0;
844 
845  parkValues["distancefrom"] = maxValues["distancefrom"] > 0.0 ? parkValues["distancefrom"] / maxValues["distancefrom"] : 0.0;
846  parkValues["timefrom"] = maxValues["timefrom"] > 0.0 ? parkValues["timefrom"] / maxValues["timefrom"] : 0.0;
847 
848  // get the parking area cost
849  double parkingCost = 0.0;
850 
851  // sum every index with its weight
852  for (ParkingParamMap_t::iterator pc = parkValues.begin(); pc != parkValues.end(); ++pc) {
853  parkingCost += weights[pc->first] * pc->second;
854  }
855 
856  // get the parking area with minimum cost
857  if (nearParkArea == nullptr || parkingCost < minParkingCost) {
858  minParkingCost = parkingCost;
859  nearParkArea = it->first;
860  newRoute = newRoutes[nearParkArea];
861  }
862 
863 #ifdef DEBUG_PARKING
864  if (DEBUGCOND) {
865  std::cout << " altPA=" << it->first->getID() << " score=" << parkingCost << "\n";
866  }
867 #endif
868  }
869  }
870 
871 #ifdef DEBUG_PARKING
872  if (DEBUGCOND) {
873  std::cout << " parkingResult=" << Named::getIDSecure(nearParkArea) << "\n";
874  }
875 #endif
876 
877  return nearParkArea;
878 }
879 
880 
881 bool
883  if (myVehicleTypes.empty() || myVehicleTypes.count(veh.getVehicleType().getOriginalID()) > 0) {
884  return true;
885  } else {
887  for (auto vTypeDist : vTypeDists) {
888  if (myVehicleTypes.count(vTypeDist) > 0) {
889  return true;
890  }
891  }
892  return false;
893  }
894 }
895 
896 
897 /****************************************************************************/
898 
#define DEBUGCOND
A lane area vehicles can halt at.
Definition: MSParkingArea.h:59
double getProbability() const
Returns the rerouting probability.
MSEdgeVector closed
The list of closed edges.
const RerouteInterval * getCurrentReroute(SUMOTime time, SUMOVehicle &veh) const
Returns the rerouting definition valid for the given time and vehicle, 0 if none. ...
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:670
const std::string & getOriginalID() const
Returns the id of the original vehicle type if this is a vehicle specific type, the id otherwise...
long long int SUMOTime
Definition: SUMOTime.h:35
virtual double getArrivalPos() const =0
Returns this vehicle&#39;s desired arrivalPos for its current route (may change on reroute) ...
double getBeginLanePosition() const
Returns the begin position of this stop.
double getUserProbability() const
Returns the rerouting probability given by the user.
virtual MSParkingArea * getNextParkingArea()=0
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:121
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:293
virtual const std::vector< MSTransportable * > & getPersons() const =0
retrieve riding persons
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:899
virtual MSVehicleDevice * getDevice(const std::type_info &type) const =0
Returns a device of the given type if it exists or 0.
virtual const MSRoute & getRoute() const =0
Returns the current route.
Represents a generic random distribution.
SUMOTime setPermissions(const SUMOTime currentTime)
Sets the edge permission if there are any defined in the closingEdge.
SVCPermissions myCurrentPermissions
List of permissions for closed edges.
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations to use.
The vehicle arrived at a junction.
lane of a reroute of type closing
SUMOTime myCurrentIntervalBegin
The first and the last time steps of the interval.
std::vector< MSLane * > myCurrentClosedLanes
List of closed lanes.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
virtual bool isVehicle() const =0
Get the vehicle&#39;s ID.
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
A device that performs vehicle rerouting based on current edge speeds.
const std::set< std::string > getVTypeDistributionMembership(const std::string &id) const
Return the distribution IDs the vehicle type is a member of.
virtual MSLane * getLane() const =0
Returns the lane the vehicle is on.
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:366
weights: time range begin
virtual double getBrakeGap() const =0
get distance for coming to a stop (used for rerouting checks)
virtual bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)=0
Replaces the current route by the given one.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
T MAX2(T a, T b)
Definition: StdDefs.h:80
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, double prob, const std::string &file, bool off, SUMOTime timeThreshold, const std::string &vTypes)
Constructor.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition: Named.h:70
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:804
const std::vector< T > & getVals() const
Returns the members of the distribution.
const MSEdge * getLastEdge() const
returns the destination edge
Definition: MSRoute.cpp:88
void setUserUsageProbability(double prob)
Sets the probability with which a vehicle is rerouted given by the user.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:73
const std::string & getID() const
Returns the id.
Definition: Named.h:77
The arrival position is given.
const SVCPermissions SVCAll
all VClasses are allowed
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
SAX-handler base for SUMO-files.
int size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:82
std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
double myProbability
The probability and the user-given probability.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:239
#define SIMTIME
Definition: SUMOTime.h:64
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes the reminder.
bool remove(T val)
Removes a value with an assigned probability from the distribution.
authorities vehicles
RandomDistributor< ParkingAreaVisible > myCurrentParkProb
new destinations with probabilities
A road/street connecting two junctions.
Definition: MSEdge.h:76
virtual void myEndElement(int element)
Called when a closing tag occurs.
double getEndLanePosition() const
Returns the end position of this stop.
The vehicle changes lanes (micro only)
MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute) const
virtual void replaceParameter(const SUMOVehicleParameter *newParameter)=0
Replaces the vehicle&#39;s parameter.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)=0
Replaces the current route by the given edges.
An abstract device that changes the state of the micro simulation.
Definition: MSTrigger.h:41
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
double getWeight(SUMOVehicle &veh, const std::string param, const double defaultWeight) const
Representation of a vehicle.
Definition: SUMOVehicle.h:61
Encapsulated SAX-Attributes.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:204
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:337
virtual ~MSTriggeredRerouter()
Destructor.
SUMOTime begin
The begin time these definitions are valid.
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:430
A wrapper for a Command function.
int getCapacity() const
Returns the area capacity.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
virtual SUMOTime getAccumulatedWaitingTime() const =0
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:284
RandomDistributor< const MSRoute * > myCurrentRouteProb
new routes with probabilities
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...
static MSEdge mySpecialDest_keepDestination
special destination values
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
Definition: MESegment.cpp:212
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Tries to reroute the vehicle.
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:642
probability of route of a reroute
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:69
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
probability of destiny of a reroute
Something on a lane to be noticed about vehicle movement.
static MSEdge mySpecialDest_terminateRoute
bool computeLooped(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into, bool silent=false)
Builds the route between the given edges using the minimum effort at the given time if from == to...
const SUMOVTypeParameter & getParameter() const
int getOccupancy() const
Returns the area occupancy.
double arrivalPos
(optional) The position the vehicle shall arrive on
RandomDistributor< MSEdge * > myCurrentEdgeProb
new destinations with probabilities
std::vector< std::string > getVector()
return vector of strings
reroute of type closing
void clear()
Clears the distribution.
entry for an alternative parking zone
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1855
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.
Structure representing possible vehicle parameter.
Representation of a vehicle or person.
SUMOTime end
The end time these definitions are valid.
#define SUMOTime_MAX
Definition: SUMOTime.h:36
bool containsAnyOf(const MSEdgeVector &edgelist) const
Definition: MSRoute.cpp:239
std::vector< MSLane * > closedLanes
The list of closed lanes.
RandomDistributor< const MSRoute * > routeProbs
The distributions of new routes to use.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
weights: time range end
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.
A single mesoscopic segment (cell)
Definition: MESegment.h:50
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
bool inUserMode() const
Returns whether the user is setting the rerouting probability.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
MSEdgeVector myCurrentClosed
List of closed edges.
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:106
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
an aggreagated-output interval
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
virtual bool replaceParkingArea(MSParkingArea *parkingArea, std::string &errorMsg)=0
Replaces a stop.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:70
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:954
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:72
const MSLane & getLane() const
Returns the lane this stop is located at.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
SVCPermissions permissions
The permissions to use.
RandomDistributor< ParkingAreaVisible > parkProbs
The distributions of new parking areas to use as destinations.
static bool gUseMesoSim
Definition: MSGlobals.h:91
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
Definition: MSRoute.cpp:375
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:76
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:247
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...
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
MSEdgeVector closedLanesAffected
The list of edges that are affect by closed lanes.
virtual SUMOTime getWaitingTime() const =0
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:114
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...
Definition: MSRoute.cpp:277