Eclipse SUMO - Simulation of Urban MObility
MSRoutingEngine.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2007-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
22 // A device that performs vehicle rerouting based on current edge speeds
23 /****************************************************************************/
24 #include <config.h>
25 
26 #include "MSRoutingEngine.h"
27 #include <microsim/MSNet.h>
28 #include <microsim/MSLane.h>
29 #include <microsim/MSEdge.h>
30 #include <microsim/MSEdgeControl.h>
32 #include <microsim/MSGlobals.h>
41 #include <utils/router/CHRouter.h>
43 
44 
45 // ===========================================================================
46 // static member variables
47 // ===========================================================================
48 std::vector<double> MSRoutingEngine::myEdgeSpeeds;
49 std::vector<double> MSRoutingEngine::myEdgeBikeSpeeds;
50 std::vector<std::vector<double> > MSRoutingEngine::myPastEdgeSpeeds;
51 std::vector<std::vector<double> > MSRoutingEngine::myPastEdgeBikeSpeeds;
61 std::map<std::pair<const MSEdge*, const MSEdge*>, const MSRoute*> MSRoutingEngine::myCachedRoutes;
63 double MSRoutingEngine::myMinEdgePriority(std::numeric_limits<double>::max());
65 
67 #ifdef HAVE_FOX
68 FXMutex MSRoutingEngine::myRouteCacheMutex;
69 #endif
70 
71 
72 // ===========================================================================
73 // method definitions
74 // ===========================================================================
75 void
77  if (myAdaptationInterval == -1) {
79  myEdgeSpeeds.clear();
80  myAdaptationSteps = -1;
81  myLastAdaptation = -1;
83  myWithTaz = oc.getBool("device.rerouting.with-taz");
84  myAdaptationInterval = string2time(oc.getString("device.rerouting.adaptation-interval"));
85  myAdaptationWeight = oc.getFloat("device.rerouting.adaptation-weight");
86  const SUMOTime period = string2time(oc.getString("device.rerouting.period"));
87  if (myAdaptationWeight < 1. && myAdaptationInterval > 0) {
90  } else if (period > 0) {
91  WRITE_WARNING("Rerouting is useless if the edge weights do not get updated!");
92  }
93  OutputDevice::createDeviceByOption("device.rerouting.output", "weights", "meandata_file.xsd");
94  }
95 }
96 
97 
98 void
100  if (myBikeSpeeds && svc == SVC_BICYCLE) {
102  } else {
104  }
105 }
106 
107 
108 void
109 MSRoutingEngine::_initEdgeWeights(std::vector<double>& edgeSpeeds, std::vector<std::vector<double> >& pastEdgeSpeeds) {
110  if (edgeSpeeds.empty()) {
111  const OptionsCont& oc = OptionsCont::getOptions();
112  if (myAdaptationWeight == 0 || !oc.isDefault("device.rerouting.adaptation-steps")) {
113  myAdaptationSteps = oc.getInt("device.rerouting.adaptation-steps");
114  }
115  const bool useLoaded = oc.getBool("device.rerouting.init-with-loaded-weights");
116  const double currentSecond = SIMTIME;
117  double maxEdgePriority = -std::numeric_limits<double>::max();
118  for (const MSEdge* const edge : MSNet::getInstance()->getEdgeControl().getEdges()) {
119  while (edge->getNumericalID() >= (int)edgeSpeeds.size()) {
120  edgeSpeeds.push_back(0);
121  if (myAdaptationSteps > 0) {
122  pastEdgeSpeeds.push_back(std::vector<double>());
123  }
124  }
125  if (useLoaded) {
126  edgeSpeeds[edge->getNumericalID()] = edge->getLength() / MSNet::getTravelTime(edge, nullptr, currentSecond);
127  } else {
128  edgeSpeeds[edge->getNumericalID()] = edge->getMeanSpeed();
129  }
130  if (myAdaptationSteps > 0) {
131  pastEdgeSpeeds[edge->getNumericalID()] = std::vector<double>(myAdaptationSteps, edgeSpeeds[edge->getNumericalID()]);
132  }
133  maxEdgePriority = MAX2(maxEdgePriority, (double)edge->getPriority());
134  myMinEdgePriority = MIN2(myMinEdgePriority, (double)edge->getPriority());
135  }
136  myEdgePriorityRange = maxEdgePriority - myMinEdgePriority;
138  myPriorityFactor = oc.getFloat("weights.priority-factor");
139  if (myPriorityFactor < 0) {
140  throw ProcessError("weights.priority-factor cannot be negative.");
141  }
142  if (myPriorityFactor > 0) {
143  if (myEdgePriorityRange == 0) {
144  WRITE_WARNING("Option weights.priority-factor does not take effect because all edges have the same priority");
145  myPriorityFactor = 0;
146  }
147  }
148  }
149 }
150 
151 
152 double
153 MSRoutingEngine::getEffort(const MSEdge* const e, const SUMOVehicle* const v, double) {
154  const int id = e->getNumericalID();
155  if (id < (int)myEdgeSpeeds.size()) {
156  return MAX2(e->getLength() / MAX2(myEdgeSpeeds[id], NUMERICAL_EPS), e->getMinimumTravelTime(v));
157  }
158  return e->getMinimumTravelTime(v);
159 }
160 
161 
162 double
163 MSRoutingEngine::getEffortBike(const MSEdge* const e, const SUMOVehicle* const v, double) {
164  const int id = e->getNumericalID();
165  if (id < (int)myEdgeBikeSpeeds.size()) {
166  return MAX2(e->getLength() / MAX2(myEdgeBikeSpeeds[id], NUMERICAL_EPS), e->getMinimumTravelTime(v));
167  }
168  return e->getMinimumTravelTime(v);
169 }
170 
171 
172 
173 double
174 MSRoutingEngine::getEffortExtra(const MSEdge* const e, const SUMOVehicle* const v, double t) {
175  double effort = (!myBikeSpeeds || v == nullptr || v->getVClass() != SVC_BICYCLE
176  ? getEffort(e, v, t)
177  : getEffortBike(e, v, t));
178  if (gWeightsRandomFactor != 1.) {
179  effort *= RandHelper::rand(1., gWeightsRandomFactor);
180  }
181  if (myPriorityFactor != 0) {
182  // lower priority should result in higher effort (and the edge with
183  // minimum priority receives a factor of 1 + myPriorityFactor
184  const double relativeInversePrio = 1 - ((e->getPriority() - myMinEdgePriority) / myEdgePriorityRange);
185  effort *= 1 + relativeInversePrio * myPriorityFactor;
186  }
187  return effort;
188 }
189 
190 
191 double
193  return edge->getLength() / myEffortFunc(edge, veh, 0);
194 }
195 
196 
197 SUMOTime
200  if (myBikeSpeeds) {
202  }
203  if (MSNet::getInstance()->getVehicleControl().getDepartedVehicleNo() == 0) {
204  return myAdaptationInterval;
205  }
206  std::map<std::pair<const MSEdge*, const MSEdge*>, const MSRoute*>::iterator it = myCachedRoutes.begin();
207  for (; it != myCachedRoutes.end(); ++it) {
208  it->second->release();
209  }
210  myCachedRoutes.clear();
212  if (myAdaptationSteps > 0) {
213  // moving average
214  for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
215  if ((*i)->isDelayed()) {
216  const int id = (*i)->getNumericalID();
217  const double currSpeed = (*i)->getMeanSpeed();
219  myPastEdgeSpeeds[id][myAdaptationStepsIndex] = currSpeed;
220  }
221  }
222  if (myBikeSpeeds) {
223  for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
224  if ((*i)->isDelayed()) {
225  const int id = (*i)->getNumericalID();
226  const double currSpeed = (*i)->getMeanSpeedBike();
229  }
230  }
231  }
233  } else {
234  // exponential moving average
235  const double newWeightFactor = (double)(1. - myAdaptationWeight);
236  for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
237  if ((*i)->isDelayed()) {
238  const int id = (*i)->getNumericalID();
239  const double currSpeed = (*i)->getMeanSpeed();
240  if (currSpeed != myEdgeSpeeds[id]) {
241  myEdgeSpeeds[id] = myEdgeSpeeds[id] * myAdaptationWeight + currSpeed * newWeightFactor;
242  }
243  }
244  }
245  if (myBikeSpeeds) {
246  for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
247  if ((*i)->isDelayed()) {
248  const int id = (*i)->getNumericalID();
249  const double currSpeed = (*i)->getMeanSpeedBike();
250  if (currSpeed != myEdgeBikeSpeeds[id]) {
251  myEdgeBikeSpeeds[id] = myEdgeBikeSpeeds[id] * myAdaptationWeight + currSpeed * newWeightFactor;
252  }
253  }
254  }
255  }
256  }
257  myLastAdaptation = currentTime + DELTA_T; // because we run at the end of the time step
258  if (OptionsCont::getOptions().isSet("device.rerouting.output")) {
259  OutputDevice& dev = OutputDevice::getDeviceByOption("device.rerouting.output");
261  dev.writeAttr(SUMO_ATTR_ID, "device.rerouting");
262  dev.writeAttr(SUMO_ATTR_BEGIN, STEPS2TIME(currentTime));
264  for (const MSEdge* e : edges) {
265  dev.openTag(SUMO_TAG_EDGE);
266  dev.writeAttr(SUMO_ATTR_ID, e->getID());
267  dev.writeAttr("traveltime", myEffortFunc(e, nullptr, STEPS2TIME(currentTime)));
268  if (myBikeSpeeds) {
269  // @note edge-priority is not included here
270  dev.writeAttr("traveltimeBike", getEffortBike(e, nullptr, STEPS2TIME(currentTime)));
271  }
272  dev.closeTag();
273  }
274  dev.closeTag();
275  }
276  return myAdaptationInterval;
277 }
278 
279 
280 const MSRoute*
281 MSRoutingEngine::getCachedRoute(const std::pair<const MSEdge*, const MSEdge*>& key) {
282  auto routeIt = myCachedRoutes.find(key);
283  if (routeIt != myCachedRoutes.end()) {
284  return routeIt->second;
285  }
286  return nullptr;
287 }
288 
289 
290 void
293  const std::string routingAlgorithm = oc.getString("routing-algorithm");
294  myBikeSpeeds = oc.getBool("device.rerouting.bike-speeds");
296 
297  SUMOAbstractRouter<MSEdge, SUMOVehicle>* router = nullptr;
298  if (routingAlgorithm == "dijkstra") {
299  router = new DijkstraRouter<MSEdge, SUMOVehicle>(MSEdge::getAllEdges(), true, myEffortFunc, nullptr, false, nullptr, true);
300  } else if (routingAlgorithm == "astar") {
301  typedef AStarRouter<MSEdge, SUMOVehicle> AStar;
302  std::shared_ptr<const AStar::LookupTable> lookup = nullptr;
303  if (oc.isSet("astar.all-distances")) {
304  lookup = std::make_shared<const AStar::FLT>(oc.getString("astar.all-distances"), (int)MSEdge::getAllEdges().size());
305  } else if (oc.isSet("astar.landmark-distances") && vehicle != nullptr) {
306  const double speedFactor = vehicle->getChosenSpeedFactor();
307  // we need an exemplary vehicle with speedFactor 1
308  vehicle->setChosenSpeedFactor(1);
311  string2time(oc.getString("begin")), string2time(oc.getString("end")), SUMOTime_MAX, 1);
312  lookup = std::make_shared<const AStar::LMLT>(oc.getString("astar.landmark-distances"), MSEdge::getAllEdges(), &chrouter,
313  nullptr, vehicle, "", oc.getInt("device.rerouting.threads"));
314  vehicle->setChosenSpeedFactor(speedFactor);
315  }
316  router = new AStar(MSEdge::getAllEdges(), true, myEffortFunc, lookup, true);
317  } else if (routingAlgorithm == "CH") {
318  const SUMOTime weightPeriod = myAdaptationInterval > 0 ? myAdaptationInterval : SUMOTime_MAX;
319  router = new CHRouter<MSEdge, SUMOVehicle>(
320  MSEdge::getAllEdges(), true, myEffortFunc, vehicle == nullptr ? SVC_PASSENGER : vehicle->getVClass(), weightPeriod, true, false);
321  } else if (routingAlgorithm == "CHWrapper") {
322  const SUMOTime weightPeriod = myAdaptationInterval > 0 ? myAdaptationInterval : SUMOTime_MAX;
325  string2time(oc.getString("begin")), string2time(oc.getString("end")), weightPeriod, oc.getInt("device.rerouting.threads"));
326  } else {
327  throw ProcessError("Unknown routing algorithm '" + routingAlgorithm + "'!");
328  }
329 
330  RailwayRouter<MSEdge, SUMOVehicle>* railRouter = nullptr;
331  if (MSNet::getInstance()->hasBidiEdges()) {
332  railRouter = new RailwayRouter<MSEdge, SUMOVehicle>(MSEdge::getAllEdges(), true, myEffortFunc, nullptr, false, true, false, oc.getFloat("railway.max-train-length"));
333  }
334  myRouterProvider = new MSRouterProvider(router, nullptr, nullptr, railRouter);
335 #ifndef THREAD_POOL
336 #ifdef HAVE_FOX
337  FXWorkerThread::Pool& threadPool = MSNet::getInstance()->getEdgeControl().getThreadPool();
338  if (threadPool.size() > 0) {
339  const std::vector<FXWorkerThread*>& threads = threadPool.getWorkers();
340  if (static_cast<MSEdgeControl::WorkerThread*>(threads.front())->setRouterProvider(myRouterProvider)) {
341  for (std::vector<FXWorkerThread*>::const_iterator t = threads.begin() + 1; t != threads.end(); ++t) {
342  static_cast<MSEdgeControl::WorkerThread*>(*t)->setRouterProvider(myRouterProvider->clone());
343  }
344  }
345  }
346 #endif
347 #endif
348 }
349 
350 
351 void
352 MSRoutingEngine::reroute(SUMOVehicle& vehicle, const SUMOTime currentTime, const std::string& info,
353  const bool onInit, const bool silent, const MSEdgeVector& prohibited) {
354  if (myRouterProvider == nullptr) {
355  initRouter(&vehicle);
356  }
357  auto& router = myRouterProvider->getVehicleRouter(vehicle.getVClass());
358 #ifndef THREAD_POOL
359 #ifdef HAVE_FOX
360  FXWorkerThread::Pool& threadPool = MSNet::getInstance()->getEdgeControl().getThreadPool();
361  if (threadPool.size() > 0) {
362  threadPool.add(new RoutingTask(vehicle, currentTime, info, onInit, silent, prohibited));
363  return;
364  }
365 #endif
366 #endif
367  if (!prohibited.empty()) {
368  router.prohibit(prohibited);
369  }
370  try {
371  vehicle.reroute(currentTime, info, router, onInit, myWithTaz, silent);
372  } catch (ProcessError&) {
373  if (!silent) {
374  if (!prohibited.empty()) {
375  router.prohibit(MSEdgeVector());
376  }
377  throw;
378  }
379  }
380  if (!prohibited.empty()) {
381  router.prohibit(MSEdgeVector());
382  }
383 }
384 
385 
386 void
387 MSRoutingEngine::setEdgeTravelTime(const MSEdge* const edge, const double travelTime) {
388  myEdgeSpeeds[edge->getNumericalID()] = edge->getLength() / travelTime;
389 }
390 
391 
393 MSRoutingEngine::getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector& prohibited) {
394  if (myRouterProvider == nullptr) {
396  initEdgeWeights(svc);
397  initRouter();
398  }
399 #ifndef THREAD_POOL
400 #ifdef HAVE_FOX
401  FXWorkerThread::Pool& threadPool = MSNet::getInstance()->getEdgeControl().getThreadPool();
402  if (threadPool.size() > 0) {
403  auto& router = static_cast<MSEdgeControl::WorkerThread*>(threadPool.getWorkers()[rngIndex % MSGlobals::gNumThreads])->getRouter(svc);
404  router.prohibit(prohibited);
405  return router;
406  }
407 #endif
408 #endif
409  myRouterProvider->getVehicleRouter(svc).prohibit(prohibited);
410  return myRouterProvider->getVehicleRouter(svc);
411 }
412 
413 
414 void
416  myAdaptationInterval = -1; // responsible for triggering initEdgeWeights
417  myPastEdgeSpeeds.clear();
418  myEdgeSpeeds.clear();
419  myPastEdgeBikeSpeeds.clear();
420  myEdgeBikeSpeeds.clear();
421  // @todo recheck. calling release crashes in parallel routing
422  //for (auto& item : myCachedRoutes) {
423  // item.second->release();
424  //}
425  myCachedRoutes.clear();
427 #ifdef HAVE_FOX
428  if (MSGlobals::gNumThreads > 1) {
429  // router deletion is done in thread destructor
430  myRouterProvider = nullptr;
431  return;
432  }
433 #endif
434  delete myRouterProvider;
435  myRouterProvider = nullptr;
436 }
437 
438 
439 #ifdef HAVE_FOX
440 void
441 MSRoutingEngine::waitForAll() {
442 #ifndef THREAD_POOL
443  FXWorkerThread::Pool& threadPool = MSNet::getInstance()->getEdgeControl().getThreadPool();
444  if (threadPool.size() > 0) {
445  threadPool.waitAll();
446  }
447 #endif
448 }
449 
450 
451 // ---------------------------------------------------------------------------
452 // MSRoutingEngine::RoutingTask-methods
453 // ---------------------------------------------------------------------------
454 void
455 MSRoutingEngine::RoutingTask::run(FXWorkerThread* context) {
456  SUMOAbstractRouter<MSEdge, SUMOVehicle>& router = static_cast<MSEdgeControl::WorkerThread*>(context)->getRouter(myVehicle.getVClass());
457  if (!myProhibited.empty()) {
458  router.prohibit(myProhibited);
459  }
460  try {
461  myVehicle.reroute(myTime, myInfo, router, myOnInit, myWithTaz, mySilent);
462  } catch (ProcessError&) {
463  if (!mySilent) {
464  if (!myProhibited.empty()) {
465  router.prohibit(MSEdgeVector());
466  }
467  throw;
468  }
469  }
470  if (!myProhibited.empty()) {
471  router.prohibit(MSEdgeVector());
472  }
473  const MSEdge* source = *myVehicle.getRoute().begin();
474  const MSEdge* dest = myVehicle.getRoute().getLastEdge();
475  if (source->isTazConnector() && dest->isTazConnector()) {
476  const std::pair<const MSEdge*, const MSEdge*> key = std::make_pair(source, dest);
477  FXMutexLock lock(myRouteCacheMutex);
479  MSRoutingEngine::myCachedRoutes[key] = &myVehicle.getRoute();
480  myVehicle.getRoute().addReference();
481  }
482  }
483 }
484 #endif
485 
486 
487 /****************************************************************************/
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define SUMOTime_MAX
Definition: SUMOTime.h:32
#define SIMTIME
Definition: SUMOTime.h:60
long long int SUMOTime
Definition: SUMOTime.h:31
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
double gWeightsRandomFactor
Definition: StdDefs.cpp:29
T MIN2(T a, T b)
Definition: StdDefs.h:73
T MAX2(T a, T b)
Definition: StdDefs.h:79
Computes the shortest path through a network using the A* algorithm.
Definition: AStarRouter.h:76
Computes the shortest path through a contracted network.
Definition: CHRouter.h:59
Computes the shortest path through a contracted network.
Base (microsim) event class.
Definition: Command.h:49
Computes the shortest path through a network using the Dijkstra algorithm.
A pool of worker threads which distributes the tasks and collects the results.
void add(Task *const t, int index=-1)
Gives a number to the given task and assigns it to the worker with the given index....
const std::vector< FXWorkerThread * > & getWorkers()
int size() const
Returns the number of threads in the pool.
void waitAll(const bool deleteFinished=true)
waits for all tasks to be finished
A thread repeatingly calculating incoming tasks.
const MSEdgeVector & getEdges() const
Returns loaded edges.
A road/street connecting two junctions.
Definition: MSEdge.h:77
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:847
int getPriority() const
Returns the priority of the edge.
Definition: MSEdge.h:313
double getLength() const
return the length of the edge
Definition: MSEdge.h:630
bool isTazConnector() const
Definition: MSEdge.h:279
double getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
Definition: MSEdge.h:450
int getNumericalID() const
Returns the numerical id of the edge.
Definition: MSEdge.h:294
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static int gNumThreads
how many threads to use
Definition: MSGlobals.h:118
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:313
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition: MSNet.h:474
static double getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the travel time to pass an edge.
Definition: MSNet.cpp:154
MSEdgeControl & getEdgeControl()
Returns the edge control.
Definition: MSNet.h:414
static SUMOTime myAdaptationInterval
At which time interval the edge weights get updated.
static double myAdaptationWeight
Information which weight prior edge efforts have.
static int myAdaptationStepsIndex
The current index in the pastEdgeSpeed ring-buffer.
static double myMinEdgePriority
Minimum priority for all edges.
static double getEffortBike(const MSEdge *const e, const SUMOVehicle *const v, double t)
static void setEdgeTravelTime(const MSEdge *const edge, const double travelTime)
adapt the known travel time for an edge
static void reroute(SUMOVehicle &vehicle, const SUMOTime currentTime, const std::string &info, const bool onInit=false, const bool silent=false, const MSEdgeVector &prohibited=MSEdgeVector())
initiate the rerouting, create router / thread pool on first use
static double myEdgePriorityRange
the difference between maximum and minimum priority for all edges
static double myPriorityFactor
Coefficient for factoring edge priority into routing weight.
static SUMOTime adaptEdgeEfforts(SUMOTime currentTime)
Adapt edge efforts by the current edge states.
static const MSRoute * getCachedRoute(const std::pair< const MSEdge *, const MSEdge * > &key)
return the cached route or nullptr on miss
static bool myBikeSpeeds
whether separate speeds for bicycles shall be tracked
static void _initEdgeWeights(std::vector< double > &edgeSpeeds, std::vector< std::vector< double > > &pastEdgeSpeeds)
initialized edge speed storage into the given containers
static MSRouterProvider * myRouterProvider
The router to use.
static bool myWithTaz
whether taz shall be used at initial rerouting
static std::vector< std::vector< double > > myPastEdgeBikeSpeeds
static std::vector< double > myEdgeSpeeds
The container of edge speeds.
static void initWeightUpdate()
intialize period edge weight update
RouterProvider< MSEdge, MSLane, MSJunction, SUMOVehicle > MSRouterProvider
static void initEdgeWeights(SUMOVehicleClass svc)
initialize the edge weights if not done before
static SUMOTime myLastAdaptation
Information when the last edge weight adaptation occurred.
static void cleanup()
deletes the router instance
static void initRouter(SUMOVehicle *vehicle=nullptr)
static SUMOAbstractRouter< MSEdge, SUMOVehicle >::Operation myEffortFunc
static int myAdaptationSteps
The number of steps for averaging edge speeds (ring-buffer)
static std::map< std::pair< const MSEdge *, const MSEdge * >, const MSRoute * > myCachedRoutes
The container of pre-calculated routes.
static Command * myEdgeWeightSettingCommand
The weights adaptation/overwriting command.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
static std::vector< std::vector< double > > myPastEdgeSpeeds
The container of past edge speeds (when using a simple moving average)
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
static double getAssumedSpeed(const MSEdge *edge, const SUMOVehicle *veh)
return current travel speed assumption
static double getEffortExtra(const MSEdge *const e, const SUMOVehicle *const v, double t)
static std::vector< double > myEdgeBikeSpeeds
A storage for options typed value containers)
Definition: OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:239
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static double rand(std::mt19937 *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.h:51
RouterProvider * clone()
SUMOAbstractRouter< E, V > & getVehicleRouter(SUMOVehicleClass svc) const
virtual void prohibit(const std::vector< E * > &)
virtual double getChosenSpeedFactor() const =0
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
Representation of a vehicle.
Definition: SUMOVehicle.h:58
virtual void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false)=0
Performs a rerouting using the given router.
virtual void setChosenSpeedFactor(const double factor)=0
A wrapper for a Command function.
Definition: StaticCommand.h:37