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->inform("Vehicle '" + veh.getID() + "' is not allowed to depart on edge '" +
105 myAlternatives[0]->getFirst()->getID() + "'.");
106 return;
107 } else if (myAlternatives[0]->getLast()->prohibits(&veh, hasRestrictions) && (!oc.getBool("repair.to")
108 // do not try to reassign destination edge for trip input
109 || myMayBeDisconnected || myAlternatives[0]->getEdgeVector().size() < 2)) {
110 // this check is not strictly necessary unless myTryRepair is set.
111 // However, the error message is more helpful than "no connection found"
112 mh->inform("Vehicle '" + veh.getID() + "' is not allowed to arrive on edge '" +
113 myAlternatives[0]->getLast()->getID() + "'.");
114 return;
115 }
116 const bool skipTripRouting = (oc.exists("write-trips") && oc.getBool("write-trips")
118 if ((myTryRepair && !skipTripRouting) || myUsingJTRR) {
119 ConstROEdgeVector newEdges;
120 if (repairCurrentRoute(router, begin, veh, myAlternatives[0]->getEdgeVector(), newEdges)) {
121 if (myAlternatives[0]->getEdgeVector() != newEdges) {
122 if (!myMayBeDisconnected) {
123 WRITE_WARNINGF(TL("Repaired route of vehicle '%'."), veh.getID());
124 }
125 myNewRoute = true;
126 RGBColor* col = myAlternatives[0]->getColor() != nullptr ? new RGBColor(*myAlternatives[0]->getColor()) : nullptr;
127 myPrecomputed = std::make_shared<RORoute>(myID, 0, myAlternatives[0]->getProbability(), newEdges, col, myAlternatives[0]->getStops());
128 } else {
130 }
131 }
132 return;
133 }
135 || OptionsCont::getOptions().getBool("remove-loops")) {
136 if (skipTripRouting || myAlternatives[myLastUsed]->isValid(veh, ignoreErrors)) {
138 }
139 } else {
140 // build a new route to test whether it is better
142 ConstROEdgeVector edges;
143 if (repairCurrentRoute(router, begin, veh, oldEdges, edges, true)) {
144 if (edges.front()->isTazConnector()) {
145 edges.erase(edges.begin());
146 }
147 if (edges.back()->isTazConnector()) {
148 edges.pop_back();
149 }
150 // check whether the same route was already used
151 int existing = -1;
152 for (int i = 0; i < (int)myAlternatives.size(); i++) {
153 if (edges == myAlternatives[i]->getEdgeVector()) {
154 existing = i;
155 break;
156 }
157 }
158 if (existing >= 0) {
159 myPrecomputed = myAlternatives[existing];
160 } else {
161 RGBColor* col = myAlternatives[0]->getColor() != nullptr ? new RGBColor(*myAlternatives[0]->getColor()) : nullptr;
162 myPrecomputed = std::make_shared<RORoute>(myID, 0, 1, edges, col, myAlternatives[0]->getStops());
163 myNewRoute = true;
164 }
165 }
166 }
167}
168
169
170bool
172 SUMOTime begin, const ROVehicle& veh,
173 ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges,
174 bool isTrip) const {
175 MsgHandler* mh = (OptionsCont::getOptions().getBool("ignore-errors") ?
177 RONet* net = RONet::getInstance();
178 const int initialSize = (int)oldEdges.size();
179 const bool hasRestrictions = RONet::getInstance()->hasParamRestrictions();
180 if (net->hasProhibitions() && router.supportsProhibitions()) {
181 if (net->getProhibitions().size() > 0 && !router.hasProhibitions()) {
182 router.prohibit(net->getProhibitions());
183 }
184 net->updateLaneProhibitions(begin);
185 }
186 if (initialSize == 1) {
187 if (myUsingJTRR) {
189 bool ok = router.compute(oldEdges.front(), nullptr, &veh, begin, newEdges);
190 myDiscardSilent = ok && newEdges.size() == 0;
191 } else {
192 newEdges = oldEdges;
193 }
194 } else {
195 if (oldEdges.front()->prohibits(&veh, hasRestrictions)) {
196 // option repair.from is in effect
197 const std::string& frontID = oldEdges.front()->getID();
198 for (ConstROEdgeVector::iterator i = oldEdges.begin(); i != oldEdges.end();) {
199 if ((*i)->prohibits(&veh, hasRestrictions) || (*i)->isInternal()) {
200 i = oldEdges.erase(i);
201 } else {
202 WRITE_MESSAGE("Changing invalid starting edge '" + frontID
203 + "' to '" + (*i)->getID() + "' for vehicle '" + veh.getID() + "'.");
204 break;
205 }
206 }
207 }
208 if (oldEdges.size() == 0) {
209 mh->inform("Could not find new starting edge for vehicle '" + veh.getID() + "'.");
210 return false;
211 }
212 if (oldEdges.back()->prohibits(&veh, hasRestrictions)) {
213 // option repair.to is in effect
214 const std::string& backID = oldEdges.back()->getID();
215 // oldEdges cannot get empty here, otherwise we would have left the stage when checking "from"
216 while (oldEdges.back()->prohibits(&veh, hasRestrictions) || oldEdges.back()->isInternal()) {
217 oldEdges.pop_back();
218 }
219 WRITE_MESSAGE("Changing invalid destination edge '" + backID
220 + "' to edge '" + oldEdges.back()->getID() + "' for vehicle '" + veh.getID() + "'.");
221 }
222 std::vector<ROVehicle::Mandatory> mandatory = veh.getMandatoryEdges(oldEdges.front(), oldEdges.back());
223 assert(mandatory.size() >= 2);
224 // removed prohibited
225 for (ConstROEdgeVector::iterator i = oldEdges.begin(); i != oldEdges.end();) {
226 if ((*i)->prohibits(&veh, hasRestrictions) || (*i)->isInternal()) {
227 // no need to check the mandatories here, this was done before
228 WRITE_MESSAGEF(TL("Removing invalid edge '%' from route for vehicle '%'."), (*i)->getID(), veh.getID());
229 i = oldEdges.erase(i);
230 } else {
231 ++i;
232 }
233 }
234 // reconnect remaining edges
235 if (mandatory.size() > oldEdges.size() && initialSize > 2) {
236 WRITE_MESSAGEF(TL("There are stop edges which were not part of the original route for vehicle '%'."), veh.getID());
237 }
238 ConstROEdgeVector targets;
239 bool checkPositions = false;
240 if (mandatory.size() >= oldEdges.size()) {
241 for (auto m : mandatory) {
242 targets.push_back(m.edge);
243 checkPositions |= m.pos >= 0;
244 }
245 } else {
246 targets = oldEdges;
247 }
248 newEdges.push_back(targets.front());
249 auto nextMandatory = mandatory.begin() + 1;
250 int lastMandatory = 0;
251 for (ConstROEdgeVector::const_iterator i = targets.begin() + 1;
252 i != targets.end() && nextMandatory != mandatory.end(); ++i) {
253 const ROEdge* prev = *(i - 1);
254 const ROEdge* cur = *i;
255 if (prev->isConnectedTo(*cur, veh.getVClass()) && (!isRailway(veh.getVClass()) || prev->getBidiEdge() != cur)) {
256 newEdges.push_back(cur);
257 } else {
258 if (initialSize > 2) {
259 // only inform if the input is (probably) not a trip
260 WRITE_MESSAGEF(TL("Edge '%' not connected to edge '%' for vehicle '%'."), (*(i - 1))->getID(), (*i)->getID(), veh.getID());
261 }
262 const ROEdge* last = newEdges.back();
263 newEdges.pop_back();
264 if (last->isTazConnector() && newEdges.size() > 1) {
265 // assume this was a viaTaz
266 last = newEdges.back();
267 newEdges.pop_back();
268 }
269 if (veh.hasJumps() && (nextMandatory - 1)->isJump) {
270 while (*i != nextMandatory->edge) {
271 ++i;
272 }
273 newEdges.push_back(last);
274 newEdges.push_back(*i);
275 //std::cout << " skipJump mIndex=" << (nextMandatory - 1 - mandatory.begin()) << " last=" << last->getID() << " next=" << (*i)->getID() << " newEdges=" << toString(newEdges) << "\n";
276 } else {
277 if (veh.getID() == "10.T0.1-13-P-j26-1.2.H.0") {
278 std::cout << " beforeRepair newEdges=" << toString(newEdges) << " last=" << last->getID() << "\n";
279 }
280
281 int numEdgesBefore = (int)newEdges.size();
282 // router.setHint(targets.begin(), i, &veh, begin);
283 if (myTryRepair && lastMandatory < (int)newEdges.size() && last != newEdges[lastMandatory]) {
285 }
286 bool ok;
287 if (checkPositions
288 && mandatory[i - targets.begin() - 1].pos >= 0
289 && mandatory[i - targets.begin()].pos >= 0) {
290 ok = router.compute(
291 last, mandatory[i - targets.begin() - 1].pos,
292 *i, mandatory[i - targets.begin()].pos,
293 &veh, begin, newEdges);
294 } else {
295 ok = router.compute(last, *i, &veh, begin, newEdges);
296 }
297 router.setMsgHandler(mh);
298 if (!ok) {
299 // backtrack: try to route from last mandatory edge to next mandatory edge
300 // XXX add option for backtracking in smaller increments
301 // (i.e. previous edge to edge after *i)
302 // we would then need to decide whether we have found a good
303 // tradeoff between faithfulness to the input data and detour-length
304 if (lastMandatory >= (int)newEdges.size() || last == newEdges[lastMandatory] || !backTrack(router, i, lastMandatory, nextMandatory->edge, newEdges, veh, begin)) {
305 mh->inform("Mandatory edge '" + (*i)->getID() + "' not reachable by vehicle '" + veh.getID() + "'.");
306 return false;
307 }
308 } else if (!myMayBeDisconnected && !isTrip && last != (*i)) {
309 double airDist = last->getToJunction()->getPosition().distanceTo(
310 (*i)->getFromJunction()->getPosition());
311 double repairDist = 0;
312 for (auto it2 = (newEdges.begin() + numEdgesBefore + 1); it2 != newEdges.end() && it2 != newEdges.end() - 1; it2++) {
313 repairDist += (*it2)->getLength();
314 }
315 const double detourFactor = repairDist / MAX2(airDist, 1.0);
316 const double detour = MAX2(0.0, repairDist - airDist);
317 const double maxDetourFactor = OptionsCont::getOptions().getFloat("repair.max-detour-factor");
318 if (detourFactor > maxDetourFactor) {
319 WRITE_MESSAGEF(" Backtracking to avoid detour of %m for gap of %m)", detour, airDist);
320 backTrack(router, i, lastMandatory, nextMandatory->edge, newEdges, veh, begin);
321 } else if (detourFactor > 1.1) {
322 WRITE_MESSAGEF(" Taking detour of %m to avoid gap of %m)", detour, airDist);
323 }
324 }
325 if (veh.getID() == "10.T0.1-13-P-j26-1.2.H.0") {
326 std::cout << " at=" << numEdgesBefore << " before=" << numEdgesBefore << " after=" << newEdges.size() << " new=" << toString(newEdges) << "\n";
327 }
328 }
329 }
330 if (*i == nextMandatory->edge) {
331 nextMandatory++;
332 lastMandatory = (int)newEdges.size() - 1;
333 }
334 }
335 if (veh.getParameter().via.size() > 0 && veh.getParameter().stops.size() > 0) {
336 // check consistency of stops and vias
337 auto it = newEdges.begin();
338 for (const auto& stop : veh.getParameter().stops) {
339 const ROEdge* e = net->getEdge(stop.edge);
340 it = std::find(it, newEdges.end(), e);
341 if (it == newEdges.end()) {
342 mh->inform("Stop edge '" + e->getID() + "' is inconsistent with via edges for vehicle '" + veh.getID() + "'.");
343 return false;
344 }
345 }
346 }
347 }
348 return true;
349}
350
351
352bool
354 ConstROEdgeVector::const_iterator& i, int lastMandatory, const ROEdge* nextMandatory,
355 ConstROEdgeVector& newEdges, const ROVehicle& veh, SUMOTime begin) {
356 ConstROEdgeVector edges;
357 bool ok = router.compute(newEdges[lastMandatory], nextMandatory, &veh, begin, edges, true);
358 if (!ok) {
359 return false;
360 }
361
362 while (*i != nextMandatory) {
363 ++i;
364 }
365 newEdges.erase(newEdges.begin() + lastMandatory + 1, newEdges.end());
366 std::copy(edges.begin() + 1, edges.end(), back_inserter(newEdges));
367 return true;
368}
369
370
371std::shared_ptr<RORoute>
373 const ROVehicle* const veh, std::shared_ptr<RORoute> current, SUMOTime begin,
374 MsgHandler* errorHandler) {
375 std::shared_ptr<RORoute> replaced = nullptr;
376 if (myTryRepair || myUsingJTRR) {
377 if (myNewRoute) {
378 replaced = myAlternatives[0];
379 myAlternatives[0] = current;
380 }
381 if (!router.isValid(current->getEdgeVector(), veh, STEPS2TIME(begin))) {
382 throw ProcessError("Route '" + getID() + "' (vehicle '" + veh->getID() + "') is not valid.");
383 }
384 double costs = router.recomputeCosts(current->getEdgeVector(), veh, begin);
385 if (veh->hasJumps()) {
386 // @todo: jumpTime should be applied in recomputeCost to ensure the
387 // correctness of time-dependent traveltimes
388 costs += STEPS2TIME(veh->getJumpTime());
389 }
390 current->setCosts(costs);
391 return replaced;
392 }
393 // add the route when it's new
394 if (myAlternatives.back()->getProbability() < 0 || !myAlternatives.back()->isPermitted(veh, errorHandler)) {
395 if (myAlternatives.back()->getProbability() >= 0 && errorHandler == MsgHandler::getErrorInstance()) {
396 throw ProcessError("Route '" + current->getID() + "' (vehicle '" + veh->getID() + "') is not valid.");
397 }
398 myAlternatives.pop_back();
399 }
400 if (myNewRoute) {
401 myAlternatives.push_back(current);
402 }
403 // recompute the costs and (when a new route was added) scale the probabilities
404 const double scale = double(myAlternatives.size() - 1) / double(myAlternatives.size());
405 for (const std::shared_ptr<RORoute>& alt : myAlternatives) {
406 if (!router.isValid(alt->getEdgeVector(), veh, STEPS2TIME(begin))) {
407 throw ProcessError("Route '" + current->getID() + "' (vehicle '" + veh->getID() + "') is not valid.");
408 }
409 // recompute the costs for all routes
410 const double newCosts = router.recomputeCosts(alt->getEdgeVector(), veh, begin);
411 assert(myAlternatives.size() != 0);
412 if (myNewRoute) {
413 if (alt == current) {
414 // set initial probability and costs
415 alt->setProbability(1. / (double) myAlternatives.size());
416 alt->setCosts(newCosts);
417 } else {
418 // rescale probs for all others
419 alt->setProbability(alt->getProbability() * scale);
420 }
421 }
423 }
424 assert(myAlternatives.size() != 0);
426 const bool keepRoute = RouteCostCalculator<RORoute, ROEdge, ROVehicle>::getCalculator().keepRoute();
427 if (!RouteCostCalculator<RORoute, ROEdge, ROVehicle>::getCalculator().keepAllRoutes() && !keepRoute) {
428 // remove with probability of 0 (not mentioned in Gawron)
429 for (std::vector<std::shared_ptr<RORoute>>::iterator i = myAlternatives.begin(); i != myAlternatives.end();) {
430 if ((*i)->getProbability() == 0) {
431 i = myAlternatives.erase(i);
432 } else {
433 i++;
434 }
435 }
436 }
437 int maxNumber = RouteCostCalculator<RORoute, ROEdge, ROVehicle>::getCalculator().getMaxRouteNumber();
438 if ((int)myAlternatives.size() > maxNumber) {
439 std::shared_ptr<const RORoute> last = myAlternatives[myLastUsed];
440 // only keep the routes with highest probability
441 sort(myAlternatives.begin(), myAlternatives.end(), [](const std::shared_ptr<const RORoute> a, const std::shared_ptr<const RORoute> b) {
442 return a->getProbability() > b->getProbability();
443 });
444 if (keepRoute) {
445 for (int i = 0; i < (int)myAlternatives.size(); i++) {
446 if (myAlternatives[i] == last) {
447 myLastUsed = i;
448 break;
449 }
450 }
451 if (myLastUsed >= maxNumber) {
453 myLastUsed = maxNumber - 1;
454 }
455 }
456 myAlternatives.erase(myAlternatives.begin() + maxNumber, myAlternatives.end());
457 }
458 // rescale probabilities
459 double newSum = 0.;
460 for (const std::shared_ptr<RORoute>& alt : myAlternatives) {
461 newSum += alt->getProbability();
462 }
463 assert(newSum > 0);
464 // @note newSum may be larger than 1 for numerical reasons
465 for (const std::shared_ptr<RORoute>& alt : myAlternatives) {
466 alt->setProbability(alt->getProbability() / newSum);
467 }
468
469 // find the route to use
470 if (!keepRoute) {
471 double chosen = RandHelper::rand();
472 myLastUsed = 0;
473 for (const std::shared_ptr<RORoute>& alt : myAlternatives) {
474 chosen -= alt->getProbability();
475 if (chosen <= 0) {
476 return nullptr;
477 }
478 myLastUsed++;
479 }
480 }
481 return nullptr;
482}
483
484
485const ROEdge*
487 return myAlternatives.back()->getFirst();
488}
489
490
491const ROEdge*
493 return myAlternatives.back()->getLast();
494}
495
496
499 bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const {
500 if (asAlternatives) {
502 for (int i = 0; i != (int)myAlternatives.size(); i++) {
503 myAlternatives[i]->writeXMLDefinition(dev, veh, true, true, withExitTimes, withLength);
504 }
505 dev.closeTag();
506 return dev;
507 } else {
508 return myAlternatives[myLastUsed]->writeXMLDefinition(dev, veh, withCost, false, withExitTimes, withLength);
509 }
510}
511
512
514RORouteDef::copy(const std::string& id, const SUMOTime stopOffset) const {
516 for (const std::shared_ptr<const RORoute> route : myAlternatives) {
517 RGBColor* col = route->getColor() != nullptr ? new RGBColor(*route->getColor()) : nullptr;
518 std::shared_ptr<RORoute> newRoute = std::make_shared<RORoute>(id, route->getCosts(), route->getProbability(), route->getEdgeVector(), col, route->getStops());
519 newRoute->addStopOffset(stopOffset);
520 result->addLoadedAlternative(newRoute);
521 }
522 return result;
523}
524
525
526double
528 double sum = 0.;
529 for (const std::shared_ptr<const RORoute> r : myAlternatives) {
530 sum += r->getProbability();
531 }
532 return sum;
533}
534
535
536/****************************************************************************/
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
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Base class for objects which have an id.
Definition Named.h:54
std::string myID
The name of the object.
Definition Named.h:125
const std::string & getID() const
Returns the id.
Definition Named.h:74
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)
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:1008
bool hasProhibitions() const
Definition RONet.h:466
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:470
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()
void setMsgHandler(MsgHandler *const errorMsgHandler)
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
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:40
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