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