Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RORouteDef.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2002-2026 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/****************************************************************************/
20// Base class for a vehicle's route definition
21/****************************************************************************/
22#include <config.h>
23
24#include <string>
25#include <iterator>
26#include <algorithm>
29#include <utils/common/Named.h>
35#include "ROEdge.h"
36#include "RORoute.h"
39#include "RORouteDef.h"
40#include "ROVehicle.h"
41
42// ===========================================================================
43// static members
44// ===========================================================================
45bool RORouteDef::myUsingJTRR(false);
47
48// ===========================================================================
49// method definitions
50// ===========================================================================
51RORouteDef::RORouteDef(const std::string& id, const int lastUsed,
52 const bool tryRepair, const bool mayBeDisconnected) :
53 Named(StringUtils::convertUmlaute(id)),
54 myPrecomputed(nullptr), myLastUsed(lastUsed), myTryRepair(tryRepair),
55 myMayBeDisconnected(mayBeDisconnected),
56 myDiscardSilent(false) {
57}
58
59
60void
62 std::copy(alt->myAlternatives.begin(), alt->myAlternatives.end(),
63 back_inserter(myAlternatives));
64}
65
66
67std::shared_ptr<RORoute>
69 SUMOTime begin, const ROVehicle& veh) const {
70 if (myPrecomputed == nullptr) {
71 preComputeCurrentRoute(router, begin, veh);
72 }
73 return myPrecomputed;
74}
75
76
77void
79 for (int i = 0; i < (int)myAlternatives.size();) {
80 if ((i != myLastUsed || mySkipNewRoutes) && !myAlternatives[i]->isPermitted(veh, errorHandler)) {
81 myAlternatives.erase(myAlternatives.begin() + i);
82 if (myLastUsed > i) {
83 myLastUsed--;
84 }
85 } else {
86 i++;
87 }
88 }
89}
90
91
92void
94 SUMOTime begin, const ROVehicle& veh) const {
95 myNewRoute = false;
97 const bool ignoreErrors = oc.getBool("ignore-errors");
98 const bool hasRestrictions = RONet::getInstance()->hasParamRestrictions();
99 assert(myAlternatives[0]->getEdgeVector().size() > 0);
101 if (myAlternatives[0]->getFirst()->prohibits(&veh, hasRestrictions) && (!oc.getBool("repair.from")
102 // do not try to reassign starting edge for trip input
103 || myMayBeDisconnected || myAlternatives[0]->getEdgeVector().size() < 2)) {
104 mh->informf(TL("Vehicle '%' is not allowed to depart on edge '%'."), veh.getID(), myAlternatives[0]->getFirst()->getID());
105 return;
106 } else if (myAlternatives[0]->getLast()->prohibits(&veh, hasRestrictions) && (!oc.getBool("repair.to")
107 // do not try to reassign destination edge for trip input
108 || myMayBeDisconnected || myAlternatives[0]->getEdgeVector().size() < 2)) {
109 // this check is not strictly necessary unless myTryRepair is set.
110 // However, the error message is more helpful than "no connection found"
111 mh->informf(TL("Vehicle '%' is not allowed to arrive on edge '%'."), veh.getID(), myAlternatives[0]->getLast()->getID());
112 return;
113 }
114 const bool skipTripRouting = (oc.exists("write-trips") && oc.getBool("write-trips")
116 if ((myTryRepair && !skipTripRouting) || myUsingJTRR) {
117 ConstROEdgeVector newEdges;
118 if (repairCurrentRoute(router, begin, veh, myAlternatives[0]->getEdgeVector(), newEdges)) {
119 if (myAlternatives[0]->getEdgeVector() != newEdges) {
120 if (!myMayBeDisconnected) {
121 WRITE_WARNINGF(TL("Repaired route of vehicle '%'."), veh.getID());
122 }
123 myNewRoute = true;
124 RGBColor* col = myAlternatives[0]->getColor() != nullptr ? new RGBColor(*myAlternatives[0]->getColor()) : nullptr;
125 myPrecomputed = std::make_shared<RORoute>(myID, 0, myAlternatives[0]->getProbability(), newEdges, col, myAlternatives[0]->getStops());
126 } else {
128 }
129 }
130 return;
131 }
133 || OptionsCont::getOptions().getBool("remove-loops")) {
134 if (skipTripRouting || myAlternatives[myLastUsed]->isValid(veh, ignoreErrors)) {
136 }
137 } else {
138 // build a new route to test whether it is better
140 ConstROEdgeVector edges;
141 if (repairCurrentRoute(router, begin, veh, oldEdges, edges, true)) {
142 if (edges.front()->isTazConnector()) {
143 edges.erase(edges.begin());
144 }
145 if (edges.back()->isTazConnector()) {
146 edges.pop_back();
147 }
148 // check whether the same route was already used
149 int existing = -1;
150 for (int i = 0; i < (int)myAlternatives.size(); i++) {
151 if (edges == myAlternatives[i]->getEdgeVector()) {
152 existing = i;
153 break;
154 }
155 }
156 if (existing >= 0) {
157 myPrecomputed = myAlternatives[existing];
158 } else {
159 RGBColor* col = myAlternatives[0]->getColor() != nullptr ? new RGBColor(*myAlternatives[0]->getColor()) : nullptr;
160 myPrecomputed = std::make_shared<RORoute>(myID, 0, 1, edges, col, myAlternatives[0]->getStops());
161 myNewRoute = true;
162 }
163 }
164 }
165}
166
167
168bool
170 SUMOTime begin, const ROVehicle& veh,
171 ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges,
172 bool isTrip) const {
173 MsgHandler* mh = (OptionsCont::getOptions().getBool("ignore-errors") ?
175 RONet* net = RONet::getInstance();
176 const int initialSize = (int)oldEdges.size();
177 const bool hasRestrictions = RONet::getInstance()->hasParamRestrictions();
178 if (net->hasProhibitions() && router.supportsProhibitions()) {
179 if (net->getProhibitions().size() > 0 && !router.hasProhibitions()) {
180 router.prohibit(net->getProhibitions());
181 }
182 net->updateLaneProhibitions(begin);
183 }
184 if (initialSize == 1) {
185 if (myUsingJTRR) {
187 bool ok = router.compute(oldEdges.front(), nullptr, &veh, begin, newEdges);
188 myDiscardSilent = ok && newEdges.size() == 0;
189 } else {
190 newEdges = oldEdges;
191 }
192 } else {
193 if (oldEdges.front()->prohibits(&veh, hasRestrictions)) {
194 // option repair.from is in effect
195 const std::string& frontID = oldEdges.front()->getID();
196 for (ConstROEdgeVector::iterator i = oldEdges.begin(); i != oldEdges.end();) {
197 if ((*i)->prohibits(&veh, hasRestrictions) || (*i)->isInternal()) {
198 i = oldEdges.erase(i);
199 } else {
200 WRITE_MESSAGE("Changing invalid starting edge '" + frontID
201 + "' to '" + (*i)->getID() + "' for vehicle '" + veh.getID() + "'.");
202 break;
203 }
204 }
205 }
206 if (oldEdges.size() == 0) {
207 mh->informf(TL("Could not find new starting edge for vehicle '%'."), veh.getID());
208 return false;
209 }
210 if (oldEdges.back()->prohibits(&veh, hasRestrictions)) {
211 // option repair.to is in effect
212 const std::string& backID = oldEdges.back()->getID();
213 // oldEdges cannot get empty here, otherwise we would have left the stage when checking "from"
214 while (oldEdges.back()->prohibits(&veh, hasRestrictions) || oldEdges.back()->isInternal()) {
215 oldEdges.pop_back();
216 }
217 WRITE_MESSAGE("Changing invalid destination edge '" + backID
218 + "' to edge '" + oldEdges.back()->getID() + "' for vehicle '" + veh.getID() + "'.");
219 }
220 std::vector<ROVehicle::Mandatory> mandatory = veh.getMandatoryEdges(oldEdges.front(), oldEdges.back());
221 assert(mandatory.size() >= 2);
222 // removed prohibited
223 for (ConstROEdgeVector::iterator i = oldEdges.begin(); i != oldEdges.end();) {
224 if ((*i)->prohibits(&veh, hasRestrictions) || (*i)->isInternal()) {
225 // no need to check the mandatories here, this was done before
226 WRITE_MESSAGEF(TL("Removing invalid edge '%' from route for vehicle '%'."), (*i)->getID(), veh.getID());
227 i = oldEdges.erase(i);
228 } else {
229 ++i;
230 }
231 }
232 // reconnect remaining edges
233 if (mandatory.size() > oldEdges.size() && initialSize > 2) {
234 WRITE_MESSAGEF(TL("There are stop edges which were not part of the original route for vehicle '%'."), veh.getID());
235 }
236 ConstROEdgeVector targets;
237 bool checkPositions = false;
238 if (mandatory.size() >= oldEdges.size()) {
239 for (auto m : mandatory) {
240 targets.push_back(m.edge);
241 checkPositions |= m.pos >= 0;
242 }
243 } else {
244 targets = oldEdges;
245 }
246 newEdges.push_back(targets.front());
247 auto nextMandatory = mandatory.begin() + 1;
248 while (nextMandatory != mandatory.end()
249 && targets.front() == nextMandatory->edge
250 && (nextMandatory->edge != (nextMandatory - 1)->edge
251 || nextMandatory->pos >= (nextMandatory - 1)->pos
252 // ignore invalid via stop pos
253 || nextMandatory->pos < 0)) {
254 nextMandatory++;
255 }
256 int lastMandatory = 0;
257 for (ConstROEdgeVector::const_iterator i = targets.begin() + 1;
258 i != targets.end() && nextMandatory != mandatory.end(); ++i) {
259 const ROEdge* prev = *(i - 1);
260 const ROEdge* cur = *i;
261 if (prev->isConnectedTo(*cur, veh.getVClass()) && (!isRailway(veh.getVClass()) || prev->getBidiEdge() != cur)) {
262 newEdges.push_back(cur);
263 } else {
264 if (initialSize > 2) {
265 // only inform if the input is (probably) not a trip
266 WRITE_MESSAGEF(TL("Edge '%' not connected to edge '%' for vehicle '%'."), (*(i - 1))->getID(), (*i)->getID(), veh.getID());
267 }
268 const ROEdge* last = newEdges.back();
269 newEdges.pop_back();
270 if (last->isTazConnector() && newEdges.size() > 1) {
271 // assume this was a viaTaz
272 last = newEdges.back();
273 newEdges.pop_back();
274 }
275 if (veh.hasJumps() && (nextMandatory - 1)->isJump) {
276 while (*i != nextMandatory->edge) {
277 ++i;
278 }
279 newEdges.push_back(last);
280 newEdges.push_back(*i);
281 //std::cout << " skipJump mIndex=" << (nextMandatory - 1 - mandatory.begin()) << " last=" << last->getID() << " next=" << (*i)->getID() << " newEdges=" << toString(newEdges) << "\n";
282 } else {
283 int numEdgesBefore = (int)newEdges.size();
284 // router.setHint(targets.begin(), i, &veh, begin);
285 if (myTryRepair && lastMandatory < (int)newEdges.size() && last != newEdges[lastMandatory]) {
287 }
288 bool ok;
289 if (checkPositions
290 && mandatory[i - targets.begin() - 1].pos >= 0
291 && mandatory[i - targets.begin()].pos >= 0) {
292 ok = router.compute(
293 last, mandatory[i - targets.begin() - 1].pos,
294 *i, mandatory[i - targets.begin()].pos,
295 &veh, begin, newEdges);
296 } else {
297 ok = router.compute(last, *i, &veh, begin, newEdges);
298 }
299 router.setMsgHandler(mh);
300 if (!ok) {
301 // backtrack: try to route from last mandatory edge to next mandatory edge
302 // XXX add option for backtracking in smaller increments
303 // (i.e. previous edge to edge after *i)
304 // we would then need to decide whether we have found a good
305 // tradeoff between faithfulness to the input data and detour-length
306 if (lastMandatory >= (int)newEdges.size() || last == newEdges[lastMandatory] || !backTrack(router, i, lastMandatory, nextMandatory->edge, newEdges, veh, begin)) {
307 mh->informf(TL("Mandatory edge '%' not reachable by vehicle '%'."), (*i)->getID(), veh.getID());
308 return false;
309 }
310 } else if (!myMayBeDisconnected && !isTrip && last != (*i)) {
311 double airDist = last->getToJunction()->getPosition().distanceTo(
312 (*i)->getFromJunction()->getPosition());
313 double repairDist = 0;
314 for (auto it2 = (newEdges.begin() + numEdgesBefore + 1); it2 != newEdges.end() && it2 != newEdges.end() - 1; it2++) {
315 repairDist += (*it2)->getLength();
316 }
317 const double detourFactor = repairDist / MAX2(airDist, 1.0);
318 const double detour = MAX2(0.0, repairDist - airDist);
319 const double maxDetourFactor = OptionsCont::getOptions().getFloat("repair.max-detour-factor");
320 if (detourFactor > maxDetourFactor) {
321 WRITE_MESSAGEF(" Backtracking to avoid detour of %m for gap of %m)", detour, airDist);
322 backTrack(router, i, lastMandatory, nextMandatory->edge, newEdges, veh, begin);
323 } else if (detourFactor > 1.1) {
324 WRITE_MESSAGEF(" Taking detour of %m to avoid gap of %m)", detour, airDist);
325 }
326 }
327 }
328 }
329 while (nextMandatory != mandatory.end()
330 && *i == nextMandatory->edge
331 && (nextMandatory->edge != (nextMandatory - 1)->edge
332 || nextMandatory->pos >= (nextMandatory - 1)->pos
333 // ignore invalid via stop pos
334 || nextMandatory->pos < 0)) {
335 nextMandatory++;
336 lastMandatory = (int)newEdges.size() - 1;
337 }
338 }
339 if (veh.getParameter().via.size() > 0 && veh.getParameter().stops.size() > 0) {
340 // check consistency of stops and vias
341 auto it = newEdges.begin();
342 for (const auto& stop : veh.getParameter().stops) {
343 const ROEdge* e = net->getEdge(stop.edge);
344 it = std::find(it, newEdges.end(), e);
345 if (it == newEdges.end()) {
346 mh->informf(TL("Stop edge '%' is inconsistent with via edges for vehicle '%'."), e->getID(), veh.getID());
347 return false;
348 }
349 }
350 }
351 }
352 return true;
353}
354
355
356bool
358 ConstROEdgeVector::const_iterator& i, int lastMandatory, const ROEdge* nextMandatory,
359 ConstROEdgeVector& newEdges, const ROVehicle& veh, SUMOTime begin) {
360 ConstROEdgeVector edges;
361 bool ok = router.compute(newEdges[lastMandatory], nextMandatory, &veh, begin, edges, true);
362 if (!ok) {
363 return false;
364 }
365
366 while (*i != nextMandatory) {
367 ++i;
368 }
369 newEdges.erase(newEdges.begin() + lastMandatory + 1, newEdges.end());
370 std::copy(edges.begin() + 1, edges.end(), back_inserter(newEdges));
371 return true;
372}
373
374
375std::shared_ptr<RORoute>
377 const ROVehicle* const veh, std::shared_ptr<RORoute> current, SUMOTime begin,
378 MsgHandler* errorHandler) {
379 std::shared_ptr<RORoute> replaced = nullptr;
380 if (myTryRepair || myUsingJTRR) {
381 if (myNewRoute) {
382 replaced = myAlternatives[0];
383 myAlternatives[0] = current;
384 }
385 if (!router.isValid(current->getEdgeVector(), veh, STEPS2TIME(begin))) {
386 throw ProcessError("Route '" + getID() + "' (vehicle '" + veh->getID() + "') is not valid.");
387 }
388 double costs = router.recomputeCosts(current->getEdgeVector(), veh, begin);
389 if (veh->hasJumps()) {
390 // @todo: jumpTime should be applied in recomputeCost to ensure the
391 // correctness of time-dependent traveltimes
392 costs += STEPS2TIME(veh->getJumpTime());
393 }
394 current->setCosts(costs);
395 return replaced;
396 }
397 // add the route when it's new
398 if (myAlternatives.back()->getProbability() < 0 || !myAlternatives.back()->isPermitted(veh, errorHandler)) {
399 if (myAlternatives.back()->getProbability() >= 0 && errorHandler == MsgHandler::getErrorInstance()) {
400 throw ProcessError("Route '" + current->getID() + "' (vehicle '" + veh->getID() + "') is not valid.");
401 }
402 myAlternatives.pop_back();
403 }
404 if (myNewRoute) {
405 myAlternatives.push_back(current);
406 }
407 // recompute the costs and (when a new route was added) scale the probabilities
408 const double scale = double(myAlternatives.size() - 1) / double(myAlternatives.size());
409 for (const std::shared_ptr<RORoute>& alt : myAlternatives) {
410 if (!router.isValid(alt->getEdgeVector(), veh, STEPS2TIME(begin))) {
411 throw ProcessError("Route '" + current->getID() + "' (vehicle '" + veh->getID() + "') is not valid.");
412 }
413 // recompute the costs for all routes
414 const double newCosts = router.recomputeCosts(alt->getEdgeVector(), veh, begin);
415 assert(myAlternatives.size() != 0);
416 if (myNewRoute) {
417 if (alt == current) {
418 // set initial probability and costs
419 alt->setProbability(1. / (double) myAlternatives.size());
420 alt->setCosts(newCosts);
421 } else {
422 // rescale probs for all others
423 alt->setProbability(alt->getProbability() * scale);
424 }
425 }
427 }
428 assert(myAlternatives.size() != 0);
430 const bool keepRoute = RouteCostCalculator<RORoute, ROEdge, ROVehicle>::getCalculator().keepRoute();
431 if (!RouteCostCalculator<RORoute, ROEdge, ROVehicle>::getCalculator().keepAllRoutes() && !keepRoute) {
432 // remove with probability of 0 (not mentioned in Gawron)
433 for (std::vector<std::shared_ptr<RORoute>>::iterator i = myAlternatives.begin(); i != myAlternatives.end();) {
434 if ((*i)->getProbability() == 0) {
435 i = myAlternatives.erase(i);
436 } else {
437 i++;
438 }
439 }
440 }
441 int maxNumber = RouteCostCalculator<RORoute, ROEdge, ROVehicle>::getCalculator().getMaxRouteNumber();
442 if ((int)myAlternatives.size() > maxNumber) {
443 std::shared_ptr<const RORoute> last = myAlternatives[myLastUsed];
444 // only keep the routes with highest probability
445 sort(myAlternatives.begin(), myAlternatives.end(), [](const std::shared_ptr<const RORoute> a, const std::shared_ptr<const RORoute> b) {
446 return a->getProbability() > b->getProbability();
447 });
448 if (keepRoute) {
449 for (int i = 0; i < (int)myAlternatives.size(); i++) {
450 if (myAlternatives[i] == last) {
451 myLastUsed = i;
452 break;
453 }
454 }
455 if (myLastUsed >= maxNumber) {
457 myLastUsed = maxNumber - 1;
458 }
459 }
460 myAlternatives.erase(myAlternatives.begin() + maxNumber, myAlternatives.end());
461 }
462 // rescale probabilities
463 double newSum = 0.;
464 for (const std::shared_ptr<RORoute>& alt : myAlternatives) {
465 newSum += alt->getProbability();
466 }
467 assert(newSum > 0);
468 // @note newSum may be larger than 1 for numerical reasons
469 for (const std::shared_ptr<RORoute>& alt : myAlternatives) {
470 alt->setProbability(alt->getProbability() / newSum);
471 }
472
473 // find the route to use
474 if (!keepRoute) {
475 double chosen = RandHelper::rand();
476 myLastUsed = 0;
477 for (const std::shared_ptr<RORoute>& alt : myAlternatives) {
478 chosen -= alt->getProbability();
479 if (chosen <= 0) {
480 return nullptr;
481 }
482 myLastUsed++;
483 }
484 }
485 return nullptr;
486}
487
488
489const ROEdge*
491 return myAlternatives.back()->getFirst();
492}
493
494
495const ROEdge*
497 return myAlternatives.back()->getLast();
498}
499
500
503 bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const {
504 if (asAlternatives) {
506 for (int i = 0; i != (int)myAlternatives.size(); i++) {
507 myAlternatives[i]->writeXMLDefinition(dev, veh, true, true, withExitTimes, withLength);
508 }
509 dev.closeTag();
510 return dev;
511 } else {
512 return myAlternatives[myLastUsed]->writeXMLDefinition(dev, veh, withCost, false, withExitTimes, withLength);
513 }
514}
515
516
518RORouteDef::copy(const std::string& id, const SUMOTime stopOffset) const {
520 for (const std::shared_ptr<const RORoute> route : myAlternatives) {
521 RGBColor* col = route->getColor() != nullptr ? new RGBColor(*route->getColor()) : nullptr;
522 std::shared_ptr<RORoute> newRoute = std::make_shared<RORoute>(id, route->getCosts(), route->getProbability(), route->getEdgeVector(), col, route->getStops());
523 newRoute->addStopOffset(stopOffset);
524 result->addLoadedAlternative(newRoute);
525 }
526 return result;
527}
528
529
530double
532 double sum = 0.;
533 for (const std::shared_ptr<const RORoute> r : myAlternatives) {
534 sum += r->getProbability();
535 }
536 return sum;
537}
538
539
540/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_MESSAGEF(...)
Definition MsgHandler.h:289
#define WRITE_MESSAGE(msg)
Definition MsgHandler.h:288
#define TL(string)
Definition MsgHandler.h:304
std::vector< const ROEdge * > ConstROEdgeVector
Definition ROEdge.h:57
#define STEPS2TIME(x)
Definition SUMOTime.h:58
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permissions is a (exclusive) railway edge.
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_ATTR_LAST
T MAX2(T a, T b)
Definition StdDefs.h:86
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
void informf(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
Definition MsgHandler.h:116
Base class for objects which have an id.
Definition Named.h:53
std::string myID
The name of the object.
Definition Named.h:124
const std::string & getID() const
Returns the id.
Definition Named.h:73
A storage for options typed value containers)
Definition OptionsCont.h:89
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
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.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
Definition Position.h:263
A basic edge for routing applications.
Definition ROEdge.h:73
const ROEdge * getBidiEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
Definition ROEdge.h:563
const RONode * getToJunction() const
Definition ROEdge.h:550
bool isTazConnector() const
Definition ROEdge.h:174
bool isConnectedTo(const ROEdge &e, const SUMOVehicleClass vClass, bool ignoreTransientPermissions=false) const
returns the information whether this edge is directly connected to the given
Definition ROEdge.cpp:461
The router's network representation.
Definition RONet.h:63
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
Definition RONet.cpp:56
void updateLaneProhibitions(SUMOTime begin)
Definition RONet.cpp:1015
bool hasProhibitions() const
Definition RONet.h:469
bool hasParamRestrictions() const
Definition RONet.h:103
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition RONet.h:179
const Prohibitions & getProhibitions() const
Definition RONet.h:473
const Position & getPosition() const
Returns the position of the node.
Definition RONode.h:67
SUMOVehicleClass getVClass() const
Definition RORoutable.h:127
const std::string & getID() const
Returns the id of the routable.
Definition RORoutable.h:98
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition RORoutable.h:75
Base class for a vehicle's route definition.
Definition RORouteDef.h:54
const ROEdge * getOrigin() const
bool repairCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh, ConstROEdgeVector oldEdges, ConstROEdgeVector &newEdges, bool isTrip=false) const
Builds the complete route (or chooses her from the list of alternatives, when existing)
static bool backTrack(SUMOAbstractRouter< ROEdge, ROVehicle > &router, ConstROEdgeVector::const_iterator &i, int lastMandatory, const ROEdge *nextMandatory, ConstROEdgeVector &newEdges, const ROVehicle &veh, SUMOTime begin)
backtrack to last mandatory edge and route to next mandatory
std::shared_ptr< RORoute > myPrecomputed
precomputed route for out-of-order computation
Definition RORouteDef.h:168
std::shared_ptr< RORoute > addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, std::shared_ptr< RORoute > current, SUMOTime begin, MsgHandler *errorHandler)
Adds an alternative to the list of routes and returns the route that was replaced or nullptr.
RORouteDef(const std::string &id, const int lastUsed, const bool tryRepair, const bool mayBeDisconnected)
Constructor.
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const
Saves the built route / route alternatives.
const bool myMayBeDisconnected
Definition RORouteDef.h:180
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
bool myDiscardSilent
Whether this route should be silently discarded.
Definition RORouteDef.h:183
std::shared_ptr< RORoute > buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route.
std::vector< std::shared_ptr< RORoute > > myAlternatives
The alternatives.
Definition RORouteDef.h:174
void preComputeCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Builds the complete route (or chooses her from the list of alternatives, when existing)
static bool myUsingJTRR
Definition RORouteDef.h:185
bool myNewRoute
Information whether a new route was generated.
Definition RORouteDef.h:177
const bool myTryRepair
Definition RORouteDef.h:179
void addLoadedAlternative(std::shared_ptr< RORoute > alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
Definition RORouteDef.h:71
int myLastUsed
Index of the route used within the last step.
Definition RORouteDef.h:171
static bool mySkipNewRoutes
Definition RORouteDef.h:186
const ROEdge * getDestination() const
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
void validateAlternatives(const ROVehicle *veh, MsgHandler *errorHandler)
removes invalid alternatives and raise an error or warning
A vehicle as used by router.
Definition ROVehicle.h:51
SUMOTime getJumpTime() const
Definition ROVehicle.h:128
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
Definition ROVehicle.h:93
bool hasJumps() const
Definition ROVehicle.h:124
std::vector< Mandatory > getMandatoryEdges(const ROEdge *requiredStart, const ROEdge *requiredEnd) const
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Abstract base class providing static factory method.
static RouteCostCalculator< R, E, V > & getCalculator()
virtual void prohibit(const Prohibitions &toProhibit)
virtual bool supportsProhibitions() const
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
bool isValid(const std::vector< const E * > &edges, const V *const v, double t) const
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
virtual void setMsgHandler(MsgHandler *const errorMsgHandler)
std::vector< std::string > via
List of the via-edges the vehicle must visit.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
Some static methods for string processing.
Definition StringUtils.h:39
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:21884