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 /****************************************************************************/
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:32
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
IntermodalEdge::myLength
double myLength
adaptable length (for splitted edges)
Definition: IntermodalEdge.h:194
IntermodalEdge::IntermodalEdge
IntermodalEdge(const std::string id, int numericalID, const E *edge, const std::string &line, const double length=0.)
Definition: IntermodalEdge.h:42
Named
Base class for objects which have an id.
Definition: Named.h:57
IntermodalEdge::removeSuccessor
void removeSuccessor(const IntermodalEdge *const edge)
Definition: IntermodalEdge.h:80
IntermodalEdge::getLengthGeometryFactor
double getLengthGeometryFactor() const
Definition: IntermodalEdge.h:162
IntermodalEdge::getTravelTimeStaticRandomized
static double getTravelTimeStaticRandomized(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
Definition: IntermodalEdge.h:120
IntermodalEdge::getStartPos
virtual double getStartPos() const
Definition: IntermodalEdge.h:148
ValueTimeLine.h
IntermodalEdge::~IntermodalEdge
virtual ~IntermodalEdge()
Definition: IntermodalEdge.h:50
IntermodalEdge::getLength
double getLength() const
Definition: IntermodalEdge.h:132
IntermodalEdge::getTravelTime
virtual double getTravelTime(const IntermodalTrip< E, N, V > *const, double) const
Definition: IntermodalEdge.h:107
IntermodalEdge::setLength
void setLength(const double length)
Definition: IntermodalEdge.h:136
IntermodalEdge
the base edge type that is given to the internal router (SUMOAbstractRouter)
Definition: IntermodalEdge.h:40
IntermodalEdge::hasEffort
virtual bool hasEffort() const
Definition: IntermodalEdge.h:144
IntermodalEdge::getEffortStatic
static double getEffortStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
Definition: IntermodalEdge.h:128
gWeightsRandomFactor
double gWeightsRandomFactor
Definition: StdDefs.cpp:31
IntermodalEdge::getMinimumTravelTime
double getMinimumTravelTime(const IntermodalTrip< E, N, V > *const trip) const
Definition: IntermodalEdge.h:172
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:60
IntermodalEdge::includeInRoute
virtual bool includeInRoute(bool) const
Definition: IntermodalEdge.h:52
IntermodalTrip::getMaxSpeed
double getMaxSpeed() const
Definition: IntermodalTrip.h:69
IntermodalTrip.h
IntermodalEdge::myEdge
const E *const myEdge
the original edge
Definition: IntermodalEdge.h:188
IntermodalEdge::getTravelTimeStatic
static double getTravelTimeStatic(const IntermodalEdge *const edge, const IntermodalTrip< E, N, V > *const trip, double time)
Definition: IntermodalEdge.h:116
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:181
IntermodalEdge::operator=
IntermodalEdge & operator=(const IntermodalEdge &src)
Invalidated assignment operator.
IntermodalEdge::getNumericalID
int getNumericalID() const
Definition: IntermodalEdge.h:64
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:112
IntermodalEdge::myEfforts
ValueTimeLine< double > * myEfforts
Container for passing effort varying over time for the edge.
Definition: IntermodalEdge.h:197
IntermodalEdge::addSuccessor
void addSuccessor(IntermodalEdge *const s, IntermodalEdge *const via=nullptr)
Definition: IntermodalEdge.h:68
IntermodalEdge::getEdge
const E * getEdge() const
Definition: IntermodalEdge.h:60
IntermodalEdge::myNumericalID
const int myNumericalID
the index in myEdges
Definition: IntermodalEdge.h:185
IntermodalEdge::getSuccessors
virtual const std::vector< IntermodalEdge * > & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Definition: IntermodalEdge.h:91
IntermodalEdge::getEndPos
virtual double getEndPos() const
Definition: IntermodalEdge.h:152
IntermodalEdge::transferSuccessors
void transferSuccessors(IntermodalEdge *to)
Definition: IntermodalEdge.h:73
IntermodalEdge::myLine
const std::string myLine
public transport line or ped vs car
Definition: IntermodalEdge.h:191
IntermodalEdge::isInternal
bool isInternal() const
Definition: IntermodalEdge.h:140
IntermodalEdge::getViaSuccessors
virtual const std::vector< std::pair< const IntermodalEdge *, const IntermodalEdge * > > & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Definition: IntermodalEdge.h:97
IntermodalEdge::prohibits
virtual bool prohibits(const IntermodalTrip< E, N, V > *const) const
Definition: IntermodalEdge.h:103
IntermodalEdge::getDistanceTo
double getDistanceTo(const IntermodalEdge *other) const
Definition: IntermodalEdge.h:167
IntermodalEdge::getLine
const std::string & getLine() const
Definition: IntermodalEdge.h:56
config.h
RandHelper.h
ValueTimeLine< double >
SVC_IGNORING
vehicles ignoring classes
Definition: SUMOVehicleClass.h:136
IntermodalTrip
the "vehicle" type that is given to the internal router (SUMOAbstractRouter)
Definition: IntermodalTrip.h:39
IntermodalEdge::getEffort
virtual double getEffort(const IntermodalTrip< E, N, V > *const, double) const
Definition: IntermodalEdge.h:124
IntermodalEdge::getSpeedLimit
double getSpeedLimit() const
Definition: IntermodalEdge.h:157
IntermodalEdge::myFollowingEdges
std::vector< IntermodalEdge * > myFollowingEdges
List of edges that may be approached from this edge.
Definition: IntermodalEdge.h:178