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-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#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
99 const ROVehicle* const, RORoute* current, SUMOTime begin,
100 MsgHandler* errorHandler);
101
102 const ROEdge* getOrigin() const;
103 const ROEdge* getDestination() const;
104
105 const RORoute* getFirstRoute() const {
106 if (myAlternatives.empty()) {
107 return 0;
108 }
109 return myAlternatives.front();
110 }
111
112 const RORoute* getUsedRoute() const {
114 }
115
125 bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const;
126
127
137 RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
138
140 double getOverallProb() const;
141
142
144 bool discardSilent() const {
145 return myDiscardSilent;
146 }
147
148
149 static void setUsingJTRR() {
150 myUsingJTRR = true;
151 }
152
153 static void setSkipNew() {
154 mySkipNewRoutes = true;
155 }
156
157protected:
160 ConstROEdgeVector::const_iterator& i, int lastMandatory, const ROEdge* nextMandatory,
161 ConstROEdgeVector& newEdges, const ROVehicle& veh, SUMOTime begin);
162
163protected:
166
168 mutable int myLastUsed;
169
171 std::vector<RORoute*> myAlternatives;
172
174 std::set<RORoute*> myRouteRefs;
175
177 mutable bool myNewRoute;
178
179 const bool myTryRepair;
181
183 mutable bool myDiscardSilent;
184
185 static bool myUsingJTRR;
186 static bool mySkipNewRoutes;
187
188private:
190 RORouteDef(const RORouteDef& src) = delete;
191
193 RORouteDef& operator=(const RORouteDef& src) = delete;
194
195};
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:153
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
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition RORouteDef.h:165
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
RORoute * addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin, MsgHandler *errorHandler)
Adds an alternative to the list of routes and returns the route that was replaced or nullptr.
const RORoute * getFirstRoute() const
Definition RORouteDef.h:105
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
std::vector< RORoute * > myAlternatives
The alternatives.
Definition RORouteDef.h:171
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:180
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
static void setUsingJTRR()
Definition RORouteDef.h:149
virtual ~RORouteDef()
Destructor.
bool myDiscardSilent
Whether this route should be silently discarded.
Definition RORouteDef.h:183
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:185
bool myNewRoute
Information whether a new route was generated.
Definition RORouteDef.h:177
const RORoute * getUsedRoute() const
Definition RORouteDef.h:112
const bool myTryRepair
Definition RORouteDef.h:179
int myLastUsed
Index of the route used within the last step.
Definition RORouteDef.h:168
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition RORouteDef.h:174
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
bool discardSilent() const
whether this route shall be silently discarded
Definition RORouteDef.h:144
A complete router's route.
Definition RORoute.h:52
A vehicle as used by router.
Definition ROVehicle.h:51