SUMO - Simulation of Urban MObility
ROEdge.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-2018 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 /****************************************************************************/
20 // A basic edge for routing applications
21 /****************************************************************************/
22 #ifndef ROEdge_h
23 #define ROEdge_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #include <config.h>
30 
31 #include <string>
32 #include <map>
33 #include <vector>
34 #include <algorithm>
35 #include <utils/common/Named.h>
36 #include <utils/common/StdDefs.h>
40 #include <utils/geom/Boundary.h>
41 #ifdef HAVE_FOX
42 #include <fx.h>
43 #endif
45 #include "RONode.h"
46 #include "ROVehicle.h"
47 
48 
49 // ===========================================================================
50 // class declarations
51 // ===========================================================================
52 class ROLane;
53 class ROEdge;
54 
55 typedef std::vector<ROEdge*> ROEdgeVector;
56 typedef std::vector<const ROEdge*> ConstROEdgeVector;
57 typedef std::vector<std::pair<const ROEdge*, const ROEdge*> > ROConstEdgePairVector;
58 
59 
60 // ===========================================================================
61 // class definitions
62 // ===========================================================================
72 class ROEdge : public Named {
73 public:
81  ROEdge(const std::string& id, RONode* from, RONode* to, int index, const int priority);
82 
83 
85  virtual ~ROEdge();
86 
87 
89 
90 
99  virtual void addLane(ROLane* lane);
100 
101 
108  virtual void addSuccessor(ROEdge* s, ROEdge* via = nullptr, std::string dir = "");
109 
110 
114  inline void setFunction(SumoXMLEdgeFunc func) {
115  myFunction = func;
116  }
117 
118 
122  inline void setSource(const bool isSource = true) {
123  myAmSource = isSource;
124  }
125 
126 
130  inline void setSink(const bool isSink = true) {
131  myAmSink = isSink;
132  }
133 
134 
138  inline void setRestrictions(const std::map<SUMOVehicleClass, double>* restrictions) {
139  myRestrictions = restrictions;
140  }
141 
142 
144  inline bool isInternal() const {
145  return myFunction == EDGEFUNC_INTERNAL;
146  }
147 
149  inline bool isCrossing() const {
150  return myFunction == EDGEFUNC_CROSSING;
151  }
152 
154  inline bool isWalkingArea() const {
156  }
157 
158  inline bool isTazConnector() const {
159  return myFunction == EDGEFUNC_CONNECTOR;
160  }
161 
171  void buildTimeLines(const std::string& measure, const bool boundariesOverride);
173 
174 
175 
177 
178 
183  inline SumoXMLEdgeFunc getFunction() const {
184  return myFunction;
185  }
186 
187 
191  inline bool isSink() const {
192  return myAmSink;
193  }
194 
195 
199  double getLength() const {
200  return myLength;
201  }
202 
206  int getNumericalID() const {
207  return myIndex;
208  }
209 
210 
214  double getSpeedLimit() const {
215  return mySpeed;
216  }
217 
219  // sufficient for the astar air-distance heuristic
220  double getLengthGeometryFactor() const {
221  if (myFromJunction != 0 && myToJunction != 0) {
223  } else {
224  return 1.0;
225  }
226  }
227 
232  inline double getVClassMaxSpeed(SUMOVehicleClass vclass) const {
233  if (myRestrictions != 0) {
234  std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(vclass);
235  if (r != myRestrictions->end()) {
236  return r->second;
237  }
238  }
239  return mySpeed;
240  }
241 
242 
246  int getNumLanes() const {
247  return (int) myLanes.size();
248  }
249 
250 
257  bool isConnectedTo(const ROEdge* const e, const ROVehicle* const vehicle) const;
258 
259 
264  inline bool prohibits(const ROVehicle* const vehicle) const {
265  const SUMOVehicleClass vclass = vehicle->getVClass();
266  return (myCombinedPermissions & vclass) != vclass;
267  }
268 
270  return myCombinedPermissions;
271  }
272 
273 
278  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
280 
281 
282 
284 
285 
292  void addEffort(double value, double timeBegin, double timeEnd);
293 
294 
301  void addTravelTime(double value, double timeBegin, double timeEnd);
302 
303 
311  int getNumSuccessors() const;
312 
313 
319 
325 
326 
334  int getNumPredecessors() const;
335 
336 
341  const ROEdgeVector& getPredecessors() const {
342  return myApproachingEdges;
343  }
344 
346  const ROEdge* getNormalBefore() const;
347 
349  const ROEdge* getNormalAfter() const;
350 
358  double getEffort(const ROVehicle* const veh, double time) const;
359 
360 
366  bool hasLoadedTravelTime(double time) const;
367 
368 
375  double getTravelTime(const ROVehicle* const veh, double time) const;
376 
377 
386  static inline double getEffortStatic(const ROEdge* const edge, const ROVehicle* const veh, double time) {
387  return edge->getEffort(veh, time);
388  }
389 
390 
398  static inline double getTravelTimeStatic(const ROEdge* const edge, const ROVehicle* const veh, double time) {
399  return edge->getTravelTime(veh, time);
400  }
401 
402 
408  inline double getMinimumTravelTime(const ROVehicle* const veh) const {
409  if (isTazConnector()) {
410  return 0;
411  } else if (veh != 0) {
412  return myLength / MIN2(veh->getType()->maxSpeed, veh->getChosenSpeedFactor() * mySpeed);
413  } else {
414  return myLength / mySpeed;
415  }
416  }
417 
418 
419  template<PollutantsInterface::EmissionType ET>
420  static double getEmissionEffort(const ROEdge* const edge, const ROVehicle* const veh, double time) {
421  double ret = 0;
422  if (!edge->getStoredEffort(time, ret)) {
423  const SUMOVTypeParameter* const type = veh->getType();
424  const double vMax = MIN2(type->maxSpeed, edge->mySpeed);
426  ret = PollutantsInterface::computeDefault(type->emissionClass, ET, vMax, accel, 0, edge->getTravelTime(veh, time)); // @todo: give correct slope
427  }
428  return ret;
429  }
430 
431 
432  static double getNoiseEffort(const ROEdge* const edge, const ROVehicle* const veh, double time);
434 
435 
437  double getDistanceTo(const ROEdge* other, const bool doBoundaryEstimate=false) const;
438 
439 
441  static const ROEdgeVector& getAllEdges();
442 
444  static int dictSize() {
445  return (int)myEdges.size();
446  };
447 
448  static void setGlobalOptions(const bool interpolate) {
449  myInterpolate = interpolate;
450  }
451 
453  static const Position getStopPosition(const SUMOVehicleParameter::Stop& stop);
454 
456  int getPriority() const {
457  return myPriority;
458  }
459 
460  const RONode* getFromJunction() const {
461  return myFromJunction;
462  }
463 
464  const RONode* getToJunction() const {
465  return myToJunction;
466  }
467 
468 
473  const std::vector<ROLane*>& getLanes() const {
474  return myLanes;
475  }
476 protected:
483  bool getStoredEffort(double time, double& ret) const;
484 
485 
486 
487 protected:
491 
493  const int myIndex;
494 
496  const int myPriority;
497 
499  double mySpeed;
500 
502  double myLength;
503 
510 
515 
517  static bool myInterpolate;
518 
520  static bool myHaveEWarned;
522  static bool myHaveTTWarned;
523 
526 
528 
531 
534 
536  const std::map<SUMOVehicleClass, double>* myRestrictions;
537 
539  std::vector<ROLane*> myLanes;
540 
543 
546 
548 
549 
551  mutable std::map<SUMOVehicleClass, ROEdgeVector> myClassesSuccessorMap;
552 
554  mutable std::map<SUMOVehicleClass, ROConstEdgePairVector> myClassesViaSuccessorMap;
555 
556 #ifdef HAVE_FOX
557  mutable FXMutex myLock;
559 #endif
560 
561 private:
563  ROEdge(const ROEdge& src);
564 
566  ROEdge& operator=(const ROEdge& src);
567 
568 };
569 
570 
571 #endif
572 
573 /****************************************************************************/
574 
static ROEdgeVector myEdges
Definition: ROEdge.h:547
std::map< SUMOVehicleClass, ROEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: ROEdge.h:551
static double getEffortStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the effort for the given edge.
Definition: ROEdge.h:386
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
Definition: ROEdge.h:341
SUMOVehicleClass getVClass() const
Definition: RORoutable.h:108
const Position & getPosition() const
Returns the position of the node.
Definition: RONode.h:67
bool isTazConnector() const
Definition: ROEdge.h:158
double myLength
The length of the edge.
Definition: ROEdge.h:502
void addTravelTime(double value, double timeBegin, double timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:133
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:206
A single lane the router may use.
Definition: ROLane.h:50
double mySpeed
The maximum speed allowed on this edge.
Definition: ROEdge.h:499
bool allFollowersProhibit(const ROVehicle *const vehicle) const
Returns whether this edge succeeding edges prohibit the given vehicle to pass them.
Definition: ROEdge.cpp:309
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:235
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
int getNumLanes() const
Returns the number of lanes this edge has.
Definition: ROEdge.h:246
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this edge.
Definition: ROEdge.h:536
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:517
Structure representing possible vehicle parameter.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const RONode * getFromJunction() const
Definition: ROEdge.h:460
void setSource(const bool isSource=true)
Sets whether the edge is a source.
Definition: ROEdge.h:122
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
Definition: ROEdge.h:264
double getLengthGeometryFactor() const
return a lower bound on shape.length() / myLength that is
Definition: ROEdge.h:220
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition: ROEdge.cpp:90
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
void setSink(const bool isSink=true)
Sets whether the edge is a sink.
Definition: ROEdge.h:130
T MAX2(T a, T b)
Definition: StdDefs.h:76
ROConstEdgePairVector myFollowingViaEdges
Definition: ROEdge.h:527
bool myAmSource
Definition: ROEdge.h:505
double getEffort(const ROVehicle *const veh, double time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:140
double getLength() const
Returns the length of the edge.
Definition: ROEdge.h:199
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:56
const RONode * getToJunction() const
Definition: ROEdge.h:464
SVCPermissions myCombinedPermissions
The list of allowed vehicle classes combined across lanes.
Definition: ROEdge.h:542
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: ROEdge.h:149
SVCPermissions getPermissions() const
Definition: ROEdge.h:269
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
double getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition: ROVehicle.h:112
static double getDefaultAccel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default acceleration for the given vehicle class This needs to be a function because the ...
ROEdgeVector myFollowingEdges
List of edges that may be approached from this edge.
Definition: ROEdge.h:525
double getMinimumTravelTime(const ROVehicle *const veh) const
Returns a lower bound for the travel time on this edge without using any stored timeLine.
Definition: ROEdge.h:408
static double getDefaultImperfection(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default driver&#39;s imperfection (sigma or epsilon in Krauss&#39; model) for the given vehicle c...
int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:244
SumoXMLEdgeFunc myFunction
The function of the edge.
Definition: ROEdge.h:533
std::vector< ROEdge * > ROEdgeVector
Definition: ROEdge.h:53
bool hasLoadedTravelTime(double time) const
Returns whether a travel time for this edge was loaded.
Definition: ROEdge.cpp:168
A vehicle as used by router.
Definition: ROVehicle.h:53
static double getEmissionEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.h:420
static double getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the travel time for the given edge.
Definition: ROEdge.h:398
double getDistanceTo(const ROEdge *other, const bool doBoundaryEstimate=false) const
optimistic distance heuristic for use in routing
Definition: ROEdge.cpp:150
double maxSpeed
The vehicle type&#39;s maximum speed [m/s].
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:489
void buildTimeLines(const std::string &measure, const bool boundariesOverride)
Builds the internal representation of the travel time/effort.
Definition: ROEdge.cpp:275
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:509
const ROEdge * getNormalAfter() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself ...
Definition: ROEdge.cpp:264
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
static bool myHaveEWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:520
bool myUsingETimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:514
std::vector< ROEdge * > ROEdgeVector
Definition: RODFRouteDesc.h:36
void addEffort(double value, double timeBegin, double timeEnd)
Adds a weight value.
Definition: ROEdge.cpp:126
SumoXMLEdgeFunc getFunction() const
Returns the function of the edge.
Definition: ROEdge.h:183
bool myAmSink
whether the edge is a source or a sink
Definition: ROEdge.h:505
Boundary myBoundary
The bounding rectangle of end nodes incoming or outgoing edges for taz connectors or of my own start ...
Definition: ROEdge.h:545
bool getStoredEffort(double time, double &ret) const
Retrieves the stored effort.
Definition: ROEdge.cpp:210
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:154
T MIN2(T a, T b)
Definition: StdDefs.h:70
static const Position getStopPosition(const SUMOVehicleParameter::Stop &stop)
return the coordinates of the center of the given stop
Definition: ROEdge.cpp:326
std::vector< std::pair< const ROEdge *, const ROEdge * > > ROConstEdgePairVector
Definition: ROEdge.h:57
static int dictSize()
Returns the number of edges.
Definition: ROEdge.h:444
std::vector< ROLane * > myLanes
This edge&#39;s lanes.
Definition: ROEdge.h:539
ValueTimeLine< double > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:512
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:82
A basic edge for routing applications.
Definition: ROEdge.h:72
Base class for objects which have an id.
Definition: Named.h:58
double getCFParam(const SumoXMLAttr attr, const double defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
bool isSink() const
Returns whether the edge acts as a sink.
Definition: ROEdge.h:191
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:144
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:456
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition: RORoutable.h:85
RONode * myToJunction
Definition: ROEdge.h:490
ROEdge(const std::string &id, RONode *from, RONode *to, int index, const int priority)
Constructor.
Definition: ROEdge.cpp:55
ROEdgeVector myApproachingEdges
List of edges that approached this edge.
Definition: ROEdge.h:530
bool isConnectedTo(const ROEdge *const e, const ROVehicle *const vehicle) const
returns the information whether this edge is directly connected to the given
Definition: ROEdge.cpp:406
virtual void addSuccessor(ROEdge *s, ROEdge *via=nullptr, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:103
std::map< SUMOVehicleClass, ROConstEdgePairVector > myClassesViaSuccessorMap
The successors with vias available for a given vClass.
Definition: ROEdge.h:554
Definition of vehicle stop (position and duration)
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
Definition: ROEdge.cpp:320
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:174
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
double getSpeedLimit() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:214
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: ROEdge.cpp:334
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.cpp:199
const std::vector< ROLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: ROEdge.h:473
ValueTimeLine< double > myTravelTimes
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:507
static void setGlobalOptions(const bool interpolate)
Definition: ROEdge.h:448
double getVClassMaxSpeed(SUMOVehicleClass vclass) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: ROEdge.h:232
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:234
const ROConstEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges including vias, restricted by vClass.
Definition: ROEdge.cpp:370
Base class for nodes used by the router.
Definition: RONode.h:46
static bool myHaveTTWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:522
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
Definition: ROEdge.cpp:253
void setRestrictions(const std::map< SUMOVehicleClass, double > *restrictions)
Sets the vehicle class specific speed limits of the edge.
Definition: ROEdge.h:138
static double computeDefault(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const double tt, const std::map< int, double > *param=0)
Returns the amount of emitted pollutant given the vehicle type and default values for the state (in m...
const int myIndex
The index (numeric id) of the edge.
Definition: ROEdge.h:493
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
const int myPriority
The edge priority (road class)
Definition: ROEdge.h:496
SUMOEmissionClass emissionClass
The emission class of this vehicle.
vehicles ignoring classes
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:114