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-2019 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::addAlternative
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
Definition: RORouteDef.cpp:264
RORoute::getProbability
double getProbability() const
Returns the probability the driver will take this route with.
Definition: RORoute.h:123
RORouteDef::buildCurrentRoute
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
RORouteDef::myTryRepair
const bool myTryRepair
Definition: RORouteDef.h:163
Named
Base class for objects which have an id.
Definition: Named.h:57
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
RORouteDef::addAlternativeDef
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:75
RORouteDef::getFirstRoute
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:101
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
RORouteDef
Base class for a vehicle's route definition.
Definition: RORouteDef.h:56
ROVehicle
A vehicle as used by router.
Definition: ROVehicle.h:53
RORouteDef::operator=
RORouteDef & operator=(const RORouteDef &src)
Invalidated assignment operator.
RORoute.h
RORouteDef::getOverallProb
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:400
RORouteDef::preComputeCurrentRoute
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
Named.h
RORouteDef::writeXMLDefinition
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes) const
Saves the built route / route alternatives.
Definition: RORouteDef.cpp:357
RORouteDef::myRouteRefs
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition: RORouteDef.h:158
RORoute
A complete router's route.
Definition: RORoute.h:55
RORouteDef::myNewRoute
bool myNewRoute
Information whether a new route was generated.
Definition: RORouteDef.h:161
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
RORouteDef::myMayBeDisconnected
const bool myMayBeDisconnected
Definition: RORouteDef.h:164
RORouteDef::myLastUsed
int myLastUsed
Index of the route used within the last step.
Definition: RORouteDef.h:152
RORouteDef::myPrecomputed
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition: RORouteDef.h:149
RORouteDef::addLoadedAlternative
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
Definition: RORouteDef.cpp:69
SUMOAbstractRouter< ROEdge, ROVehicle >
RORouteDef::ComparatorProbability
Definition: RORouteDef.h:170
RORouteDef::getDestination
const ROEdge * getDestination() const
Definition: RORouteDef.cpp:351
RORouteDef::ComparatorProbability::operator()
bool operator()(const RORoute *const a, const RORoute *const b)
Definition: RORouteDef.h:171
ROEdge
A basic edge for routing applications.
Definition: ROEdge.h:73
RORouteDef::~RORouteDef
virtual ~RORouteDef()
Destructor.
Definition: RORouteDef.cpp:59
RORouteDef::copyOrigDest
RORouteDef * copyOrigDest(const std::string &id) const
Returns a origin-destination copy of the route definition.
Definition: RORouteDef.cpp:373
config.h
RORouteDef::copy
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:386
SUMOAbstractRouter.h
RORouteDef::RORouteDef
RORouteDef(const std::string &id, const int lastUsed, const bool tryRepair, const bool mayBeDisconnected)
Constructor.
Definition: RORouteDef.cpp:52
RORouteDef::myUsingJTRR
static bool myUsingJTRR
Definition: RORouteDef.h:166
RORouteDef::setUsingJTRR
static void setUsingJTRR()
Definition: RORouteDef.h:143
ConstROEdgeVector
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:57
RORouteDef::repairCurrentRoute
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
RORouteDef::myAlternatives
std::vector< RORoute * > myAlternatives
The alternatives.
Definition: RORouteDef.h:155