SUMO - Simulation of Urban MObility
ROEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
12 // A basic edge for routing applications
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
15 // Copyright (C) 2002-2017 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 #ifndef ROEdge_h
26 #define ROEdge_h
27 
28 
29 // ===========================================================================
30 // included modules
31 // ===========================================================================
32 #ifdef _MSC_VER
33 #include <windows_config.h>
34 #else
35 #include <config.h>
36 #endif
37 
38 #include <string>
39 #include <map>
40 #include <vector>
41 #include <algorithm>
42 #include <utils/common/Named.h>
43 #include <utils/common/StdDefs.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:
83  enum EdgeFunc {
98  };
99 
100 
108  ROEdge(const std::string& id, RONode* from, RONode* to, int index, const int priority);
109 
110 
112  virtual ~ROEdge();
113 
114 
116 
117 
126  virtual void addLane(ROLane* lane);
127 
128 
135  virtual void addSuccessor(ROEdge* s, std::string dir = "");
136 
137 
141  inline void setFunc(EdgeFunc func) {
142  myFunc = func;
143  }
144 
145 
149  inline void setRestrictions(const std::map<SUMOVehicleClass, double>* restrictions) {
150  myRestrictions = restrictions;
151  }
152 
153 
155  inline bool isInternal() const {
156  return myFunc == ET_INTERNAL;
157  }
158 
160  inline bool isCrossing() const {
161  return myFunc == ET_CROSSING;
162  }
163 
165  inline bool isWalkingArea() const {
166  return myFunc == ET_WALKINGAREA;
167  }
168 
178  void buildTimeLines(const std::string& measure, const bool boundariesOverride);
180 
181 
182 
184 
185 
190  EdgeFunc getFunc() const {
191  return myFunc;
192  }
193 
194 
198  double getLength() const {
199  return myLength;
200  }
201 
205  int getNumericalID() const {
206  return myIndex;
207  }
208 
209 
213  double getSpeedLimit() const {
214  return mySpeed;
215  }
216 
218  // sufficient for the astar air-distance heuristic
219  double getLengthGeometryFactor() const {
220  if (myFromJunction != 0 && myToJunction != 0) {
222  } else {
223  return 1.0;
224  }
225  }
226 
231  inline double getVClassMaxSpeed(SUMOVehicleClass vclass) const {
232  if (myRestrictions != 0) {
233  std::map<SUMOVehicleClass, double>::const_iterator r = myRestrictions->find(vclass);
234  if (r != myRestrictions->end()) {
235  return r->second;
236  }
237  }
238  return mySpeed;
239  }
240 
241 
245  int getLaneNo() const {
246  return (int) myLanes.size();
247  }
248 
249 
256  bool isConnectedTo(const ROEdge* const e, const ROVehicle* const vehicle) const;
257 
258 
263  inline bool prohibits(const ROVehicle* const vehicle) const {
264  const SUMOVehicleClass vclass = vehicle->getVClass();
265  return (myCombinedPermissions & vclass) != vclass;
266  }
267 
269  return myCombinedPermissions;
270  }
271 
272 
277  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
279 
280 
281 
283 
284 
291  void addEffort(double value, double timeBegin, double timeEnd);
292 
293 
300  void addTravelTime(double value, double timeBegin, double timeEnd);
301 
302 
310  int getNumSuccessors() const;
311 
312 
315  const ROEdgeVector& getSuccessors() const {
316  return myFollowingEdges;
317  }
318 
319 
324  const ROEdgeVector& getSuccessors(SUMOVehicleClass vClass) const;
325 
326 
334  int getNumPredecessors() const;
335 
336 
341  const ROEdgeVector& getPredecessors() const {
342  return myApproachingEdges;
343  }
344 
345 
353  double getEffort(const ROVehicle* const veh, double time) const;
354 
355 
361  bool hasLoadedTravelTime(double time) const;
362 
363 
370  double getTravelTime(const ROVehicle* const veh, double time) const;
371 
372 
381  static inline double getEffortStatic(const ROEdge* const edge, const ROVehicle* const veh, double time) {
382  return edge->getEffort(veh, time);
383  }
384 
385 
393  static inline double getTravelTimeStatic(const ROEdge* const edge, const ROVehicle* const veh, double time) {
394  return edge->getTravelTime(veh, time);
395  }
396 
397 
403  inline double getMinimumTravelTime(const ROVehicle* const veh) const {
404  return myLength / MIN2(veh->getType()->maxSpeed, veh->getChosenSpeedFactor() * mySpeed);
405  }
406 
407 
408  template<PollutantsInterface::EmissionType ET>
409  static double getEmissionEffort(const ROEdge* const edge, const ROVehicle* const veh, double time) {
410  double ret = 0;
411  if (!edge->getStoredEffort(time, ret)) {
412  const SUMOVTypeParameter* const type = veh->getType();
413  const double vMax = MIN2(type->maxSpeed, edge->mySpeed);
415  ret = PollutantsInterface::computeDefault(type->emissionClass, ET, vMax, accel, 0, edge->getTravelTime(veh, time)); // @todo: give correct slope
416  }
417  return ret;
418  }
419 
420 
421  static double getNoiseEffort(const ROEdge* const edge, const ROVehicle* const veh, double time);
423 
424 
426  double getDistanceTo(const ROEdge* other) const;
427 
428 
430  static const ROEdgeVector& getAllEdges();
431 
433  static int dictSize() {
434  return (int)myEdges.size();
435  };
436 
437  static void setGlobalOptions(const bool interpolate) {
438  myInterpolate = interpolate;
439  }
440 
442  int getPriority() const {
443  return myPriority;
444  }
445 
446  const RONode* getFromJunction() const {
447  return myFromJunction;
448  }
449 
450  const RONode* getToJunction() const {
451  return myToJunction;
452  }
453 
454 
459  const std::vector<ROLane*>& getLanes() const {
460  return myLanes;
461  }
462 protected:
469  bool getStoredEffort(double time, double& ret) const;
470 
471 
472 
473 protected:
477 
479  const int myIndex;
480 
482  const int myPriority;
483 
485  double mySpeed;
486 
488  double myLength;
489 
490 
495 
500 
502  static bool myInterpolate;
503 
505  static bool myHaveEWarned;
507  static bool myHaveTTWarned;
508 
511 
514 
517 
519  const std::map<SUMOVehicleClass, double>* myRestrictions;
520 
522  std::vector<ROLane*> myLanes;
523 
526 
528 
529 
531  mutable std::map<SUMOVehicleClass, ROEdgeVector> myClassesSuccessorMap;
532 
533 #ifdef HAVE_FOX
534  mutable FXMutex myLock;
536 #endif
537 
538 private:
540  ROEdge(const ROEdge& src);
541 
543  ROEdge& operator=(const ROEdge& src);
544 
545 };
546 
547 
548 #endif
549 
550 /****************************************************************************/
551 
static ROEdgeVector myEdges
Definition: ROEdge.h:527
std::map< SUMOVehicleClass, ROEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: ROEdge.h:531
static double getEffortStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the effort for the given edge.
Definition: ROEdge.h:381
double getSpeedLimit() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:213
double myLength
The length of the edge.
Definition: ROEdge.h:488
void addTravelTime(double value, double timeBegin, double timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:121
A single lane the router may use.
Definition: ROLane.h:57
double getVClassMaxSpeed(SUMOVehicleClass vclass) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: ROEdge.h:231
double mySpeed
The maximum speed allowed on this edge.
Definition: ROEdge.h:485
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:519
double getLength() const
Returns the length of the edge.
Definition: ROEdge.h:198
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:502
Structure representing possible vehicle parameter.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition: ROEdge.cpp:92
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
EdgeFunc getFunc() const
Returns the function of the edge.
Definition: ROEdge.h:190
T MAX2(T a, T b)
Definition: StdDefs.h:70
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:215
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
Definition: ROEdge.h:97
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:155
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:62
void setFunc(EdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:141
SVCPermissions myCombinedPermissions
The list of allowed vehicle classes combined across lanes.
Definition: ROEdge.h:525
double getEffort(const ROVehicle *const veh, double time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:128
const std::vector< ROLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: ROEdge.h:459
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:510
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:165
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...
std::vector< ROEdge * > ROEdgeVector
Definition: ROEdge.h:59
A vehicle as used by router.
Definition: ROVehicle.h:60
An internal edge which models walking areas for pedestrians.
Definition: ROEdge.h:93
const RONode * getToJunction() const
Definition: ROEdge.h:450
bool allFollowersProhibit(const ROVehicle *const vehicle) const
Returns whether this edge succeeding edges prohibit the given vehicle to pass them.
Definition: ROEdge.cpp:267
bool getStoredEffort(double time, double &ret) const
Retrieves the stored effort.
Definition: ROEdge.cpp:190
static double getEmissionEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.h:409
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:155
static double getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the travel time for the given edge.
Definition: ROEdge.h:393
double maxSpeed
The vehicle type&#39;s maximum speed [m/s].
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:475
const SUMOVTypeParameter * getType() const
Returns the type of the vehicle.
Definition: RORoutable.h:83
An edge where vehicles disappear (no vehicle may leave this edge)
Definition: ROEdge.h:91
void buildTimeLines(const std::string &measure, const bool boundariesOverride)
Builds the internal representation of the travel time/effort.
Definition: ROEdge.cpp:233
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:494
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:325
An edge where vehicles are inserted at (no vehicle may come from back)
Definition: ROEdge.h:89
static bool myHaveEWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:505
bool myUsingETimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:499
std::vector< ROEdge * > ROEdgeVector
Definition: RODFRouteDesc.h:43
void addEffort(double value, double timeBegin, double timeEnd)
Adds a weight value.
Definition: ROEdge.cpp:114
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
Definition: ROEdge.h:341
T MIN2(T a, T b)
Definition: StdDefs.h:64
static int dictSize()
Returns the number of edges.
Definition: ROEdge.h:433
std::vector< ROLane * > myLanes
This edge&#39;s lanes.
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:403
ValueTimeLine< double > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:497
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:84
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:240
A basic edge for routing applications.
Definition: ROEdge.h:77
Base class for objects which have an id.
Definition: Named.h:46
bool hasLoadedTravelTime(double time) const
Returns whether a travel time for this edge was loaded.
Definition: ROEdge.cpp:149
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:138
const RONode * getFromJunction() const
Definition: ROEdge.h:446
double getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition: ROVehicle.h:124
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:105
An internal edge which models pedestrian crossings.
Definition: ROEdge.h:95
RONode * myToJunction
Definition: ROEdge.h:476
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:442
ROEdge(const std::string &id, RONode *from, RONode *to, int index, const int priority)
Constructor.
Definition: ROEdge.cpp:62
ROEdgeVector myApproachingEdges
List of edges that approached this edge.
Definition: ROEdge.h:513
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
Definition: ROEdge.h:263
int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:224
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
Definition: ROEdge.cpp:278
const ROEdgeVector & getSuccessors() const
Returns the following edges.
Definition: ROEdge.h:315
EdgeFunc
Possible functions of edges.
Definition: ROEdge.h:83
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.cpp:179
double getLengthGeometryFactor() const
return a lower bound on shape.length() / myLength that is
Definition: ROEdge.h:219
ValueTimeLine< double > myTravelTimes
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:492
static void setGlobalOptions(const bool interpolate)
Definition: ROEdge.h:437
int getLaneNo() const
Returns the number of lanes this edge has.
Definition: ROEdge.h:245
Base class for nodes used by the router.
Definition: RONode.h:53
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: ROEdge.h:160
static bool myHaveTTWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:507
A normal edge.
Definition: ROEdge.h:85
SVCPermissions getPermissions() const
Definition: ROEdge.h:268
An edge representing a whole district.
Definition: ROEdge.h:87
void setRestrictions(const std::map< SUMOVehicleClass, double > *restrictions)
Sets the vehicle class specific speed limits of the edge.
Definition: ROEdge.h:149
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:106
const Position & getPosition() const
Returns the position of the node.
Definition: RONode.h:74
const int myIndex
The index (numeric id) of the edge.
Definition: ROEdge.h:479
EdgeFunc myFunc
The function of the edge.
Definition: ROEdge.h:516
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
const int myPriority
The edge priority (road class)
Definition: ROEdge.h:482
SUMOEmissionClass emissionClass
The emission class of this vehicle.
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:205