Eclipse SUMO - Simulation of Urban MObility
RORouteDef.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2020 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 // ===========================================================================
35 class ROEdge;
36 class OptionsCont;
37 class ROVehicle;
38 class OutputDevice;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
53 class RORouteDef : public Named {
54 public:
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) const;
89 
94  const ROVehicle* const, RORoute* current, SUMOTime begin);
95 
96  const ROEdge* getDestination() const;
97 
98  const RORoute* getFirstRoute() const {
99  if (myAlternatives.empty()) {
100  return 0;
101  }
102  return myAlternatives.front();
103  }
104 
113  OutputDevice& writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,
114  bool asAlternatives, bool withExitTimes) const;
115 
124  RORouteDef* copyOrigDest(const std::string& id) const;
125 
135  RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
136 
138  double getOverallProb() const;
139 
140 
142  bool discardSilent() const {
143  return myDiscardSilent;
144  }
145 
146 
147  static void setUsingJTRR() {
148  myUsingJTRR = true;
149  }
150 
151 protected:
154 
156  mutable int myLastUsed;
157 
159  std::vector<RORoute*> myAlternatives;
160 
162  std::set<RORoute*> myRouteRefs;
163 
165  mutable bool myNewRoute;
166 
167  const bool myTryRepair;
169 
171  mutable bool myDiscardSilent;
172 
173  static bool myUsingJTRR;
174 
175 private:
178  bool operator()(const RORoute* const a, const RORoute* const b) {
179  return a->getProbability() > b->getProbability();
180  }
181  };
182 
183 private:
185  RORouteDef(const RORouteDef& src);
186 
189 
190 };
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:54
long long int SUMOTime
Definition: SUMOTime.h:31
Base class for objects which have an id.
Definition: Named.h:53
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
A basic edge for routing applications.
Definition: ROEdge.h:70
Base class for a vehicle's route definition.
Definition: RORouteDef.h:53
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition: RORouteDef.h:153
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
Definition: RORouteDef.cpp:69
RORouteDef(const std::string &id, const int lastUsed, const bool tryRepair, const bool mayBeDisconnected)
Constructor.
Definition: RORouteDef.cpp:50
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:406
std::vector< RORoute * > myAlternatives
The alternatives.
Definition: RORouteDef.h:159
RORouteDef(const RORouteDef &src)
Invalidated copy constructor.
RORoute * buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route.
Definition: RORouteDef.cpp:84
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:98
const bool myMayBeDisconnected
Definition: RORouteDef.h:168
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:75
static void setUsingJTRR()
Definition: RORouteDef.h:147
virtual ~RORouteDef()
Destructor.
Definition: RORouteDef.cpp:59
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes) const
Saves the built route / route alternatives.
Definition: RORouteDef.cpp:363
bool myDiscardSilent
Whether this route should be silently discarded.
Definition: RORouteDef.h:171
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)
Definition: RORouteDef.cpp:94
static bool myUsingJTRR
Definition: RORouteDef.h:173
bool myNewRoute
Information whether a new route was generated.
Definition: RORouteDef.h:165
RORouteDef * copyOrigDest(const std::string &id) const
Returns a origin-destination copy of the route definition.
Definition: RORouteDef.cpp:379
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
Definition: RORouteDef.cpp:270
const bool myTryRepair
Definition: RORouteDef.h:167
int myLastUsed
Index of the route used within the last step.
Definition: RORouteDef.h:156
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition: RORouteDef.h:162
const ROEdge * getDestination() const
Definition: RORouteDef.cpp:357
RORouteDef & operator=(const RORouteDef &src)
Invalidated assignment operator.
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:392
bool repairCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh, ConstROEdgeVector oldEdges, ConstROEdgeVector &newEdges) const
Builds the complete route (or chooses her from the list of alternatives, when existing)
Definition: RORouteDef.cpp:164
bool discardSilent() const
whether this route shall be silently discarded
Definition: RORouteDef.h:142
A complete router's route.
Definition: RORoute.h:52
double getProbability() const
Returns the probability the driver will take this route with.
Definition: RORoute.h:120
A vehicle as used by router.
Definition: ROVehicle.h:50
bool operator()(const RORoute *const a, const RORoute *const b)
Definition: RORouteDef.h:178