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 /****************************************************************************/
16 // Base class for a vehicle's route definition
17 /****************************************************************************/
18 #ifndef RORouteDef_h
19 #define RORouteDef_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <iostream>
29 #include <utils/common/Named.h>
31 #include "RORoute.h"
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class ROEdge;
38 class OptionsCont;
39 class ROVehicle;
40 class OutputDevice;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
55 class RORouteDef : public Named {
56 public:
62  RORouteDef(const std::string& id, const int lastUsed,
63  const bool tryRepair, const bool mayBeDisconnected);
64 
65 
67  virtual ~RORouteDef();
68 
69 
72  void addLoadedAlternative(RORoute* alternative);
73 
75  void addAlternativeDef(const RORouteDef* alternative);
76 
80  const ROVehicle& veh) const;
81 
85  const ROVehicle& veh) const;
86 
90  const ROVehicle& veh, ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges) const;
91 
96  const ROVehicle* const, RORoute* current, SUMOTime begin);
97 
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 
115  OutputDevice& writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,
116  bool asAlternatives, bool withExitTimes) const;
117 
126  RORouteDef* copyOrigDest(const std::string& id) const;
127 
137  RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
138 
140  double getOverallProb() const;
141 
142  static void setUsingJTRR() {
143  myUsingJTRR = true;
144  }
145 
146 protected:
149 
151  mutable int myLastUsed;
152 
154  std::vector<RORoute*> myAlternatives;
155 
157  std::set<RORoute*> myRouteRefs;
158 
160  mutable bool myNewRoute;
161 
162  const bool myTryRepair;
164 
165  static bool myUsingJTRR;
166 
167 private:
170  bool operator()(const RORoute* const a, const RORoute* const b) {
171  return a->getProbability() > b->getProbability();
172  }
173  };
174 
175 private:
177  RORouteDef(const RORouteDef& src);
178 
180  RORouteDef& operator=(const RORouteDef& src);
181 
182 };
183 
184 
185 #endif
186 
187 /****************************************************************************/
188 
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:263
RORoute::getProbability
double getProbability() const
Returns the probability the driver will take this route with.
Definition: RORoute.h:122
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:83
RORouteDef::myTryRepair
const bool myTryRepair
Definition: RORouteDef.h:162
Named
Base class for objects which have an id.
Definition: Named.h:56
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
RORouteDef::addAlternativeDef
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:74
RORouteDef::getFirstRoute
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:100
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
RORouteDef
Base class for a vehicle's route definition.
Definition: RORouteDef.h:55
ROVehicle
A vehicle as used by router.
Definition: ROVehicle.h:52
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:399
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:93
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:356
RORouteDef::myRouteRefs
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition: RORouteDef.h:157
RORoute
A complete router's route.
Definition: RORoute.h:54
RORouteDef::myNewRoute
bool myNewRoute
Information whether a new route was generated.
Definition: RORouteDef.h:160
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
RORouteDef::myMayBeDisconnected
const bool myMayBeDisconnected
Definition: RORouteDef.h:163
RORouteDef::myLastUsed
int myLastUsed
Index of the route used within the last step.
Definition: RORouteDef.h:151
RORouteDef::myPrecomputed
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition: RORouteDef.h:148
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:68
SUMOAbstractRouter< ROEdge, ROVehicle >
RORouteDef::ComparatorProbability
Definition: RORouteDef.h:169
RORouteDef::getDestination
const ROEdge * getDestination() const
Definition: RORouteDef.cpp:350
RORouteDef::ComparatorProbability::operator()
bool operator()(const RORoute *const a, const RORoute *const b)
Definition: RORouteDef.h:170
ROEdge
A basic edge for routing applications.
Definition: ROEdge.h:72
RORouteDef::~RORouteDef
virtual ~RORouteDef()
Destructor.
Definition: RORouteDef.cpp:58
RORouteDef::copyOrigDest
RORouteDef * copyOrigDest(const std::string &id) const
Returns a origin-destination copy of the route definition.
Definition: RORouteDef.cpp:372
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:385
SUMOAbstractRouter.h
RORouteDef::RORouteDef
RORouteDef(const std::string &id, const int lastUsed, const bool tryRepair, const bool mayBeDisconnected)
Constructor.
Definition: RORouteDef.cpp:51
RORouteDef::myUsingJTRR
static bool myUsingJTRR
Definition: RORouteDef.h:165
RORouteDef::setUsingJTRR
static void setUsingJTRR()
Definition: RORouteDef.h:142
ConstROEdgeVector
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:56
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:163
RORouteDef::myAlternatives
std::vector< RORoute * > myAlternatives
The alternatives.
Definition: RORouteDef.h:154