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
78 const ROVehicle& veh) const;
79
83 const ROVehicle& veh) const;
84
88 const ROVehicle& veh, ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges,
89 bool isTrip = false) const;
90
95 const ROVehicle* const, RORoute* current, SUMOTime begin);
96
97 const ROEdge* getOrigin() const;
98 const ROEdge* getDestination() const;
99
100 const RORoute* getFirstRoute() const {
101 if (myAlternatives.empty()) {
102 return 0;
103 }
104 return myAlternatives.front();
105 }
106
107 const RORoute* getUsedRoute() const {
109 }
110
120 bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const;
121
122
132 RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
133
135 double getOverallProb() const;
136
137
139 bool discardSilent() const {
140 return myDiscardSilent;
141 }
142
143
144 static void setUsingJTRR() {
145 myUsingJTRR = true;
146 }
147
148protected:
151 ConstROEdgeVector::const_iterator& i, int lastMandatory, ConstROEdgeVector::iterator nextMandatory,
152 ConstROEdgeVector& newEdges, const ROVehicle& veh, SUMOTime begin);
153
154protected:
157
159 mutable int myLastUsed;
160
162 std::vector<RORoute*> myAlternatives;
163
165 std::set<RORoute*> myRouteRefs;
166
168 mutable bool myNewRoute;
169
170 const bool myTryRepair;
172
174 mutable bool myDiscardSilent;
175
176 static bool myUsingJTRR;
177
178private:
180 RORouteDef(const RORouteDef& src) = delete;
181
183 RORouteDef& operator=(const RORouteDef& src) = delete;
184
185};
long long int SUMOTime
Definition GUI.h:36
std::vector< const ROEdge * > ConstROEdgeVector
Definition ROEdge.h:56
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:72
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:156
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:100
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
std::vector< RORoute * > myAlternatives
The alternatives.
Definition RORouteDef.h:162
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:171
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
static void setUsingJTRR()
Definition RORouteDef.h:144
virtual ~RORouteDef()
Destructor.
bool myDiscardSilent
Whether this route should be silently discarded.
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:176
bool myNewRoute
Information whether a new route was generated.
Definition RORouteDef.h:168
const RORoute * getUsedRoute() const
Definition RORouteDef.h:107
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
const bool myTryRepair
Definition RORouteDef.h:170
int myLastUsed
Index of the route used within the last step.
Definition RORouteDef.h:159
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition RORouteDef.h:165
const ROEdge * getDestination() const
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
bool discardSilent() const
whether this route shall be silently discarded
Definition RORouteDef.h:139
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