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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Base class for a vehicle's route definition
18 /****************************************************************************/
19 #ifndef RORouteDef_h
20 #define RORouteDef_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <iostream>
30 #include <utils/common/Named.h>
32 #include "RORoute.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class ROEdge;
39 class OptionsCont;
40 class ROVehicle;
41 class OutputDevice;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
56 class RORouteDef : public Named {
57 public:
63  RORouteDef(const std::string& id, const int lastUsed,
64  const bool tryRepair, const bool mayBeDisconnected);
65 
66 
68  virtual ~RORouteDef();
69 
70 
73  void addLoadedAlternative(RORoute* alternative);
74 
76  void addAlternativeDef(const RORouteDef* alternative);
77 
81  const ROVehicle& veh) const;
82 
86  const ROVehicle& veh) const;
87 
91  const ROVehicle& veh, ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges) const;
92 
97  const ROVehicle* const, RORoute* current, SUMOTime begin);
98 
99  const ROEdge* getDestination() const;
100 
101  const RORoute* getFirstRoute() const {
102  if (myAlternatives.empty()) {
103  return 0;
104  }
105  return myAlternatives.front();
106  }
107 
116  OutputDevice& writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,
117  bool asAlternatives, bool withExitTimes) const;
118 
127  RORouteDef* copyOrigDest(const std::string& id) const;
128 
138  RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
139 
141  double getOverallProb() const;
142 
143  static void setUsingJTRR() {
144  myUsingJTRR = true;
145  }
146 
147 protected:
150 
152  mutable int myLastUsed;
153 
155  std::vector<RORoute*> myAlternatives;
156 
158  std::set<RORoute*> myRouteRefs;
159 
161  mutable bool myNewRoute;
162 
163  const bool myTryRepair;
165 
166  static bool myUsingJTRR;
167 
168 private:
171  bool operator()(const RORoute* const a, const RORoute* const b) {
172  return a->getProbability() > b->getProbability();
173  }
174  };
175 
176 private:
178  RORouteDef(const RORouteDef& src);
179 
181  RORouteDef& operator=(const RORouteDef& src);
182 
183 };
184 
185 
186 #endif
187 
188 /****************************************************************************/
189 
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:384
int myLastUsed
Index of the route used within the last step.
Definition: RORouteDef.h:152
bool myNewRoute
Information whether a new route was generated.
Definition: RORouteDef.h:161
long long int SUMOTime
Definition: SUMOTime.h:36
const bool myTryRepair
Definition: RORouteDef.h:163
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes) const
Saves the built route / route alternatives.
Definition: RORouteDef.cpp:355
const ROEdge * getDestination() const
Definition: RORouteDef.cpp:349
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
Definition: RORouteDef.cpp:262
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:75
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:101
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:162
RORouteDef * copyOrigDest(const std::string &id) const
Returns a origin-destination copy of the route definition.
Definition: RORouteDef.cpp:371
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:56
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:166
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:398
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
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition: RORouteDef.h:149
const bool myMayBeDisconnected
Definition: RORouteDef.h:164
A vehicle as used by router.
Definition: ROVehicle.h:53
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition: RORouteDef.h:158
double getProbability() const
Returns the probability the driver will take this route with.
Definition: RORoute.h:123
RORouteDef(const std::string &id, const int lastUsed, const bool tryRepair, const bool mayBeDisconnected)
Constructor.
Definition: RORouteDef.cpp:52
A basic edge for routing applications.
Definition: ROEdge.h:72
Base class for objects which have an id.
Definition: Named.h:58
virtual ~RORouteDef()
Destructor.
Definition: RORouteDef.cpp:59
bool operator()(const RORoute *const a, const RORoute *const b)
Definition: RORouteDef.h:171
static void setUsingJTRR()
Definition: RORouteDef.h:143
A storage for options typed value containers)
Definition: OptionsCont.h:92
Base class for a vehicle&#39;s route definition.
Definition: RORouteDef.h:56
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA...
Definition: RORouteDef.cpp:69
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
RORouteDef & operator=(const RORouteDef &src)
Invalidated assignment operator.
std::vector< RORoute * > myAlternatives
The alternatives.
Definition: RORouteDef.h:155
A complete router&#39;s route.
Definition: RORoute.h:55