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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Base class for a vehicle's route definition
20 /****************************************************************************/
21 #ifndef RORouteDef_h
22 #define RORouteDef_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <iostream>
36 #include <utils/common/Named.h>
38 #include "RORoute.h"
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class ROEdge;
45 class OptionsCont;
46 class ROVehicle;
47 class OutputDevice;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
62 class RORouteDef : public Named {
63 public:
69  RORouteDef(const std::string& id, const int lastUsed,
70  const bool tryRepair, const bool mayBeDisconnected);
71 
72 
74  virtual ~RORouteDef();
75 
76 
79  void addLoadedAlternative(RORoute* alternative);
80 
82  void addAlternativeDef(const RORouteDef* alternative);
83 
87  const ROVehicle& veh) const;
88 
92  const ROVehicle& veh) const;
93 
97  const ROVehicle& veh, ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges) const;
98 
103  const ROVehicle* const, RORoute* current, SUMOTime begin);
104 
105  const ROEdge* getDestination() const;
106 
107  const RORoute* getFirstRoute() const {
108  if (myAlternatives.empty()) {
109  return 0;
110  }
111  return myAlternatives.front();
112  }
113 
122  OutputDevice& writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,
123  bool asAlternatives, bool withExitTimes) const;
124 
133  RORouteDef* copyOrigDest(const std::string& id) const;
134 
144  RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
145 
147  double getOverallProb() const;
148 
149  static void setUsingJTRR() {
150  myUsingJTRR = true;
151  }
152 
153 protected:
156 
158  mutable int myLastUsed;
159 
161  std::vector<RORoute*> myAlternatives;
162 
164  std::set<RORoute*> myRouteRefs;
165 
167  mutable bool myNewRoute;
168 
169  const bool myTryRepair;
171 
172  static bool myUsingJTRR;
173 
174 private:
177  bool operator()(const RORoute* const a, const RORoute* const b) {
178  return a->getProbability() > b->getProbability();
179  }
180  };
181 
182 private:
184  RORouteDef(const RORouteDef& src);
185 
187  RORouteDef& operator=(const RORouteDef& src);
188 
189 };
190 
191 
192 #endif
193 
194 /****************************************************************************/
195 
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:411
int myLastUsed
Index of the route used within the last step.
Definition: RORouteDef.h:158
bool myNewRoute
Information whether a new route was generated.
Definition: RORouteDef.h:167
const bool myTryRepair
Definition: RORouteDef.h:169
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes) const
Saves the built route / route alternatives.
Definition: RORouteDef.cpp:382
const ROEdge * getDestination() const
Definition: RORouteDef.cpp:376
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
Definition: RORouteDef.cpp:289
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:81
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:107
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:168
RORouteDef * copyOrigDest(const std::string &id) const
Returns a origin-destination copy of the route definition.
Definition: RORouteDef.cpp:398
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:62
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:100
static bool myUsingJTRR
Definition: RORouteDef.h:172
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:425
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:90
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition: RORouteDef.h:155
const bool myMayBeDisconnected
Definition: RORouteDef.h:170
A vehicle as used by router.
Definition: ROVehicle.h:59
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition: RORouteDef.h:164
double getProbability() const
Returns the probability the driver will take this route with.
Definition: RORoute.h:129
RORouteDef(const std::string &id, const int lastUsed, const bool tryRepair, const bool mayBeDisconnected)
Constructor.
Definition: RORouteDef.cpp:58
A basic edge for routing applications.
Definition: ROEdge.h:77
Base class for objects which have an id.
Definition: Named.h:54
virtual ~RORouteDef()
Destructor.
Definition: RORouteDef.cpp:65
bool operator()(const RORoute *const a, const RORoute *const b)
Definition: RORouteDef.h:177
static void setUsingJTRR()
Definition: RORouteDef.h:149
A storage for options typed value containers)
Definition: OptionsCont.h:98
Base class for a vehicle&#39;s route definition.
Definition: RORouteDef.h:62
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA...
Definition: RORouteDef.cpp:75
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
long long int SUMOTime
Definition: TraCIDefs.h:51
RORouteDef & operator=(const RORouteDef &src)
Invalidated assignment operator.
std::vector< RORoute * > myAlternatives
The alternatives.
Definition: RORouteDef.h:161
A complete router&#39;s route.
Definition: RORoute.h:61