SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RORouteDef.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Base class for a vehicle's route definition
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2002-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef RORouteDef_h
23 #define RORouteDef_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <iostream>
37 #include <utils/common/Named.h>
39 #include "RORoute.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class ROEdge;
46 class OptionsCont;
47 class ROVehicle;
48 class OutputDevice;
49 
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
63 class RORouteDef : public Named {
64 public:
70  RORouteDef(const std::string& id, const int lastUsed,
71  const bool tryRepair, const bool mayBeDisconnected);
72 
73 
75  virtual ~RORouteDef();
76 
77 
80  void addLoadedAlternative(RORoute* alternative);
81 
83  void addAlternativeDef(const RORouteDef* alternative);
84 
88  const ROVehicle& veh) const;
89 
93  const ROVehicle& veh) const;
94 
98  const ROVehicle& veh, ConstROEdgeVector oldEdges, ConstROEdgeVector& newEdges) const;
99 
104  const ROVehicle* const, RORoute* current, SUMOTime begin);
105 
106  const ROEdge* getDestination() const;
107 
108  const RORoute* getFirstRoute() const {
109  if (myAlternatives.empty()) {
110  return 0;
111  }
112  return myAlternatives.front();
113  }
114 
123  OutputDevice& writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,
124  bool asAlternatives, bool withExitTimes) const;
125 
134  RORouteDef* copyOrigDest(const std::string& id) const;
135 
145  RORouteDef* copy(const std::string& id, const SUMOTime stopOffset) const;
146 
148  SUMOReal getOverallProb() const;
149 
150  static void setUsingJTRR() {
151  myUsingJTRR = true;
152  }
153 
154 protected:
157 
159  mutable int myLastUsed;
160 
162  std::vector<RORoute*> myAlternatives;
163 
165  std::set<RORoute*> myRouteRefs;
166 
168  mutable bool myNewRoute;
169 
170  const bool myTryRepair;
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 
188  RORouteDef& operator=(const RORouteDef& src);
189 
190 };
191 
192 
193 #endif
194 
195 /****************************************************************************/
196 
int myLastUsed
Index of the route used within the last step.
Definition: RORouteDef.h:159
bool myNewRoute
Information whether a new route was generated.
Definition: RORouteDef.h:168
RORouteDef * copyOrigDest(const std::string &id) const
Returns a origin-destination copy of the route definition.
Definition: RORouteDef.cpp:393
long long int SUMOTime
Definition: SUMOTime.h:43
const bool myTryRepair
Definition: RORouteDef.h:170
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:173
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
Definition: RORouteDef.cpp:284
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:95
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
Definition: RORouteDef.cpp:86
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:105
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:62
static bool myUsingJTRR
Definition: RORouteDef.h:173
RORoute * myPrecomputed
precomputed route for out-of-order computation
Definition: RORouteDef.h:156
const bool myMayBeDisconnected
Definition: RORouteDef.h:171
A vehicle as used by router.
Definition: ROVehicle.h:60
std::set< RORoute * > myRouteRefs
Routes which are deleted someplace else.
Definition: RORouteDef.h:165
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes) const
Saves the built route / route alternatives.
Definition: RORouteDef.cpp:377
SUMOReal getProbability() const
Returns the probability the driver will take this route with.
Definition: RORoute.h:130
RORouteDef(const std::string &id, const int lastUsed, const bool tryRepair, const bool mayBeDisconnected)
Constructor.
Definition: RORouteDef.cpp:63
const ROEdge * getDestination() const
Definition: RORouteDef.cpp:371
A basic edge for routing applications.
Definition: ROEdge.h:77
Base class for objects which have an id.
Definition: Named.h:46
virtual ~RORouteDef()
Destructor.
Definition: RORouteDef.cpp:70
bool operator()(const RORoute *const a, const RORoute *const b)
Definition: RORouteDef.h:178
static void setUsingJTRR()
Definition: RORouteDef.h:150
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
Definition: RORouteDef.cpp:406
A storage for options typed value containers)
Definition: OptionsCont.h:99
Base class for a vehicle's route definition.
Definition: RORouteDef.h:63
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA...
Definition: RORouteDef.cpp:80
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
const RORoute * getFirstRoute() const
Definition: RORouteDef.h:108
RORouteDef & operator=(const RORouteDef &src)
Invalidated assignment operator.
std::vector< RORoute * > myAlternatives
The alternatives.
Definition: RORouteDef.h:162
SUMOReal getOverallProb() const
Returns the sum of the probablities of the contained routes.
Definition: RORouteDef.cpp:420
A complete router's route.
Definition: RORoute.h:62