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-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 EdgeType {
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  void setType(EdgeType type);
138 
140  inline bool isInternal() const {
141  return myType == ET_INTERNAL;
142  }
143 
145  inline bool isCrossing() const {
146  return myType == ET_CROSSING;
147  }
148 
150  inline bool isWalkingArea() const {
151  return myType == ET_WALKINGAREA;
152  }
153 
163  void buildTimeLines(const std::string& measure);
165 
166 
167 
169 
170 
175  EdgeType getType() const {
176  return myType;
177  }
178 
179 
183  SUMOReal getLength() const {
184  return myLength;
185  }
186 
190  unsigned int getNumericalID() const {
191  return myIndex;
192  }
193 
194 
198  SUMOReal getSpeed() const {
199  return mySpeed;
200  }
201 
202 
206  unsigned int getLaneNo() const {
207  return (unsigned int) myLanes.size();
208  }
209 
210 
214  RONode* getFromNode() const {
215  return myFromNode;
216  }
217 
218 
222  RONode* getToNode() const {
223  return myToNode;
224  }
225 
226 
233  bool isConnectedTo(const ROEdge* const e, const ROVehicle* const vehicle) const;
234 
235 
240  inline bool prohibits(const ROVehicle* const vehicle) const {
241  const SUMOVehicleClass vclass = vehicle->getVClass();
242  return (myCombinedPermissions & vclass) != vclass;
243  }
244 
246  return myCombinedPermissions;
247  }
248 
249 
254  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
256 
257 
258 
260 
261 
268  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
269 
270 
277  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
278 
279 
287  unsigned int getNumSuccessors() const;
288 
289 
292  const ROEdgeVector& getSuccessors() const {
293  return myFollowingEdges;
294  }
295 
296 
301  const ROEdgeVector& getSuccessors(SUMOVehicleClass vClass) const;
302 
303 
311  unsigned int getNumPredecessors() const;
312 
313 
318  const ROEdgeVector& getPredecessors() const {
319  return myApproachingEdges;
320  }
321 
322 
330  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const;
331 
332 
339  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const;
340 
341 
350  static inline SUMOReal getEffortStatic(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
351  return edge->getEffort(veh, time);
352  }
353 
354 
362  static inline SUMOReal getTravelTimeStatic(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
363  return edge->getTravelTime(veh, time);
364  }
365 
366 
372  inline SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const {
373  return myLength / MIN2(veh->getType()->maxSpeed, veh->getChosenSpeedFactor() * mySpeed);
374  }
375 
376 
377  template<PollutantsInterface::EmissionType ET>
378  static SUMOReal getEmissionEffort(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
379  SUMOReal ret = 0;
380  if (!edge->getStoredEffort(time, ret)) {
381  const SUMOVTypeParameter* const type = veh->getType();
382  const SUMOReal vMax = MIN2(type->maxSpeed, edge->mySpeed);
384  ret = PollutantsInterface::computeDefault(type->emissionClass, ET, vMax, accel, 0, edge->getTravelTime(veh, time)); // @todo: give correct slope
385  }
386  return ret;
387  }
388 
389 
390  static SUMOReal getNoiseEffort(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time);
392 
393 
395  SUMOReal getDistanceTo(const ROEdge* other) const;
396 
397 
399  static ROEdge* dictionary(size_t index);
400 
402  static size_t dictSize() {
403  return myEdges.size();
404  };
405 
406  static void setTimeLineOptions(
407  bool useBoundariesOnOverrideTT,
408  bool useBoundariesOnOverrideE,
409  bool interpolate) {
410  myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT;
411  myUseBoundariesOnOverrideE = useBoundariesOnOverrideE;
412  myInterpolate = interpolate;
413  }
414 
416  int getPriority() const {
417  return myPriority;
418  }
419 
420  const RONode* getFromJunction() const {
421  return myFromJunction;
422  }
423 
424  const RONode* getToJunction() const {
425  return myToJunction;
426  }
427 
428 
429  void setJunctions(RONode* from, RONode* to) {
430  myFromJunction = from;
431  myToJunction = to;
432  }
433 
438  const std::vector<ROLane*>& getLanes() const {
439  return myLanes;
440  }
441 protected:
448  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const;
449 
450 
451 
452 protected:
454  RONode* const myFromNode, * const myToNode;
455 
457  const unsigned int myIndex;
458 
460  const int myPriority;
461 
464 
467 
468 
475 
482 
484  static bool myInterpolate;
485 
487  static bool myHaveEWarned;
489  static bool myHaveTTWarned;
490 
493 
496 
499 
501  std::vector<ROLane*> myLanes;
502 
505 
507 
511 
513  typedef std::map<SUMOVehicleClass, ROEdgeVector> ClassesSuccesorMap;
514  mutable ClassesSuccesorMap myClassesSuccessorMap;
515 
516 private:
518  ROEdge(const ROEdge& src);
519 
521  ROEdge& operator=(const ROEdge& src);
522 
523 };
524 
525 
526 #endif
527 
528 /****************************************************************************/
529 
static ROEdgeVector myEdges
Definition: ROEdge.h:506
RONode * getToNode() const
Returns the node this edge ends at.
Definition: ROEdge.h:222
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.
EdgeType getType() const
Returns the type of the edge.
Definition: ROEdge.h:175
std::map< SUMOVehicleClass, ROEdgeVector > ClassesSuccesorMap
The successors available for a given vClass.
Definition: ROEdge.h:513
static bool myUseBoundariesOnOverrideTT
Whether overriding weight boundaries shall be reported.
Definition: ROEdge.h:474
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:207
SUMOReal getDistanceTo(const ROEdge *other) const
optimistic distance heuristic for use in routing
Definition: ROEdge.cpp:136
static SUMOReal getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Definition: ROEdge.cpp:171
void setJunctions(RONode *from, RONode *to)
Definition: ROEdge.h:429
SUMOVehicleClass getVClass() const
Definition: ROVehicle.h:132
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:484
Structure representing possible vehicle parameter.
EdgeType
Possible types of edges.
Definition: ROEdge.h:79
int SVCPermissions
static ROEdge * dictionary(size_t index)
Returns the ROEdge at the index.
Definition: ROEdge.cpp:273
ValueTimeLine< SUMOReal > myTravelTimes
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:470
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition: ROEdge.cpp:90
SUMOVehicleClass vehicleClass
The vehicle's class.
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:206
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:59
static bool myUseBoundariesOnOverrideE
Whether overriding weight boundaries shall be reported.
Definition: ROEdge.h:481
SVCPermissions myCombinedPermissions
The list of allowed vehicle classes combined across lanes.
Definition: ROEdge.h:504
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
Definition: ROEdge.h:438
void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:119
An internal edge which models walking areas for pedestrians.
Definition: ROEdge.h:89
RONode * getFromNode() const
Returns the node this edge starts at.
Definition: ROEdge.h:214
ROEdgeVector myFollowingEdges
List of edges that may be approached from this edge.
Definition: ROEdge.h:492
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:150
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...
An edge where vehicles are inserted at (no vehicle may come from back)
Definition: ROEdge.h:85
std::vector< ROEdge * > ROEdgeVector
Definition: ROEdge.h:56
A vehicle as used by router.
Definition: ROVehicle.h:60
void setType(EdgeType type)
Sets the type of te edge.
Definition: ROEdge.cpp:225
const RONode * getToJunction() const
Definition: ROEdge.h:424
bool allFollowersProhibit(const ROVehicle *const vehicle) const
Returns whether this edge succeeding edges prohibit the given vehicle to pass them.
Definition: ROEdge.cpp:262
static SUMOReal getEffortStatic(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Returns the effort for the given edge.
Definition: ROEdge.h:350
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:140
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:509
ValueTimeLine< SUMOReal > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:477
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:472
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:312
static bool myHaveEWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:487
SUMOReal myLength
The length of the edge.
Definition: ROEdge.h:466
bool myUsingETimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:479
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:318
T MIN2(T a, T b)
Definition: StdDefs.h:68
static void setTimeLineOptions(bool useBoundariesOnOverrideTT, bool useBoundariesOnOverrideE, bool interpolate)
Definition: ROEdge.h:406
unsigned int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:190
An edge representing a whole district.
Definition: ROEdge.h:83
ClassesSuccesorMap myClassesSuccessorMap
Definition: ROEdge.h:514
std::vector< ROLane * > myLanes
This edge's lanes.
Definition: ROEdge.h:501
ROEdge(const std::string &id, RONode *from, RONode *to, unsigned int index, const int priority)
Constructor.
Definition: ROEdge.cpp:67
const unsigned int myIndex
The index (numeric id) of the edge.
Definition: ROEdge.h:457
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:82
A basic edge for routing applications.
Definition: ROEdge.h:73
Base class for objects which have an id.
Definition: Named.h:45
RONode *const *const myToNode
Definition: ROEdge.h:454
SUMOReal mySpeed
The maximum speed allowed on this edge.
Definition: ROEdge.h:463
SUMOReal maxSpeed
The vehicle type's maximum speed [m/s].
const RONode * getFromJunction() const
Definition: ROEdge.h:420
void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a weight value.
Definition: ROEdge.cpp:112
virtual void addSuccessor(ROEdge *s, std::string dir="")
Adds information about a connected edge.
Definition: ROEdge.cpp:103
RONode * myToJunction
Definition: ROEdge.h:510
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:416
SUMOReal getLength() const
Returns the length of the edge.
Definition: ROEdge.h:183
ROEdgeVector myApproachingEdges
List of edges that approached this edge.
Definition: ROEdge.h:495
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
Definition: ROEdge.h:240
A normal edge.
Definition: ROEdge.h:81
SUMOReal getEffort(const ROVehicle *const veh, SUMOReal time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:126
static SUMOReal getEmissionEffort(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Definition: ROEdge.h:378
An internal edge which models pedestrian crossings.
Definition: ROEdge.h:91
void buildTimeLines(const std::string &measure)
Builds the internal representation of the travel time/effort.
Definition: ROEdge.cpp:231
const ROEdgeVector & getSuccessors() const
Returns the following edges.
Definition: ROEdge.h:292
unsigned int getNumPredecessors() const
Returns the number of edges connected to this edge.
Definition: ROEdge.cpp:216
bool getStoredEffort(SUMOReal time, SUMOReal &ret) const
Retrieves the stored effort.
Definition: ROEdge.cpp:182
RONode *const myFromNode
The nodes this edge is connecting.
Definition: ROEdge.h:454
static size_t dictSize()
Returns the number of edges.
Definition: ROEdge.h:402
SUMOReal getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition: ROVehicle.h:140
#define SUMOReal
Definition: config.h:218
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:145
SUMOReal getTravelTime(const ROVehicle *const veh, SUMOReal time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:147
An edge where vehicles disappear (no vehicle may leave this edge)
Definition: ROEdge.h:87
static bool myHaveTTWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:489
SVCPermissions getPermissions() const
Definition: ROEdge.h:245
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:372
EdgeType myType
The type of the edge.
Definition: ROEdge.h:498
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:198
const int myPriority
The edge priority (road class)
Definition: ROEdge.h:460
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:362