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-2025 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);
46
47// ===========================================================================
48// method definitions
49// ===========================================================================
50RORouteDef::RORouteDef(const std::string& id, const int lastUsed,
51 const bool tryRepair, const bool mayBeDisconnected) :
52 Named(StringUtils::convertUmlaute(id)),
53 myPrecomputed(nullptr), myLastUsed(lastUsed), myTryRepair(tryRepair),
54 myMayBeDisconnected(mayBeDisconnected),
55 myDiscardSilent(false) {
56}
57
58
60 for (std::vector<RORoute*>::iterator i = myAlternatives.begin(); i != myAlternatives.end(); i++) {
61 if (myRouteRefs.count(*i) == 0) {
62 delete *i;
63 }
64 }
65}
66
67
68void
72
73
74void
76 std::copy(alt->myAlternatives.begin(), alt->myAlternatives.end(),
77 back_inserter(myAlternatives));
78 std::copy(alt->myAlternatives.begin(), alt->myAlternatives.end(),
79 std::inserter(myRouteRefs, myRouteRefs.end()));
80}
81
82
85 SUMOTime begin, const ROVehicle& veh) const {
86 if (myPrecomputed == nullptr) {
87 preComputeCurrentRoute(router, begin, veh);
88 }
89 return myPrecomputed;
90}
91
92
93void
95 for (int i = 0; i < (int)myAlternatives.size();) {
96 if (i != myLastUsed) {
97 if (myAlternatives[i]->isPermitted(veh, errorHandler)) {
98 i++;
99 } else {
100 myAlternatives.erase(myAlternatives.begin() + i);
101 if (myLastUsed > i) {
102 myLastUsed--;
103 }
104 }
105 } else {
106 i++;
107 }
108 }
109}
110
111
112void
114 SUMOTime begin, const ROVehicle& veh) const {
115 myNewRoute = false;
117 const bool ignoreErrors = oc.getBool("ignore-errors");
118 assert(myAlternatives[0]->getEdgeVector().size() > 0);
120 if (myAlternatives[0]->getFirst()->prohibits(&veh) && (!oc.getBool("repair.from")
121 // do not try to reassign starting edge for trip input
122 || myMayBeDisconnected || myAlternatives[0]->getEdgeVector().size() < 2)) {
123 mh->inform("Vehicle '" + veh.getID() + "' is not allowed to depart on edge '" +
124 myAlternatives[0]->getFirst()->getID() + "'.");
125 return;
126 } else if (myAlternatives[0]->getLast()->prohibits(&veh) && (!oc.getBool("repair.to")
127 // do not try to reassign destination edge for trip input
128 || myMayBeDisconnected || myAlternatives[0]->getEdgeVector().size() < 2)) {
129 // this check is not strictly necessary unless myTryRepair is set.
130 // However, the error message is more helpful than "no connection found"
131 mh->inform("Vehicle '" + veh.getID() + "' is not allowed to arrive on edge '" +
132 myAlternatives[0]->getLast()->getID() + "'.");
133 return;
134 }
135 const bool skipTripRouting = (oc.exists("write-trips") && oc.getBool("write-trips")
137 if ((myTryRepair && !skipTripRouting) || myUsingJTRR) {
138 ConstROEdgeVector newEdges;
139 if (repairCurrentRoute(router, begin, veh, myAlternatives[0]->getEdgeVector(), newEdges)) {
140 if (myAlternatives[0]->getEdgeVector() != newEdges) {
141 if (!myMayBeDisconnected) {
142 WRITE_WARNINGF(TL("Repaired route of vehicle '%'."), veh.getID());
143 }
144 myNewRoute = true;
145 RGBColor* col = myAlternatives[0]->getColor() != nullptr ? new RGBColor(*myAlternatives[0]->getColor()) : nullptr;
146 myPrecomputed = new RORoute(myID, 0, myAlternatives[0]->getProbability(), newEdges, col, myAlternatives[0]->getStops());
147 } else {
149 }
150 }
151 return;
152 }
154 || OptionsCont::getOptions().getBool("remove-loops"))
155 && (skipTripRouting || myAlternatives[myLastUsed]->isValid(veh, ignoreErrors))) {
157 } else {
158 // build a new route to test whether it is better
160 ConstROEdgeVector edges;
161 if (repairCurrentRoute(router, begin, veh, oldEdges, edges, true)) {
162 if (edges.front()->isTazConnector()) {
163 edges.erase(edges.begin());
164 }
165 if (edges.back()->isTazConnector()) {
166 edges.pop_back();
167 }
168 // check whether the same route was already used
169 int existing = -1;
170 for (int i = 0; i < (int)myAlternatives.size(); i++) {
171 if (edges == myAlternatives[i]->getEdgeVector()) {
172 existing = i;
173 break;
174 }
175 }
176 if (existing >= 0) {
177 myPrecomputed = myAlternatives[existing];
178 } else {
179 RGBColor* col = myAlternatives[0]->getColor() != nullptr ? new RGBColor(*myAlternatives[0]->getColor()) : nullptr;
180 myPrecomputed = new RORoute(myID, 0, 1, edges, col, myAlternatives[0]->getStops());
181 myNewRoute = true;
182 }
183 }
184 }
185}
186
187
188bool
190 SUMOTime begin, const ROVehicle& veh,
191 ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges,
192 bool isTrip) const {
193 MsgHandler* mh = (OptionsCont::getOptions().getBool("ignore-errors") ?
195 const int initialSize = (int)oldEdges.size();
196 if (initialSize == 1) {
197 if (myUsingJTRR) {
199 bool ok = router.compute(oldEdges.front(), nullptr, &veh, begin, newEdges);
200 myDiscardSilent = ok && newEdges.size() == 0;
201 } else {
202 newEdges = oldEdges;
203 }
204 } else {
205 if (oldEdges.front()->prohibits(&veh)) {
206 // option repair.from is in effect
207 const std::string& frontID = oldEdges.front()->getID();
208 for (ConstROEdgeVector::iterator i = oldEdges.begin(); i != oldEdges.end();) {
209 if ((*i)->prohibits(&veh) || (*i)->isInternal()) {
210 i = oldEdges.erase(i);
211 } else {
212 WRITE_MESSAGE("Changing invalid starting edge '" + frontID
213 + "' to '" + (*i)->getID() + "' for vehicle '" + veh.getID() + "'.");
214 break;
215 }
216 }
217 }
218 if (oldEdges.size() == 0) {
219 mh->inform("Could not find new starting edge for vehicle '" + veh.getID() + "'.");
220 return false;
221 }
222 if (oldEdges.back()->prohibits(&veh)) {
223 // option repair.to is in effect
224 const std::string& backID = oldEdges.back()->getID();
225 // oldEdges cannot get empty here, otherwise we would have left the stage when checking "from"
226 while (oldEdges.back()->prohibits(&veh) || oldEdges.back()->isInternal()) {
227 oldEdges.pop_back();
228 }
229 WRITE_MESSAGE("Changing invalid destination edge '" + backID
230 + "' to edge '" + oldEdges.back()->getID() + "' for vehicle '" + veh.getID() + "'.");
231 }
232 ConstROEdgeVector mandatory = veh.getMandatoryEdges(oldEdges.front(), oldEdges.back());
233 std::set<ConstROEdgeVector::const_iterator> jumpStarts;
234 veh.collectJumps(mandatory, jumpStarts);
235 assert(mandatory.size() >= 2);
236 // removed prohibited
237 for (ConstROEdgeVector::iterator i = oldEdges.begin(); i != oldEdges.end();) {
238 if ((*i)->prohibits(&veh) || (*i)->isInternal()) {
239 // no need to check the mandatories here, this was done before
240 WRITE_MESSAGEF(TL("Removing invalid edge '%' from route for vehicle '%'."), (*i)->getID(), veh.getID());
241 i = oldEdges.erase(i);
242 } else {
243 ++i;
244 }
245 }
246 // reconnect remaining edges
247 if (mandatory.size() > oldEdges.size() && initialSize > 2) {
248 WRITE_MESSAGEF(TL("There are stop edges which were not part of the original route for vehicle '%'."), veh.getID());
249 }
250 const ConstROEdgeVector& targets = mandatory.size() > oldEdges.size() ? mandatory : oldEdges;
251 newEdges.push_back(targets.front());
252 ConstROEdgeVector::iterator nextMandatory = mandatory.begin() + 1;
253 int lastMandatory = 0;
254 for (ConstROEdgeVector::const_iterator i = targets.begin() + 1;
255 i != targets.end() && nextMandatory != mandatory.end(); ++i) {
256 const ROEdge* prev = *(i - 1);
257 const ROEdge* cur = *i;
258 if (prev->isConnectedTo(*cur, veh.getVClass()) && (!isRailway(veh.getVClass()) || prev->getBidiEdge() != cur)) {
259 newEdges.push_back(cur);
260 } else {
261 if (initialSize > 2) {
262 // only inform if the input is (probably) not a trip
263 WRITE_MESSAGEF(TL("Edge '%' not connected to edge '%' for vehicle '%'."), (*(i - 1))->getID(), (*i)->getID(), veh.getID());
264 }
265 const ROEdge* last = newEdges.back();
266 newEdges.pop_back();
267 if (last->isTazConnector() && newEdges.size() > 1) {
268 // assume this was a viaTaz
269 last = newEdges.back();
270 newEdges.pop_back();
271 }
272 if (veh.hasJumps() && jumpStarts.count(nextMandatory - 1) != 0) {
273 while (*i != *nextMandatory) {
274 ++i;
275 }
276 newEdges.push_back(last);
277 newEdges.push_back(*i);
278 //std::cout << " skipJump mIndex=" << (nextMandatory - 1 - mandatory.begin()) << " last=" << last->getID() << " next=" << (*i)->getID() << " newEdges=" << toString(newEdges) << "\n";
279 } else {
280
281 int numEdgesBefore = (int)newEdges.size();
282 // router.setHint(targets.begin(), i, &veh, begin);
283 if (!router.compute(last, *i, &veh, begin, newEdges)) {
284 // backtrack: try to route from last mandatory edge to next mandatory edge
285 // XXX add option for backtracking in smaller increments
286 // (i.e. previous edge to edge after *i)
287 // we would then need to decide whether we have found a good
288 // tradeoff between faithfulness to the input data and detour-length
289 if (lastMandatory >= (int)newEdges.size() || last == newEdges[lastMandatory] || !backTrack(router, i, lastMandatory, nextMandatory, newEdges, veh, begin)) {
290 mh->inform("Mandatory edge '" + (*i)->getID() + "' not reachable by vehicle '" + veh.getID() + "'.");
291 return false;
292 }
293 } else if (!myMayBeDisconnected && !isTrip && last != (*i)) {
294 double airDist = last->getToJunction()->getPosition().distanceTo(
295 (*i)->getFromJunction()->getPosition());
296 double repairDist = 0;
297 for (auto it2 = (newEdges.begin() + numEdgesBefore + 1); it2 != newEdges.end() && it2 != newEdges.end() - 1; it2++) {
298 repairDist += (*it2)->getLength();
299 }
300 const double detourFactor = repairDist / MAX2(airDist, 1.0);
301 const double detour = MAX2(0.0, repairDist - airDist);
302 const double maxDetourFactor = OptionsCont::getOptions().getFloat("repair.max-detour-factor");
303 if (detourFactor > maxDetourFactor) {
304 WRITE_MESSAGEF(" Backtracking to avoid detour of %m for gap of %m)", detour, airDist);
305 backTrack(router, i, lastMandatory, nextMandatory, newEdges, veh, begin);
306 } else if (detourFactor > 1.1) {
307 WRITE_MESSAGEF(" Taking detour of %m to avoid gap of %m)", detour, airDist);
308 }
309 }
310 }
311 }
312 if (*i == *nextMandatory) {
313 nextMandatory++;
314 lastMandatory = (int)newEdges.size() - 1;
315 }
316 }
317 }
318 return true;
319}
320
321
322bool
324 ConstROEdgeVector::const_iterator& i, int lastMandatory, ConstROEdgeVector::iterator nextMandatory,
325 ConstROEdgeVector& newEdges, const ROVehicle& veh, SUMOTime begin) {
326 ConstROEdgeVector edges;
327 bool ok = router.compute(newEdges[lastMandatory], *nextMandatory, &veh, begin, edges);
328 if (!ok) {
329 return false;
330 }
331
332 while (*i != *nextMandatory) {
333 ++i;
334 }
335 newEdges.erase(newEdges.begin() + lastMandatory + 1, newEdges.end());
336 std::copy(edges.begin() + 1, edges.end(), back_inserter(newEdges));
337 return true;
338}
339
340
341void
343 const ROVehicle* const veh, RORoute* current, SUMOTime begin,
344 MsgHandler* errorHandler) {
345 if (myTryRepair || myUsingJTRR) {
346 if (myNewRoute) {
347 delete myAlternatives[0];
348 myAlternatives[0] = current;
349 }
350 if (!router.isValid(current->getEdgeVector(), veh)) {
351 throw ProcessError("Route '" + getID() + "' (vehicle '" + veh->getID() + "') is not valid.");
352 }
353 double costs = router.recomputeCosts(current->getEdgeVector(), veh, begin);
354 if (veh->hasJumps()) {
355 // @todo: jumpTime should be applied in recomputeCost to ensure the
356 // correctness of time-dependent traveltimes
357 costs += STEPS2TIME(veh->getJumpTime());
358 }
359 current->setCosts(costs);
360 return;
361 }
362 // add the route when it's new
363 if (myAlternatives.back()->getProbability() < 0 || !myAlternatives.back()->isPermitted(veh, errorHandler)) {
364 if (myAlternatives.back()->getProbability() >= 0 && errorHandler == MsgHandler::getErrorInstance()) {
365 throw ProcessError("Route '" + current->getID() + "' (vehicle '" + veh->getID() + "') is not valid.");
366 }
367 delete myAlternatives.back();
368 myAlternatives.pop_back();
369 }
370 if (myNewRoute) {
371 myAlternatives.push_back(current);
372 }
373 // recompute the costs and (when a new route was added) scale the probabilities
374 const double scale = double(myAlternatives.size() - 1) / double(myAlternatives.size());
375 for (RORoute* const alt : myAlternatives) {
376 if (!router.isValid(alt->getEdgeVector(), veh)) {
377 throw ProcessError("Route '" + current->getID() + "' (vehicle '" + veh->getID() + "') is not valid.");
378 }
379 // recompute the costs for all routes
380 const double newCosts = router.recomputeCosts(alt->getEdgeVector(), veh, begin);
381 assert(myAlternatives.size() != 0);
382 if (myNewRoute) {
383 if (alt == current) {
384 // set initial probability and costs
385 alt->setProbability(1. / (double) myAlternatives.size());
386 alt->setCosts(newCosts);
387 } else {
388 // rescale probs for all others
389 alt->setProbability(alt->getProbability() * scale);
390 }
391 }
393 }
394 assert(myAlternatives.size() != 0);
396 const bool keepRoute = RouteCostCalculator<RORoute, ROEdge, ROVehicle>::getCalculator().keepRoute();
397 if (!RouteCostCalculator<RORoute, ROEdge, ROVehicle>::getCalculator().keepAllRoutes() && !keepRoute) {
398 // remove with probability of 0 (not mentioned in Gawron)
399 for (std::vector<RORoute*>::iterator i = myAlternatives.begin(); i != myAlternatives.end();) {
400 if ((*i)->getProbability() == 0) {
401 delete *i;
402 i = myAlternatives.erase(i);
403 } else {
404 i++;
405 }
406 }
407 }
408 int maxNumber = RouteCostCalculator<RORoute, ROEdge, ROVehicle>::getCalculator().getMaxRouteNumber();
409 if ((int)myAlternatives.size() > maxNumber) {
410 const RORoute* last = myAlternatives[myLastUsed];
411 // only keep the routes with highest probability
412 sort(myAlternatives.begin(), myAlternatives.end(), [](const RORoute * const a, const RORoute * const b) {
413 return a->getProbability() > b->getProbability();
414 });
415 if (keepRoute) {
416 for (int i = 0; i < (int)myAlternatives.size(); i++) {
417 if (myAlternatives[i] == last) {
418 myLastUsed = i;
419 break;
420 }
421 }
422 if (myLastUsed >= maxNumber) {
424 myLastUsed = maxNumber - 1;
425 }
426 }
427 for (std::vector<RORoute*>::iterator i = myAlternatives.begin() + maxNumber; i != myAlternatives.end(); i++) {
428 delete *i;
429 }
430 myAlternatives.erase(myAlternatives.begin() + maxNumber, myAlternatives.end());
431 }
432 // rescale probabilities
433 double newSum = 0.;
434 for (const RORoute* const alt : myAlternatives) {
435 newSum += alt->getProbability();
436 }
437 assert(newSum > 0);
438 // @note newSum may be larger than 1 for numerical reasons
439 for (RORoute* const alt : myAlternatives) {
440 alt->setProbability(alt->getProbability() / newSum);
441 }
442
443 // find the route to use
444 if (!keepRoute) {
445 double chosen = RandHelper::rand();
446 myLastUsed = 0;
447 for (const RORoute* const alt : myAlternatives) {
448 chosen -= alt->getProbability();
449 if (chosen <= 0) {
450 return;
451 }
452 myLastUsed++;
453 }
454 }
455}
456
457const ROEdge*
459 return myAlternatives.back()->getFirst();
460}
461
462
463const ROEdge*
465 return myAlternatives.back()->getLast();
466}
467
468
471 bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const {
472 if (asAlternatives) {
474 for (int i = 0; i != (int)myAlternatives.size(); i++) {
475 myAlternatives[i]->writeXMLDefinition(dev, veh, true, true, withExitTimes, withLength);
476 }
477 dev.closeTag();
478 return dev;
479 } else {
480 return myAlternatives[myLastUsed]->writeXMLDefinition(dev, veh, withCost, false, withExitTimes, withLength);
481 }
482}
483
484
486RORouteDef::copy(const std::string& id, const SUMOTime stopOffset) const {
488 for (const RORoute* const route : myAlternatives) {
489 RGBColor* col = route->getColor() != nullptr ? new RGBColor(*route->getColor()) : nullptr;
490 RORoute* newRoute = new RORoute(id, route->getCosts(), route->getProbability(), route->getEdgeVector(), col, route->getStops());
491 newRoute->addStopOffset(stopOffset);
492 result->addLoadedAlternative(newRoute);
493 }
494 return result;
495}
496
497
498double
500 double sum = 0.;
501 for (std::vector<RORoute*>::const_iterator i = myAlternatives.begin(); i != myAlternatives.end(); i++) {
502 sum += (*i)->getProbability();
503 }
504 return sum;
505}
506
507
508/****************************************************************************/
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:55
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.
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 & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
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:554
const RONode * getToJunction() const
Definition ROEdge.h:541
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:462
const Position & getPosition() const
Returns the position of the node.
Definition RONode.h:67
SUMOVehicleClass getVClass() const
Definition RORoutable.h:109
const std::string & getID() const
Returns the id of the routable.
Definition RORoutable.h:91
Base class for a vehicle's route definition.
Definition RORouteDef.h:53
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)
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition RORouteDef.h:160
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
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.
std::vector< RORoute * > myAlternatives
The alternatives.
Definition RORouteDef.h:166
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const
Saves the built route / route alternatives.
RORoute * buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route.
const bool myMayBeDisconnected
Definition RORouteDef.h:175
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
virtual ~RORouteDef()
Destructor.
bool myDiscardSilent
Whether this route should be silently discarded.
Definition RORouteDef.h:178
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:180
bool myNewRoute
Information whether a new route was generated.
Definition RORouteDef.h:172
const bool myTryRepair
Definition RORouteDef.h:174
int myLastUsed
Index of the route used within the last step.
Definition RORouteDef.h:163
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition RORouteDef.h:169
const ROEdge * getDestination() const
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin, MsgHandler *errorHandler)
Adds an alternative to the list of routes.
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
static bool backTrack(SUMOAbstractRouter< ROEdge, ROVehicle > &router, ConstROEdgeVector::const_iterator &i, int lastMandatory, ConstROEdgeVector::iterator nextMandatory, ConstROEdgeVector &newEdges, const ROVehicle &veh, SUMOTime begin)
backtrack to last mandatory edge and route to next mandatory
A complete router's route.
Definition RORoute.h:52
void addStopOffset(const SUMOTime offset)
Adapts the until time of all stops by the given offset.
Definition RORoute.h:196
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
Definition RORoute.h:152
void setCosts(double costs)
Sets the costs of the route.
Definition RORoute.cpp:64
A vehicle as used by router.
Definition ROVehicle.h:50
void collectJumps(const ConstROEdgeVector &mandatory, std::set< ConstROEdgeVector::const_iterator > &jumpStarts) const
collect mandatory-edge iterators that define jumps in the route
SUMOTime getJumpTime() const
Definition ROVehicle.h:129
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
Definition ROVehicle.h:92
ConstROEdgeVector getMandatoryEdges(const ROEdge *requiredStart, const ROEdge *requiredEnd) const
compute mandatory edges
bool hasJumps() const
Definition ROVehicle.h:125
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()
bool isValid(const std::vector< const E * > &edges, const V *const v) 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...
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
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