SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-2016 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, SUMOReal>* 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  SUMOReal getLength() const {
199  return myLength;
200  }
201 
205  int getNumericalID() const {
206  return myIndex;
207  }
208 
209 
213  SUMOReal getSpeed() const {
214  return mySpeed;
215  }
216 
222  if (myRestrictions != 0) {
223  std::map<SUMOVehicleClass, SUMOReal>::const_iterator r = myRestrictions->find(vclass);
224  if (r != myRestrictions->end()) {
225  return r->second;
226  }
227  }
228  return mySpeed;
229  }
230 
231 
235  int getLaneNo() const {
236  return (int) myLanes.size();
237  }
238 
239 
246  bool isConnectedTo(const ROEdge* const e, const ROVehicle* const vehicle) const;
247 
248 
253  inline bool prohibits(const ROVehicle* const vehicle) const {
254  const SUMOVehicleClass vclass = vehicle->getVClass();
255  return (myCombinedPermissions & vclass) != vclass;
256  }
257 
259  return myCombinedPermissions;
260  }
261 
262 
267  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
269 
270 
271 
273 
274 
281  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
282 
283 
290  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
291 
292 
300  int getNumSuccessors() const;
301 
302 
305  const ROEdgeVector& getSuccessors() const {
306  return myFollowingEdges;
307  }
308 
309 
314  const ROEdgeVector& getSuccessors(SUMOVehicleClass vClass) const;
315 
316 
324  int getNumPredecessors() const;
325 
326 
331  const ROEdgeVector& getPredecessors() const {
332  return myApproachingEdges;
333  }
334 
335 
343  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const;
344 
345 
351  bool hasLoadedTravelTime(SUMOReal time) const;
352 
353 
360  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const;
361 
362 
371  static inline SUMOReal getEffortStatic(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
372  return edge->getEffort(veh, time);
373  }
374 
375 
383  static inline SUMOReal getTravelTimeStatic(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
384  return edge->getTravelTime(veh, time);
385  }
386 
387 
393  inline SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const {
394  return myLength / MIN2(veh->getType()->maxSpeed, veh->getChosenSpeedFactor() * mySpeed);
395  }
396 
397 
398  template<PollutantsInterface::EmissionType ET>
399  static SUMOReal getEmissionEffort(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
400  SUMOReal ret = 0;
401  if (!edge->getStoredEffort(time, ret)) {
402  const SUMOVTypeParameter* const type = veh->getType();
403  const SUMOReal vMax = MIN2(type->maxSpeed, edge->mySpeed);
405  ret = PollutantsInterface::computeDefault(type->emissionClass, ET, vMax, accel, 0, edge->getTravelTime(veh, time)); // @todo: give correct slope
406  }
407  return ret;
408  }
409 
410 
411  static SUMOReal getNoiseEffort(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time);
413 
414 
416  SUMOReal getDistanceTo(const ROEdge* other) const;
417 
418 
420  static const ROEdgeVector& getAllEdges();
421 
423  static int dictSize() {
424  return (int)myEdges.size();
425  };
426 
427  static void setGlobalOptions(const bool interpolate) {
428  myInterpolate = interpolate;
429  }
430 
432  int getPriority() const {
433  return myPriority;
434  }
435 
436  const RONode* getFromJunction() const {
437  return myFromJunction;
438  }
439 
440  const RONode* getToJunction() const {
441  return myToJunction;
442  }
443 
444 
449  const std::vector<ROLane*>& getLanes() const {
450  return myLanes;
451  }
452 protected:
459  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const;
460 
461 
462 
463 protected:
467 
469  const int myIndex;
470 
472  const int myPriority;
473 
476 
479 
480 
485 
490 
492  static bool myInterpolate;
493 
495  static bool myHaveEWarned;
497  static bool myHaveTTWarned;
498 
501 
504 
507 
509  const std::map<SUMOVehicleClass, SUMOReal>* myRestrictions;
510 
512  std::vector<ROLane*> myLanes;
513 
516 
518 
519 
521  mutable std::map<SUMOVehicleClass, ROEdgeVector> myClassesSuccessorMap;
522 
523 #ifdef HAVE_FOX
524  mutable FXMutex myLock;
526 #endif
527 
528 private:
530  ROEdge(const ROEdge& src);
531 
533  ROEdge& operator=(const ROEdge& src);
534 
535 };
536 
537 
538 #endif
539 
540 /****************************************************************************/
541 
static ROEdgeVector myEdges
Definition: ROEdge.h:517
std::map< SUMOVehicleClass, ROEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: ROEdge.h:521
A single lane the router may use.
Definition: ROLane.h:57
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
SUMOReal getDistanceTo(const ROEdge *other) const
optimistic distance heuristic for use in routing
Definition: ROEdge.cpp:142
static SUMOReal getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Definition: ROEdge.cpp:183
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:492
Structure representing possible vehicle parameter.
SUMOReal getCFParam(const SumoXMLAttr attr, const SUMOReal defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
int SVCPermissions
ValueTimeLine< SUMOReal > myTravelTimes
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:482
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition: ROEdge.cpp:96
SUMOVehicleClass vehicleClass
The vehicle's class.
EdgeFunc getFunc() const
Returns the function of the edge.
Definition: ROEdge.h:190
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:219
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
Definition: ROEdge.h:97
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:515
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
Definition: ROEdge.h:449
void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:125
ROEdgeVector myFollowingEdges
List of edges that may be approached from this edge.
Definition: ROEdge.h:500
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:165
static SUMOReal getDefaultImperfection(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default driver's imperfection (sigma or epsilon in Krauss' model) for the given vehicle c...
std::vector< ROEdge * > ROEdgeVector
Definition: ROEdge.h:59
bool hasLoadedTravelTime(SUMOReal time) const
Returns whether a travel time for this edge was loaded.
Definition: ROEdge.cpp:153
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:440
bool allFollowersProhibit(const ROVehicle *const vehicle) const
Returns whether this edge succeeding edges prohibit the given vehicle to pass them.
Definition: ROEdge.cpp:271
static SUMOReal getEffortStatic(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Returns the effort for the given edge.
Definition: ROEdge.h:371
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:155
const std::map< SUMOVehicleClass, SUMOReal > * myRestrictions
The vClass speed restrictions for this edge.
Definition: ROEdge.h:509
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:465
ValueTimeLine< SUMOReal > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:487
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:237
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:484
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:329
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:495
SUMOReal myLength
The length of the edge.
Definition: ROEdge.h:478
bool myUsingETimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:489
static SUMOReal computeDefault(const SUMOEmissionClass c, const EmissionType e, const double v, const double a, const double slope, const SUMOReal tt)
Returns the amount of emitted pollutant given the vehicle type and default values for the state (in m...
std::vector< ROEdge * > ROEdgeVector
Definition: RODFRouteDesc.h:43
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
Definition: ROEdge.h:331
T MIN2(T a, T b)
Definition: StdDefs.h:69
static int dictSize()
Returns the number of edges.
Definition: ROEdge.h:423
std::vector< ROLane * > myLanes
This edge's lanes.
Definition: ROEdge.h:512
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:88
A basic edge for routing applications.
Definition: ROEdge.h:77
Base class for objects which have an id.
Definition: Named.h:46
SUMOReal mySpeed
The maximum speed allowed on this edge.
Definition: ROEdge.h:475
void setRestrictions(const std::map< SUMOVehicleClass, SUMOReal > *restrictions)
Sets the vehicle class specific speed limits of the edge.
Definition: ROEdge.h:149
SUMOReal maxSpeed
The vehicle type's maximum speed [m/s].
const RONode * getFromJunction() const
Definition: ROEdge.h:436
void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a weight value.
Definition: ROEdge.cpp:118
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:109
An internal edge which models pedestrian crossings.
Definition: ROEdge.h:95
RONode * myToJunction
Definition: ROEdge.h:466
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:432
SUMOReal getLength() const
Returns the length of the edge.
Definition: ROEdge.h:198
ROEdge(const std::string &id, RONode *from, RONode *to, int index, const int priority)
Constructor.
Definition: ROEdge.cpp:66
ROEdgeVector myApproachingEdges
List of edges that approached this edge.
Definition: ROEdge.h:503
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
Definition: ROEdge.h:253
int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:228
SUMOReal getEffort(const ROVehicle *const veh, SUMOReal time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:132
static SUMOReal getEmissionEffort(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Definition: ROEdge.h:399
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
Definition: ROEdge.cpp:282
const ROEdgeVector & getSuccessors() const
Returns the following edges.
Definition: ROEdge.h:305
EdgeFunc
Possible functions of edges.
Definition: ROEdge.h:83
bool getStoredEffort(SUMOReal time, SUMOReal &ret) const
Retrieves the stored effort.
Definition: ROEdge.cpp:194
static void setGlobalOptions(const bool interpolate)
Definition: ROEdge.h:427
SUMOReal getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition: ROVehicle.h:124
int getLaneNo() const
Returns the number of lanes this edge has.
Definition: ROEdge.h:235
#define SUMOReal
Definition: config.h:214
static SUMOReal getDefaultAccel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default acceleration for the given vehicle class This needs to be a function because the ...
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
SUMOReal getTravelTime(const ROVehicle *const veh, SUMOReal time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:159
static bool myHaveTTWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:497
A normal edge.
Definition: ROEdge.h:85
SVCPermissions getPermissions() const
Definition: ROEdge.h:258
SUMOReal 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:393
An edge representing a whole district.
Definition: ROEdge.h:87
SUMOVehicleClass getVClass() const
Definition: RORoutable.h:106
const int myIndex
The index (numeric id) of the edge.
Definition: ROEdge.h:469
EdgeFunc myFunc
The function of the edge.
Definition: ROEdge.h:506
SUMOReal getVClassMaxSpeed(SUMOVehicleClass vclass) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
Definition: ROEdge.h:221
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:213
const int myPriority
The edge priority (road class)
Definition: ROEdge.h:472
SUMOEmissionClass emissionClass
The emission class of this vehicle.
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:205
static SUMOReal getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Returns the travel time for the given edge.
Definition: ROEdge.h:383