Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RORouteDef.h
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#pragma once
23#include <config.h>
24
25#include <string>
26#include <iostream>
27#include <utils/common/Named.h>
29#include "RORoute.h"
30
31
32// ===========================================================================
33// class declarations
34// ===========================================================================
35class ROEdge;
36class OptionsCont;
37class ROVehicle;
38class OutputDevice;
39
40
41// ===========================================================================
42// class definitions
43// ===========================================================================
53class RORouteDef : public Named {
54public:
60 RORouteDef(const std::string& id, const int lastUsed,
61 const bool tryRepair, const bool mayBeDisconnected);
62
63
65 virtual ~RORouteDef();
66
67
70 void addLoadedAlternative(RORoute* alternative);
71
73 void addAlternativeDef(const RORouteDef* alternative);
74
76 void validateAlternatives(const ROVehicle* veh, MsgHandler* errorHandler);
77
81 const ROVehicle& veh) const;
82
86 const ROVehicle& veh) const;
87
91 const ROVehicle& veh, ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges,
92 bool isTrip = false) const;
93
98 const ROVehicle* const, RORoute* current, SUMOTime begin,
99 MsgHandler* errorHandler);
100
101 const ROEdge* getOrigin() const;
102 const ROEdge* getDestination() const;
103
104 const RORoute* getFirstRoute() const {
105 if (myAlternatives.empty()) {
106 return 0;
107 }
108 return myAlternatives.front();
109 }
110
111 const RORoute* getUsedRoute() const {
113 }
114
124 bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const;
125
126
136 RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
137
139 double getOverallProb() const;
140
141
143 bool discardSilent() const {
144 return myDiscardSilent;
145 }
146
147
148 static void setUsingJTRR() {
149 myUsingJTRR = true;
150 }
151
152 static void setSkipNew() {
153 mySkipNewRoutes = true;
154 }
155
156protected:
159 ConstROEdgeVector::const_iterator& i, int lastMandatory, ConstROEdgeVector::iterator nextMandatory,
160 ConstROEdgeVector& newEdges, const ROVehicle& veh, SUMOTime begin);
161
162protected:
165
167 mutable int myLastUsed;
168
170 std::vector<RORoute*> myAlternatives;
171
173 std::set<RORoute*> myRouteRefs;
174
176 mutable bool myNewRoute;
177
178 const bool myTryRepair;
180
182 mutable bool myDiscardSilent;
183
184 static bool myUsingJTRR;
185 static bool mySkipNewRoutes;
186
187private:
189 RORouteDef(const RORouteDef& src) = delete;
190
192 RORouteDef& operator=(const RORouteDef& src) = delete;
193
194};
long long int SUMOTime
Definition GUI.h:36
std::vector< const ROEdge * > ConstROEdgeVector
Definition ROEdge.h:57
Base class for objects which have an id.
Definition Named.h:54
A storage for options typed value containers)
Definition OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
A basic edge for routing applications.
Definition ROEdge.h:73
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)
static void setSkipNew()
Definition RORouteDef.h:152
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition RORouteDef.h:164
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
const RORoute * getFirstRoute() const
Definition RORouteDef.h:104
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
std::vector< RORoute * > myAlternatives
The alternatives.
Definition RORouteDef.h:170
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:179
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
static void setUsingJTRR()
Definition RORouteDef.h:148
virtual ~RORouteDef()
Destructor.
bool myDiscardSilent
Whether this route should be silently discarded.
Definition RORouteDef.h:182
RORouteDef & operator=(const RORouteDef &src)=delete
Invalidated assignment operator.
RORouteDef(const RORouteDef &src)=delete
Invalidated copy constructor.
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:184
bool myNewRoute
Information whether a new route was generated.
Definition RORouteDef.h:176
const RORoute * getUsedRoute() const
Definition RORouteDef.h:111
const bool myTryRepair
Definition RORouteDef.h:178
int myLastUsed
Index of the route used within the last step.
Definition RORouteDef.h:167
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition RORouteDef.h:173
static bool mySkipNewRoutes
Definition RORouteDef.h:185
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
bool discardSilent() const
whether this route shall be silently discarded
Definition RORouteDef.h:143
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
A vehicle as used by router.
Definition ROVehicle.h:50