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 <memory>
28#include <utils/common/Named.h>
30#include "RORoute.h"
31
32
33// ===========================================================================
34// class declarations
35// ===========================================================================
36class ROEdge;
37class OptionsCont;
38class ROVehicle;
39class OutputDevice;
40
41
42// ===========================================================================
43// class definitions
44// ===========================================================================
54class RORouteDef : public Named {
55public:
61 RORouteDef(const std::string& id, const int lastUsed,
62 const bool tryRepair, const bool mayBeDisconnected);
63
64
66 virtual ~RORouteDef() {}
67
68
71 void addLoadedAlternative(std::shared_ptr<RORoute> alternative) {
72 myAlternatives.push_back(alternative);
73 }
74
76 void addAlternativeDef(const RORouteDef* alternative);
77
79 void validateAlternatives(const ROVehicle* veh, MsgHandler* errorHandler);
80
83 std::shared_ptr<RORoute> buildCurrentRoute(SUMOAbstractRouter<ROEdge, ROVehicle>& router, SUMOTime begin,
84 const ROVehicle& veh) const;
85
89 const ROVehicle& veh) const;
90
94 const ROVehicle& veh, ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges,
95 bool isTrip = false) const;
96
101 std::shared_ptr<RORoute> addAlternative(SUMOAbstractRouter<ROEdge, ROVehicle>& router,
102 const ROVehicle* const, std::shared_ptr<RORoute> current, SUMOTime begin,
103 MsgHandler* errorHandler);
104
105 const ROEdge* getOrigin() const;
106 const ROEdge* getDestination() const;
107
108 std::shared_ptr<const RORoute> getFirstRoute() const {
109 if (myAlternatives.empty()) {
110 return nullptr;
111 }
112 return myAlternatives.front();
113 }
114
115 std::shared_ptr<const RORoute> getUsedRoute() const {
117 }
118
128 bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const;
129
130
140 RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
141
143 double getOverallProb() const;
144
145
147 bool discardSilent() const {
148 return myDiscardSilent;
149 }
150
151
152 static void setUsingJTRR() {
153 myUsingJTRR = true;
154 }
155
156 static void setSkipNew() {
157 mySkipNewRoutes = true;
158 }
159
160protected:
163 ConstROEdgeVector::const_iterator& i, int lastMandatory, const ROEdge* nextMandatory,
164 ConstROEdgeVector& newEdges, const ROVehicle& veh, SUMOTime begin);
165
166protected:
168 mutable std::shared_ptr<RORoute> myPrecomputed;
169
171 mutable int myLastUsed;
172
174 std::vector<std::shared_ptr<RORoute> > myAlternatives;
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: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 void setSkipNew()
Definition RORouteDef.h:156
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.
virtual ~RORouteDef()
Destructor.
Definition RORouteDef.h:66
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.
std::shared_ptr< const RORoute > getFirstRoute() const
Definition RORouteDef.h:108
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:152
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
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 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
std::shared_ptr< const RORoute > getUsedRoute() const
Definition RORouteDef.h:115
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:147
A vehicle as used by router.
Definition ROVehicle.h:51