Eclipse SUMO - Simulation of Urban MObility
IntermodalEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 // The Edge definition for the Intermodal Router
17 /****************************************************************************/
18 #ifndef IntermodalEdge_h
19 #define IntermodalEdge_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <vector>
31 #include "IntermodalTrip.h"
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
38 template<class E, class L, class N, class V>
39 class IntermodalEdge : public Named {
40 public:
41  IntermodalEdge(const std::string id, int numericalID, const E* edge, const std::string& line, const double length = 0.) :
42  Named(id),
43  myNumericalID(numericalID),
44  myEdge(edge),
45  myLine(line),
46  myLength(edge == nullptr || length > 0. ? length : edge->getLength()),
47  myEfforts(nullptr) { }
48 
49  virtual ~IntermodalEdge() {}
50 
51  virtual bool includeInRoute(bool /* allEdges */) const {
52  return false;
53  }
54 
55  inline const std::string& getLine() const {
56  return myLine;
57  }
58 
59  inline const E* getEdge() const {
60  return myEdge;
61  }
62 
63  int getNumericalID() const {
64  return myNumericalID;
65  }
66 
67  void addSuccessor(IntermodalEdge* const s, IntermodalEdge* const via = nullptr) {
68  myFollowingEdges.push_back(s);
69  myFollowingViaEdges.push_back(std::make_pair(s, via));
70  }
71 
75  myFollowingEdges.clear();
76  myFollowingViaEdges.clear();
77  }
78 
79  void removeSuccessor(const IntermodalEdge* const edge) {
80  myFollowingEdges.erase(std::find(myFollowingEdges.begin(), myFollowingEdges.end(), edge));
81  for (auto it = myFollowingViaEdges.begin(); it != myFollowingViaEdges.end();) {
82  if (it->first == edge) {
83  it = myFollowingViaEdges.erase(it);
84  } else {
85  ++it;
86  }
87  }
88  }
89 
90  virtual const std::vector<IntermodalEdge*>& getSuccessors(SUMOVehicleClass vClass = SVC_IGNORING) const {
91  UNUSED_PARAMETER(vClass);
92  // the network is already tailored. No need to check for permissions here
93  return myFollowingEdges;
94  }
95 
96  virtual const std::vector<std::pair<const IntermodalEdge*, const IntermodalEdge*> >& getViaSuccessors(SUMOVehicleClass vClass = SVC_IGNORING) const {
97  UNUSED_PARAMETER(vClass);
98  // the network is already tailored. No need to check for permissions here
99  return myFollowingViaEdges;
100  }
101 
102  virtual bool prohibits(const IntermodalTrip<E, N, V>* const /* trip */) const {
103  return false;
104  }
105 
106  virtual bool restricts(const IntermodalTrip<E, N, V>* const /* trip */) const {
107  return false;
108  }
109 
110  virtual double getTravelTime(const IntermodalTrip<E, N, V>* const /* trip */, double /* time */) const {
111  return 0.;
112  }
113 
115  virtual double getIntended(const double /* time */, std::string& /* intended */) const {
116  return 0.;
117  }
118 
119  static inline double getTravelTimeStatic(const IntermodalEdge* const edge, const IntermodalTrip<E, N, V>* const trip, double time) {
120  return edge == nullptr ? 0. : edge->getTravelTime(trip, time);
121  }
122 
123  static inline double getTravelTimeStaticRandomized(const IntermodalEdge* const edge, const IntermodalTrip<E, N, V>* const trip, double time) {
124  return edge == nullptr ? 0. : edge->getTravelTime(trip, time) * RandHelper::rand(1., gWeightsRandomFactor);
125  }
126 
127  virtual double getEffort(const IntermodalTrip<E, N, V>* const /* trip */, double /* time */) const {
128  return 0.;
129  }
130 
131  static inline double getEffortStatic(const IntermodalEdge* const edge, const IntermodalTrip<E, N, V>* const trip, double time) {
132  return edge == nullptr || !edge->hasEffort() ? 0. : edge->getEffort(trip, time);
133  }
134 
135  inline double getLength() const {
136  return myLength;
137  }
138 
139  inline void setLength(const double length) {
140  myLength = length;
141  }
142 
143  inline bool isInternal() const {
144  return myEdge != nullptr && myEdge->isInternal();
145  }
146 
147  virtual bool hasEffort() const {
148  return myEfforts != nullptr;
149  }
150 
151  virtual double getStartPos() const {
152  return 0.;
153  }
154 
155  virtual double getEndPos() const {
156  return myLength;
157  }
158 
159  // only used by AStar
160  inline double getSpeedLimit() const {
161  return myEdge != nullptr ? myEdge->getSpeedLimit() : 200. / 3.6;
162  }
163 
164  // only used by AStar
165  inline double getLengthGeometryFactor() const {
166  return myEdge != nullptr ? myEdge->getLengthGeometryFactor() : 1;
167  }
168 
169  // only used by AStar
170  inline double getDistanceTo(const IntermodalEdge* other) const {
171  return myEdge != nullptr && other->myEdge != nullptr && myEdge != other->myEdge ? myEdge->getDistanceTo(other->myEdge, true) : 0.;
172  }
173 
174  // only used by AStar
175  inline double getMinimumTravelTime(const IntermodalTrip<E, N, V>* const trip) const {
176  return myLength / trip->getMaxSpeed();
177  }
178 
179 protected:
181  std::vector<IntermodalEdge*> myFollowingEdges;
182 
184  std::vector<std::pair<const IntermodalEdge*, const IntermodalEdge*> > myFollowingViaEdges;
185 
186 private:
188  const int myNumericalID;
189 
191  const E* const myEdge;
192 
194  const std::string myLine;
195 
197  double myLength;
198 
201 
202 private:
204  IntermodalEdge(const IntermodalEdge& src);
205 
208 
209 };
210 
211 
212 #endif
213 
214 /****************************************************************************/
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:31
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
IntermodalEdge::myLength
double myLength
adaptable length (for splitted edges)
Definition: IntermodalEdge.h:197
IntermodalEdge::IntermodalEdge
IntermodalEdge(const std::string id, int numericalID, const E *edge, const std::string &line, const double length=0.)
Definition: IntermodalEdge.h:41
Named
Base class for objects which have an id.
Definition: Named.h:56
IntermodalEdge::removeSuccessor
void removeSuccessor(const IntermodalEdge *const edge)
Definition: IntermodalEdge.h:79
IntermodalEdge::getLengthGeometryFactor
double getLengthGeometryFactor() const
Definition: IntermodalEdge.h:165
IntermodalEdge::getTravelTimeStaticRandomized
static double getTravelTimeStaticRandomized(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
Definition: IntermodalEdge.h:123
IntermodalEdge::getStartPos
virtual double getStartPos() const
Definition: IntermodalEdge.h:151
ValueTimeLine.h
IntermodalEdge::~IntermodalEdge
virtual ~IntermodalEdge()
Definition: IntermodalEdge.h:49
IntermodalEdge::getLength
double getLength() const
Definition: IntermodalEdge.h:135
IntermodalEdge::getTravelTime
virtual double getTravelTime(const IntermodalTrip< E, N, V > *const, double) const
Definition: IntermodalEdge.h:110
IntermodalEdge::setLength
void setLength(const double length)
Definition: IntermodalEdge.h:139
IntermodalEdge
the base edge type that is given to the internal router (SUMOAbstractRouter)
Definition: IntermodalEdge.h:39
IntermodalEdge::hasEffort
virtual bool hasEffort() const
Definition: IntermodalEdge.h:147
IntermodalEdge::getEffortStatic
static double getEffortStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
Definition: IntermodalEdge.h:131
gWeightsRandomFactor
double gWeightsRandomFactor
Definition: StdDefs.cpp:30
IntermodalEdge::getMinimumTravelTime
double getMinimumTravelTime(const IntermodalTrip< E, N, V > *const trip) const
Definition: IntermodalEdge.h:175
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:53
IntermodalEdge::includeInRoute
virtual bool includeInRoute(bool) const
Definition: IntermodalEdge.h:51
IntermodalTrip::getMaxSpeed
double getMaxSpeed() const
Definition: IntermodalTrip.h:68
IntermodalTrip.h
IntermodalEdge::myEdge
const E *const myEdge
the original edge
Definition: IntermodalEdge.h:191
IntermodalEdge::getTravelTimeStatic
static double getTravelTimeStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
Definition: IntermodalEdge.h:119
IntermodalEdge::myFollowingViaEdges
std::vector< std::pair< const IntermodalEdge *, const IntermodalEdge * > > myFollowingViaEdges
List of edges that may be approached from this edge with optional internal vias.
Definition: IntermodalEdge.h:184
IntermodalEdge::operator=
IntermodalEdge & operator=(const IntermodalEdge &src)
Invalidated assignment operator.
IntermodalEdge::getNumericalID
int getNumericalID() const
Definition: IntermodalEdge.h:63
IntermodalEdge::getIntended
virtual double getIntended(const double, std::string &) const
get intended vehicle id and departure time of next public transport ride
Definition: IntermodalEdge.h:115
IntermodalEdge::myEfforts
ValueTimeLine< double > * myEfforts
Container for passing effort varying over time for the edge.
Definition: IntermodalEdge.h:200
IntermodalEdge::addSuccessor
void addSuccessor(IntermodalEdge *const s, IntermodalEdge *const via=nullptr)
Definition: IntermodalEdge.h:67
IntermodalEdge::getEdge
const E * getEdge() const
Definition: IntermodalEdge.h:59
IntermodalEdge::myNumericalID
const int myNumericalID
the index in myEdges
Definition: IntermodalEdge.h:188
IntermodalEdge::getSuccessors
virtual const std::vector< IntermodalEdge * > & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Definition: IntermodalEdge.h:90
IntermodalEdge::getEndPos
virtual double getEndPos() const
Definition: IntermodalEdge.h:155
IntermodalEdge::transferSuccessors
void transferSuccessors(IntermodalEdge *to)
Definition: IntermodalEdge.h:72
IntermodalEdge::myLine
const std::string myLine
public transport line or ped vs car
Definition: IntermodalEdge.h:194
IntermodalEdge::isInternal
bool isInternal() const
Definition: IntermodalEdge.h:143
IntermodalEdge::getViaSuccessors
virtual const std::vector< std::pair< const IntermodalEdge *, const IntermodalEdge * > > & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Definition: IntermodalEdge.h:96
IntermodalEdge::prohibits
virtual bool prohibits(const IntermodalTrip< E, N, V > *const) const
Definition: IntermodalEdge.h:102
IntermodalEdge::getDistanceTo
double getDistanceTo(const IntermodalEdge *other) const
Definition: IntermodalEdge.h:170
IntermodalEdge::getLine
const std::string & getLine() const
Definition: IntermodalEdge.h:55
config.h
RandHelper.h
IntermodalEdge::restricts
virtual bool restricts(const IntermodalTrip< E, N, V > *const) const
Definition: IntermodalEdge.h:106
ValueTimeLine< double >
SVC_IGNORING
vehicles ignoring classes
Definition: SUMOVehicleClass.h:135
IntermodalTrip
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
Definition: IntermodalTrip.h:38
IntermodalEdge::getEffort
virtual double getEffort(const IntermodalTrip< E, N, V > *const, double) const
Definition: IntermodalEdge.h:127
IntermodalEdge::getSpeedLimit
double getSpeedLimit() const
Definition: IntermodalEdge.h:160
IntermodalEdge::myFollowingEdges
std::vector< IntermodalEdge * > myFollowingEdges
List of edges that may be approached from this edge.
Definition: IntermodalEdge.h:181