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;
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  int getPriority() const {
454  return myPriority;
455  }
456 
457  const RONode* getFromJunction() const {
458  return myFromJunction;
459  }
460 
461  const RONode* getToJunction() const {
462  return myToJunction;
463  }
464 
465 
470  const std::vector<ROLane*>& getLanes() const {
471  return myLanes;
472  }
473 protected:
480  bool getStoredEffort(double time, double& ret) const;
481 
482 
483 
484 protected:
488 
490  const int myIndex;
491 
493  const int myPriority;
494 
496  double mySpeed;
497 
499  double myLength;
500 
507 
512 
514  static bool myInterpolate;
515 
517  static bool myHaveEWarned;
519  static bool myHaveTTWarned;
520 
523 
525 
528 
531 
533  const std::map<SUMOVehicleClass, double>* myRestrictions;
534 
536  std::vector<ROLane*> myLanes;
537 
540 
543 
545 
546 
548  mutable std::map<SUMOVehicleClass, ROEdgeVector> myClassesSuccessorMap;
549 
551  mutable std::map<SUMOVehicleClass, ROConstEdgePairVector> myClassesViaSuccessorMap;
552 
553 #ifdef HAVE_FOX
554  mutable FXMutex myLock;
556 #endif
557 
558 private:
560  ROEdge(const ROEdge& src);
561 
563  ROEdge& operator=(const ROEdge& src);
564 
565 };
566 
567 
568 #endif
569 
570 /****************************************************************************/
571 
static ROEdgeVector myEdges
Definition: ROEdge.h:544
std::map< SUMOVehicleClass, ROEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: ROEdge.h:548
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:499
void addTravelTime(double value, double timeBegin, double timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:130
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:496
bool allFollowersProhibit(const ROVehicle *const vehicle) const
Returns whether this edge succeeding edges prohibit the given vehicle to pass them.
Definition: ROEdge.cpp:303
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:229
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:533
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:514
Structure representing possible vehicle parameter.
Boundary myTazBoundary
The bounding rectangle of incoming or outgoing edges for taz connectors.
Definition: ROEdge.h:542
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const RONode * getFromJunction() const
Definition: ROEdge.h:457
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:87
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:524
bool myAmSource
Definition: ROEdge.h:502
double getEffort(const ROVehicle *const veh, double time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:137
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:461
SVCPermissions myCombinedPermissions
The list of allowed vehicle classes combined across lanes.
Definition: ROEdge.h:539
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:522
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:238
SumoXMLEdgeFunc myFunction
The function of the edge.
Definition: ROEdge.h:530
std::vector< ROEdge * > ROEdgeVector
Definition: ROEdge.h:53
double getDistanceTo(const ROEdge *other) const
optimistic distance heuristic for use in routing
Definition: ROEdge.cpp:147
bool hasLoadedTravelTime(double time) const
Returns whether a travel time for this edge was loaded.
Definition: ROEdge.cpp:162
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 maxSpeed
The vehicle type&#39;s maximum speed [m/s].
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:486
void buildTimeLines(const std::string &measure, const bool boundariesOverride)
Builds the internal representation of the travel time/effort.
Definition: ROEdge.cpp:269
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:506
const ROEdge * getNormalAfter() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself ...
Definition: ROEdge.cpp:258
static bool myHaveEWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:517
bool myUsingETimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:511
std::vector< ROEdge * > ROEdgeVector
Definition: RODFRouteDesc.h:36
void addEffort(double value, double timeBegin, double timeEnd)
Adds a weight value.
Definition: ROEdge.cpp:123
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:502
bool getStoredEffort(double time, double &ret) const
Retrieves the stored effort.
Definition: ROEdge.cpp:204
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:154
T MIN2(T a, T b)
Definition: StdDefs.h:70
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:536
ValueTimeLine< double > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:509
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:79
A basic edge for routing applications.
Definition: ROEdge.h:72
Base class for objects which have an id.
Definition: Named.h:49
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:453
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition: RORoutable.h:85
RONode * myToJunction
Definition: ROEdge.h:487
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:527
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:392
virtual void addSuccessor(ROEdge *s, ROEdge *via=nullptr, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:100
std::map< SUMOVehicleClass, ROConstEdgePairVector > myClassesViaSuccessorMap
The successors with vias available for a given vClass.
Definition: ROEdge.h:551
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
Definition: ROEdge.cpp:314
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:168
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:320
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.cpp:193
const std::vector< ROLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: ROEdge.h:470
ValueTimeLine< double > myTravelTimes
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:504
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:233
const ROConstEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges including vias, restricted by vClass.
Definition: ROEdge.cpp:356
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:519
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
Definition: ROEdge.cpp:247
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:490
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
const int myPriority
The edge priority (road class)
Definition: ROEdge.h:493
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