SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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-2015 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>
48 #include "RONode.h"
49 #include "ROVehicle.h"
50 
51 
52 // ===========================================================================
53 // class declarations
54 // ===========================================================================
55 class ROLane;
56 class ROEdge;
57 
58 typedef std::vector<ROEdge*> ROEdgeVector;
59 typedef std::vector<const ROEdge*> ConstROEdgeVector;
60 
61 // ===========================================================================
62 // class definitions
63 // ===========================================================================
73 class ROEdge : public Named {
74 public:
79  enum EdgeFunc {
94  };
95 
96 
104  ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index, const int priority);
105 
106 
108  virtual ~ROEdge();
109 
110 
112 
113 
122  virtual void addLane(ROLane* lane);
123 
124 
131  virtual void addSuccessor(ROEdge* s, std::string dir = "");
132 
133 
137  inline void setFunc(EdgeFunc func) {
138  myFunc = func;
139  }
140 
141 
145  inline void setRestrictions(const std::map<SUMOVehicleClass, SUMOReal>* restrictions) {
146  myRestrictions = restrictions;
147  }
148 
149 
151  inline bool isInternal() const {
152  return myFunc == ET_INTERNAL;
153  }
154 
156  inline bool isCrossing() const {
157  return myFunc == ET_CROSSING;
158  }
159 
161  inline bool isWalkingArea() const {
162  return myFunc == ET_WALKINGAREA;
163  }
164 
174  void buildTimeLines(const std::string& measure);
176 
177 
178 
180 
181 
186  EdgeFunc getFunc() const {
187  return myFunc;
188  }
189 
190 
194  SUMOReal getLength() const {
195  return myLength;
196  }
197 
201  unsigned int getNumericalID() const {
202  return myIndex;
203  }
204 
205 
209  SUMOReal getSpeed() const {
210  return mySpeed;
211  }
212 
213 
217  unsigned int getLaneNo() const {
218  return (unsigned int) myLanes.size();
219  }
220 
221 
228  bool isConnectedTo(const ROEdge* const e, const ROVehicle* const vehicle) const;
229 
230 
235  inline bool prohibits(const ROVehicle* const vehicle) const {
236  const SUMOVehicleClass vclass = vehicle->getVClass();
237  return (myCombinedPermissions & vclass) != vclass;
238  }
239 
241  return myCombinedPermissions;
242  }
243 
244 
249  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
251 
252 
253 
255 
256 
263  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
264 
265 
272  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
273 
274 
282  unsigned int getNumSuccessors() const;
283 
284 
287  const ROEdgeVector& getSuccessors() const {
288  return myFollowingEdges;
289  }
290 
291 
296  const ROEdgeVector& getSuccessors(SUMOVehicleClass vClass) const;
297 
298 
306  unsigned int getNumPredecessors() const;
307 
308 
313  const ROEdgeVector& getPredecessors() const {
314  return myApproachingEdges;
315  }
316 
317 
325  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const;
326 
327 
334  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const;
335 
336 
345  static inline SUMOReal getEffortStatic(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
346  return edge->getEffort(veh, time);
347  }
348 
349 
357  static inline SUMOReal getTravelTimeStatic(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
358  return edge->getTravelTime(veh, time);
359  }
360 
361 
367  inline SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const {
368  return myLength / MIN2(veh->getType()->maxSpeed, veh->getChosenSpeedFactor() * mySpeed);
369  }
370 
371 
372  template<PollutantsInterface::EmissionType ET>
373  static SUMOReal getEmissionEffort(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
374  SUMOReal ret = 0;
375  if (!edge->getStoredEffort(time, ret)) {
376  const SUMOVTypeParameter* const type = veh->getType();
377  const SUMOReal vMax = MIN2(type->maxSpeed, edge->mySpeed);
379  ret = PollutantsInterface::computeDefault(type->emissionClass, ET, vMax, accel, 0, edge->getTravelTime(veh, time)); // @todo: give correct slope
380  }
381  return ret;
382  }
383 
384 
385  static SUMOReal getNoiseEffort(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time);
387 
388 
390  SUMOReal getDistanceTo(const ROEdge* other) const;
391 
392 
394  static ROEdge* dictionary(size_t index);
395 
397  static size_t dictSize() {
398  return myEdges.size();
399  };
400 
401  static void setGlobalOptions(
402  bool useBoundariesOnOverrideTT,
403  bool useBoundariesOnOverrideE,
404  bool interpolate,
405  bool isParallel) {
406  myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT;
407  myUseBoundariesOnOverrideE = useBoundariesOnOverrideE;
408  myInterpolate = interpolate;
409  myAmParallel = isParallel;
410  }
411 
413  int getPriority() const {
414  return myPriority;
415  }
416 
417  const RONode* getFromJunction() const {
418  return myFromJunction;
419  }
420 
421  const RONode* getToJunction() const {
422  return myToJunction;
423  }
424 
425 
430  const std::vector<ROLane*>& getLanes() const {
431  return myLanes;
432  }
433 protected:
440  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const;
441 
442 
443 
444 protected:
448 
450  const unsigned int myIndex;
451 
453  const int myPriority;
454 
457 
460 
461 
468 
475 
477  static bool myInterpolate;
478 
480  static bool myAmParallel;
481 
483  static bool myHaveEWarned;
485  static bool myHaveTTWarned;
486 
489 
492 
495 
497  const std::map<SUMOVehicleClass, SUMOReal>* myRestrictions;
498 
500  std::vector<ROLane*> myLanes;
501 
504 
506 
507 
509  mutable std::map<SUMOVehicleClass, ROEdgeVector> myClassesSuccessorMap;
510 
511 private:
513  ROEdge(const ROEdge& src);
514 
516  ROEdge& operator=(const ROEdge& src);
517 
518 };
519 
520 
521 #endif
522 
523 /****************************************************************************/
524 
static ROEdgeVector myEdges
Definition: ROEdge.h:505
std::map< SUMOVehicleClass, ROEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
Definition: ROEdge.h:509
SUMOReal get(const SumoXMLAttr attr, const SUMOReal defaultValue) const
Returns the named value from the map, or the default if it is not contained there.
static bool myUseBoundariesOnOverrideTT
Whether overriding weight boundaries shall be reported.
Definition: ROEdge.h:467
A single lane the router may use.
Definition: ROLane.h:52
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
unsigned int getNumSuccessors() const
Returns the number of edges this edge is connected to.
Definition: ROEdge.cpp:216
SUMOReal getDistanceTo(const ROEdge *other) const
optimistic distance heuristic for use in routing
Definition: ROEdge.cpp:145
static SUMOReal getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Definition: ROEdge.cpp:180
SUMOVehicleClass getVClass() const
Definition: ROVehicle.h:132
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:477
Structure representing possible vehicle parameter.
int SVCPermissions
static ROEdge * dictionary(size_t index)
Returns the ROEdge at the index.
Definition: ROEdge.cpp:276
ValueTimeLine< SUMOReal > myTravelTimes
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:463
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition: ROEdge.cpp:99
static bool myAmParallel
Information whether we are routing multi-threaded.
Definition: ROEdge.h:480
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
EdgeFunc getFunc() const
Returns the function of the edge.
Definition: ROEdge.h:186
const SUMOVTypeParameter * getType() const
Returns the type of the vehicle.
Definition: ROVehicle.h:94
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
Definition: ROEdge.h:93
unsigned int getLaneNo() const
Returns the number of lanes this edge has.
Definition: ROEdge.h:217
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:59
void setFunc(EdgeFunc func)
Sets the function of the edge.
Definition: ROEdge.h:137
static bool myUseBoundariesOnOverrideE
Whether overriding weight boundaries shall be reported.
Definition: ROEdge.h:474
SVCPermissions myCombinedPermissions
The list of allowed vehicle classes combined across lanes.
Definition: ROEdge.h:503
const std::vector< ROLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: ROEdge.h:430
void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:128
ROEdgeVector myFollowingEdges
List of edges that may be approached from this edge.
Definition: ROEdge.h:488
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:161
static SUMOReal 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...
A vehicle as used by router.
Definition: ROVehicle.h:60
An internal edge which models walking areas for pedestrians.
Definition: ROEdge.h:89
const RONode * getToJunction() const
Definition: ROEdge.h:421
bool allFollowersProhibit(const ROVehicle *const vehicle) const
Returns whether this edge succeeding edges prohibit the given vehicle to pass them.
Definition: ROEdge.cpp:265
static SUMOReal getEffortStatic(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Returns the effort for the given edge.
Definition: ROEdge.h:345
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:151
const std::map< SUMOVehicleClass, SUMOReal > * myRestrictions
The vClass speed restrictions for this edge.
Definition: ROEdge.h:497
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:446
ValueTimeLine< SUMOReal > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:470
An edge where vehicles disappear (no vehicle may leave this edge)
Definition: ROEdge.h:87
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:465
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:336
An edge where vehicles are inserted at (no vehicle may come from back)
Definition: ROEdge.h:85
static bool myHaveEWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:483
SUMOReal myLength
The length of the edge.
Definition: ROEdge.h:459
bool myUsingETimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:472
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:313
T MIN2(T a, T b)
Definition: StdDefs.h:68
unsigned int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:201
static void setGlobalOptions(bool useBoundariesOnOverrideTT, bool useBoundariesOnOverrideE, bool interpolate, bool isParallel)
Definition: ROEdge.h:401
std::vector< ROLane * > myLanes
This edge&#39;s lanes.
Definition: ROEdge.h:500
ROEdge(const std::string &id, RONode *from, RONode *to, unsigned int index, const int priority)
Constructor.
Definition: ROEdge.cpp:69
const unsigned int myIndex
The index (numeric id) of the edge.
Definition: ROEdge.h:450
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:91
A basic edge for routing applications.
Definition: ROEdge.h:73
Base class for objects which have an id.
Definition: Named.h:45
SUMOReal mySpeed
The maximum speed allowed on this edge.
Definition: ROEdge.h:456
void setRestrictions(const std::map< SUMOVehicleClass, SUMOReal > *restrictions)
Sets the vehicle class specific speed limits of the edge.
Definition: ROEdge.h:145
SUMOReal maxSpeed
The vehicle type&#39;s maximum speed [m/s].
const RONode * getFromJunction() const
Definition: ROEdge.h:417
void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a weight value.
Definition: ROEdge.cpp:121
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:112
An internal edge which models pedestrian crossings.
Definition: ROEdge.h:91
RONode * myToJunction
Definition: ROEdge.h:447
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:413
SUMOReal getLength() const
Returns the length of the edge.
Definition: ROEdge.h:194
ROEdgeVector myApproachingEdges
List of edges that approached this edge.
Definition: ROEdge.h:491
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
Definition: ROEdge.h:235
SUMOReal getEffort(const ROVehicle *const veh, SUMOReal time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:135
static SUMOReal getEmissionEffort(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Definition: ROEdge.h:373
void buildTimeLines(const std::string &measure)
Builds the internal representation of the travel time/effort.
Definition: ROEdge.cpp:234
const ROEdgeVector & getSuccessors() const
Returns the following edges.
Definition: ROEdge.h:287
EdgeFunc
Possible functions of edges.
Definition: ROEdge.h:79
unsigned int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:225
bool getStoredEffort(SUMOReal time, SUMOReal &ret) const
Retrieves the stored effort.
Definition: ROEdge.cpp:191
static size_t dictSize()
Returns the number of edges.
Definition: ROEdge.h:397
SUMOReal getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition: ROVehicle.h:140
#define SUMOReal
Definition: config.h:215
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:156
SUMOReal getTravelTime(const ROVehicle *const veh, SUMOReal time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:156
static bool myHaveTTWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:485
A normal edge.
Definition: ROEdge.h:81
SVCPermissions getPermissions() const
Definition: ROEdge.h:240
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:367
An edge representing a whole district.
Definition: ROEdge.h:83
EdgeFunc myFunc
The function of the edge.
Definition: ROEdge.h:494
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:209
const int myPriority
The edge priority (road class)
Definition: ROEdge.h:453
SUMOEmissionClass emissionClass
The emission class of this vehicle.
static SUMOReal getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Returns the travel time for the given edge.
Definition: ROEdge.h:357