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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
22 // A basic edge for routing applications
23 /****************************************************************************/
24 #ifndef ROEdge_h
25 #define ROEdge_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <string>
38 #include <map>
39 #include <vector>
40 #include <algorithm>
41 #include <utils/common/Named.h>
42 #include <utils/common/StdDefs.h>
46 #include <utils/geom/Boundary.h>
47 #ifdef HAVE_FOX
48 #include <fx.h>
49 #endif
51 #include "RONode.h"
52 #include "ROVehicle.h"
53 
54 
55 // ===========================================================================
56 // class declarations
57 // ===========================================================================
58 class ROLane;
59 class ROEdge;
60 
61 typedef std::vector<ROEdge*> ROEdgeVector;
62 typedef std::vector<const ROEdge*> ConstROEdgeVector;
63 
64 
65 // ===========================================================================
66 // class definitions
67 // ===========================================================================
77 class ROEdge : public Named {
78 public:
86  ROEdge(const std::string& id, RONode* from, RONode* to, int index, const int priority);
87 
88 
90  virtual ~ROEdge();
91 
92 
94 
95 
104  virtual void addLane(ROLane* lane);
105 
106 
113  virtual void addSuccessor(ROEdge* s, std::string dir = "");
114 
115 
119  inline void setFunction(SumoXMLEdgeFunc func) {
120  myFunction = func;
121  }
122 
123 
127  inline void setSource(const bool isSource = true) {
128  myAmSource = isSource;
129  }
130 
131 
135  inline void setSink(const bool isSink = true) {
136  myAmSink = isSink;
137  }
138 
139 
143  inline void setRestrictions(const std::map<SUMOVehicleClass, double>* restrictions) {
144  myRestrictions = restrictions;
145  }
146 
147 
149  inline bool isInternal() const {
150  return myFunction == EDGEFUNC_INTERNAL;
151  }
152 
154  inline bool isCrossing() const {
155  return myFunction == EDGEFUNC_CROSSING;
156  }
157 
159  inline bool isWalkingArea() const {
161  }
162 
163  inline bool isTazConnector() const {
164  return myFunction == EDGEFUNC_CONNECTOR;
165  }
166 
176  void buildTimeLines(const std::string& measure, const bool boundariesOverride);
178 
179 
180 
182 
183 
188  inline SumoXMLEdgeFunc getFunction() const {
189  return myFunction;
190  }
191 
192 
196  inline bool isSink() const {
197  return myAmSink;
198  }
199 
200 
204  double getLength() const {
205  return myLength;
206  }
207 
211  int getNumericalID() const {
212  return myIndex;
213  }
214 
215 
219  double getSpeedLimit() const {
220  return mySpeed;
221  }
222 
224  // sufficient for the astar air-distance heuristic
225  double getLengthGeometryFactor() const {
226  if (myFromJunction != 0 && myToJunction != 0) {
228  } else {
229  return 1.0;
230  }
231  }
232 
237  inline double getVClassMaxSpeed(SUMOVehicleClass vclass) const {
238  if (myRestrictions != 0) {
239  std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(vclass);
240  if (r != myRestrictions->end()) {
241  return r->second;
242  }
243  }
244  return mySpeed;
245  }
246 
247 
251  int getNumLanes() const {
252  return (int) myLanes.size();
253  }
254 
255 
262  bool isConnectedTo(const ROEdge* const e, const ROVehicle* const vehicle) const;
263 
264 
269  inline bool prohibits(const ROVehicle* const vehicle) const {
270  const SUMOVehicleClass vclass = vehicle->getVClass();
271  return (myCombinedPermissions & vclass) != vclass;
272  }
273 
275  return myCombinedPermissions;
276  }
277 
278 
283  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
285 
286 
287 
289 
290 
297  void addEffort(double value, double timeBegin, double timeEnd);
298 
299 
306  void addTravelTime(double value, double timeBegin, double timeEnd);
307 
308 
316  int getNumSuccessors() const;
317 
318 
321  const ROEdgeVector& getSuccessors() const {
322  return myFollowingEdges;
323  }
324 
325 
330  const ROEdgeVector& getSuccessors(SUMOVehicleClass vClass) const;
331 
332 
340  int getNumPredecessors() const;
341 
342 
347  const ROEdgeVector& getPredecessors() const {
348  return myApproachingEdges;
349  }
350 
352  const ROEdge* getNormalBefore() const;
353 
355  const ROEdge* getNormalAfter() const;
356 
364  double getEffort(const ROVehicle* const veh, double time) const;
365 
366 
372  bool hasLoadedTravelTime(double time) const;
373 
374 
381  double getTravelTime(const ROVehicle* const veh, double time) const;
382 
383 
392  static inline double getEffortStatic(const ROEdge* const edge, const ROVehicle* const veh, double time) {
393  return edge->getEffort(veh, time);
394  }
395 
396 
404  static inline double getTravelTimeStatic(const ROEdge* const edge, const ROVehicle* const veh, double time) {
405  return edge->getTravelTime(veh, time);
406  }
407 
408 
414  inline double getMinimumTravelTime(const ROVehicle* const veh) const {
415  if (isTazConnector()) {
416  return 0;
417  } else if (veh != 0) {
418  return myLength / MIN2(veh->getType()->maxSpeed, veh->getChosenSpeedFactor() * mySpeed);
419  } else {
420  return myLength / mySpeed;
421  }
422  }
423 
424 
425  template<PollutantsInterface::EmissionType ET>
426  static double getEmissionEffort(const ROEdge* const edge, const ROVehicle* const veh, double time) {
427  double ret = 0;
428  if (!edge->getStoredEffort(time, ret)) {
429  const SUMOVTypeParameter* const type = veh->getType();
430  const double vMax = MIN2(type->maxSpeed, edge->mySpeed);
432  ret = PollutantsInterface::computeDefault(type->emissionClass, ET, vMax, accel, 0, edge->getTravelTime(veh, time)); // @todo: give correct slope
433  }
434  return ret;
435  }
436 
437 
438  static double getNoiseEffort(const ROEdge* const edge, const ROVehicle* const veh, double time);
440 
441 
443  double getDistanceTo(const ROEdge* other) const;
444 
445 
447  static const ROEdgeVector& getAllEdges();
448 
450  static int dictSize() {
451  return (int)myEdges.size();
452  };
453 
454  static void setGlobalOptions(const bool interpolate) {
455  myInterpolate = interpolate;
456  }
457 
459  int getPriority() const {
460  return myPriority;
461  }
462 
463  const RONode* getFromJunction() const {
464  return myFromJunction;
465  }
466 
467  const RONode* getToJunction() const {
468  return myToJunction;
469  }
470 
471 
476  const std::vector<ROLane*>& getLanes() const {
477  return myLanes;
478  }
479 protected:
486  bool getStoredEffort(double time, double& ret) const;
487 
488 
489 
490 protected:
494 
496  const int myIndex;
497 
499  const int myPriority;
500 
502  double mySpeed;
503 
505  double myLength;
506 
513 
518 
520  static bool myInterpolate;
521 
523  static bool myHaveEWarned;
525  static bool myHaveTTWarned;
526 
529 
532 
535 
537  const std::map<SUMOVehicleClass, double>* myRestrictions;
538 
540  std::vector<ROLane*> myLanes;
541 
544 
547 
549 
550 
552  mutable std::map<SUMOVehicleClass, ROEdgeVector> myClassesSuccessorMap;
553 
554 #ifdef HAVE_FOX
555  mutable FXMutex myLock;
557 #endif
558 
559 private:
561  ROEdge(const ROEdge& src);
562 
564  ROEdge& operator=(const ROEdge& src);
565 
566 };
567 
568 
569 #endif
570 
571 /****************************************************************************/
572 
static ROEdgeVector myEdges
Definition: ROEdge.h:548
std::map< SUMOVehicleClass, ROEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: ROEdge.h:552
static double getEffortStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the effort for the given edge.
Definition: ROEdge.h:392
double getSpeedLimit() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:219
double myLength
The length of the edge.
Definition: ROEdge.h:505
void addTravelTime(double value, double timeBegin, double timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:136
A single lane the router may use.
Definition: ROLane.h:56
double getVClassMaxSpeed(SUMOVehicleClass vclass) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: ROEdge.h:237
double mySpeed
The maximum speed allowed on this edge.
Definition: ROEdge.h:502
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this edge.
Definition: ROEdge.h:537
double getLength() const
Returns the length of the edge.
Definition: ROEdge.h:204
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:520
Structure representing possible vehicle parameter.
Boundary myTazBoundary
The bounding rectangle of incoming or outgoing edges for taz connectors.
Definition: ROEdge.h:546
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
void setSource(const bool isSource=true)
Sets whether the edge is a source.
Definition: ROEdge.h:127
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition: ROEdge.cpp:93
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
void setSink(const bool isSink=true)
Sets whether the edge is a sink.
Definition: ROEdge.h:135
T MAX2(T a, T b)
Definition: StdDefs.h:73
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:234
bool isTazConnector() const
Definition: ROEdge.h:163
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:174
bool myAmSource
Definition: ROEdge.h:508
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:62
SVCPermissions myCombinedPermissions
The list of allowed vehicle classes combined across lanes.
Definition: ROEdge.h:543
double getEffort(const ROVehicle *const veh, double time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:143
const std::vector< ROLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: ROEdge.h:476
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
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:528
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:159
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...
SumoXMLEdgeFunc myFunction
The function of the edge.
Definition: ROEdge.h:534
std::vector< ROEdge * > ROEdgeVector
Definition: ROEdge.h:59
A vehicle as used by router.
Definition: ROVehicle.h:59
const RONode * getToJunction() const
Definition: ROEdge.h:467
bool allFollowersProhibit(const ROVehicle *const vehicle) const
Returns whether this edge succeeding edges prohibit the given vehicle to pass them.
Definition: ROEdge.cpp:308
bool getStoredEffort(double time, double &ret) const
Retrieves the stored effort.
Definition: ROEdge.cpp:209
static double getEmissionEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.h:426
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:149
static double getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the travel time for the given edge.
Definition: ROEdge.h:404
double maxSpeed
The vehicle type&#39;s maximum speed [m/s].
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:492
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Definition: RORoutable.h:91
void buildTimeLines(const std::string &measure, const bool boundariesOverride)
Builds the internal representation of the travel time/effort.
Definition: ROEdge.cpp:274
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:512
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:366
static bool myHaveEWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:523
int getNumLanes() const
Returns the number of lanes this edge has.
Definition: ROEdge.h:251
bool myUsingETimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:517
std::vector< ROEdge * > ROEdgeVector
Definition: RODFRouteDesc.h:42
void addEffort(double value, double timeBegin, double timeEnd)
Adds a weight value.
Definition: ROEdge.cpp:129
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
Definition: ROEdge.h:347
bool myAmSink
whether the edge is a source or a sink
Definition: ROEdge.h:508
T MIN2(T a, T b)
Definition: StdDefs.h:67
SumoXMLEdgeFunc getFunction() const
Returns the function of the edge.
Definition: ROEdge.h:188
static int dictSize()
Returns the number of edges.
Definition: ROEdge.h:450
std::vector< ROLane * > myLanes
This edge&#39;s lanes.
Definition: ROEdge.h:540
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:414
ValueTimeLine< double > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:515
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:85
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:239
A basic edge for routing applications.
Definition: ROEdge.h:77
Base class for objects which have an id.
Definition: Named.h:45
bool hasLoadedTravelTime(double time) const
Returns whether a travel time for this edge was loaded.
Definition: ROEdge.cpp:168
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.
double getDistanceTo(const ROEdge *other) const
optimistic distance heuristic for use in routing
Definition: ROEdge.cpp:153
const RONode * getFromJunction() const
Definition: ROEdge.h:463
double getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition: ROVehicle.h:114
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:106
RONode * myToJunction
Definition: ROEdge.h:493
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:459
ROEdge(const std::string &id, RONode *from, RONode *to, int index, const int priority)
Constructor.
Definition: ROEdge.cpp:61
ROEdgeVector myApproachingEdges
List of edges that approached this edge.
Definition: ROEdge.h:531
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
Definition: ROEdge.h:269
int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:243
bool isSink() const
Returns whether the edge acts as a sink.
Definition: ROEdge.h:196
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
Definition: ROEdge.cpp:319
const ROEdgeVector & getSuccessors() const
Returns the following edges.
Definition: ROEdge.h:321
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.cpp:198
const ROEdge * getNormalAfter() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself ...
Definition: ROEdge.cpp:263
double getLengthGeometryFactor() const
return a lower bound on shape.length() / myLength that is
Definition: ROEdge.h:225
ValueTimeLine< double > myTravelTimes
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:510
static void setGlobalOptions(const bool interpolate)
Definition: ROEdge.h:454
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
Definition: ROEdge.cpp:252
Base class for nodes used by the router.
Definition: RONode.h:52
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: ROEdge.h:154
static bool myHaveTTWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:525
SVCPermissions getPermissions() const
Definition: ROEdge.h:274
void setRestrictions(const std::map< SUMOVehicleClass, double > *restrictions)
Sets the vehicle class specific speed limits of the edge.
Definition: ROEdge.h:143
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...
SUMOVehicleClass getVClass() const
Definition: RORoutable.h:114
const Position & getPosition() const
Returns the position of the node.
Definition: RONode.h:73
const int myIndex
The index (numeric id) of the edge.
Definition: ROEdge.h:496
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
const int myPriority
The edge priority (road class)
Definition: ROEdge.h:499
SUMOEmissionClass emissionClass
The emission class of this vehicle.
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:211
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:119