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-2014 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 
57 
58 // ===========================================================================
59 // class definitions
60 // ===========================================================================
70 class ROEdge : public Named {
71 public:
76  enum EdgeType {
91  };
92 
93 
101  ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index, const int priority);
102 
103 
105  virtual ~ROEdge();
106 
107 
109 
110 
119  virtual void addLane(ROLane* lane);
120 
121 
128  virtual void addSuccessor(ROEdge* s, std::string dir = "");
129 
130 
134  void setType(EdgeType type);
135 
137  inline bool isInternal() const {
138  return myType == ET_INTERNAL;
139  }
140 
142  inline bool isCrossing() const {
143  return myType == ET_CROSSING;
144  }
145 
147  inline bool isWalkingArea() const {
148  return myType == ET_WALKINGAREA;
149  }
150 
160  void buildTimeLines(const std::string& measure);
162 
163 
164 
166 
167 
172  EdgeType getType() const {
173  return myType;
174  }
175 
176 
180  SUMOReal getLength() const {
181  return myLength;
182  }
183 
187  unsigned int getNumericalID() const {
188  return myIndex;
189  }
190 
191 
195  SUMOReal getSpeed() const {
196  return mySpeed;
197  }
198 
199 
203  unsigned int getLaneNo() const {
204  return (unsigned int) myLanes.size();
205  }
206 
207 
211  RONode* getFromNode() const {
212  return myFromNode;
213  }
214 
215 
219  RONode* getToNode() const {
220  return myToNode;
221  }
222 
223 
229  bool isConnectedTo(const ROEdge* const e) const {
230  return std::find(myFollowingEdges.begin(), myFollowingEdges.end(), e) != myFollowingEdges.end();
231  }
232 
233 
238  inline bool prohibits(const ROVehicle* const vehicle) const {
239  const SUMOVehicleClass vclass = vehicle->getVClass();
240  return (myCombinedPermissions & vclass) != vclass;
241  }
242 
244  return myCombinedPermissions;
245  }
246 
247 
252  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
254 
255 
256 
258 
259 
266  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
267 
268 
275  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
276 
277 
285  unsigned int getNumSuccessors() const;
286 
287 
292  ROEdge* getSuccessor(unsigned int pos) const {
293  return myFollowingEdges[pos];
294  }
295 
296 
304  unsigned int getNumPredecessors() const;
305 
306 
311  ROEdge* getPredecessor(unsigned int pos) const {
312  return myApproachingEdges[pos];
313  }
314 
315 
323  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const;
324 
325 
332  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const;
333 
334 
343  static inline SUMOReal getEffortStatic(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
344  return edge->getEffort(veh, time);
345  }
346 
347 
355  static inline SUMOReal getTravelTimeStatic(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
356  return edge->getTravelTime(veh, time);
357  }
358 
359 
365  inline SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const {
366  return myLength / MIN2(veh->getType()->maxSpeed, veh->getChosenSpeedFactor() * mySpeed);
367  }
368 
369 
370  template<PollutantsInterface::EmissionType ET>
371  static SUMOReal getEmissionEffort(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time) {
372  SUMOReal ret = 0;
373  if (!edge->getStoredEffort(time, ret)) {
374  const SUMOVTypeParameter* const type = veh->getType();
375  const SUMOReal vMax = MIN2(type->maxSpeed, edge->mySpeed);
377  ret = PollutantsInterface::computeDefault(type->emissionClass, ET, vMax, accel, 0, edge->getTravelTime(veh, time)); // @todo: give correct slope
378  }
379  return ret;
380  }
381 
382 
383  static SUMOReal getNoiseEffort(const ROEdge* const edge, const ROVehicle* const veh, SUMOReal time);
385 
386 
388  SUMOReal getDistanceTo(const ROEdge* other) const;
389 
390 
392  static ROEdge* dictionary(size_t index);
393 
395  static size_t dictSize() {
396  return myEdges.size();
397  };
398 
399  static void setTimeLineOptions(
400  bool useBoundariesOnOverrideTT,
401  bool useBoundariesOnOverrideE,
402  bool interpolate) {
403  myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT;
404  myUseBoundariesOnOverrideE = useBoundariesOnOverrideE;
405  myInterpolate = interpolate;
406  }
407 
409  int getPriority() const {
410  return myPriority;
411  }
412 
413  const RONode* getFromJunction() const {
414  return myFromJunction;
415  }
416 
417  const RONode* getToJunction() const {
418  return myToJunction;
419  }
420 
421 
422  void setJunctions(RONode* from, RONode* to) {
423  myFromJunction = from;
424  myToJunction = to;
425  }
426 
431  const std::vector<ROLane*>& getLanes() const {
432  return myLanes;
433  }
434 protected:
441  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const;
442 
443 
444 
445 protected:
447  RONode* const myFromNode, * const myToNode;
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 myHaveEWarned;
482  static bool myHaveTTWarned;
483 
485  std::vector<ROEdge*> myFollowingEdges;
486 
488  std::vector<ROEdge*> myApproachingEdges;
489 
492 
494  std::vector<ROLane*> myLanes;
495 
498 
499  static std::vector<ROEdge*> myEdges;
500 
504 
505 
506 private:
508  ROEdge(const ROEdge& src);
509 
511  ROEdge& operator=(const ROEdge& src);
512 
513 };
514 
515 
516 #endif
517 
518 /****************************************************************************/
519 
RONode * getToNode() const
Returns the node this edge ends at.
Definition: ROEdge.h:219
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:172
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:207
SUMOReal getDistanceTo(const ROEdge *other) const
optimistic distance heuristic for use in routing
Definition: ROEdge.cpp:136
static std::vector< ROEdge * > myEdges
Definition: ROEdge.h:499
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:422
SUMOVehicleClass getVClass() const
Definition: ROVehicle.h:131
static bool myInterpolate
Information whether to interpolate at interval boundaries.
Definition: ROEdge.h:477
Structure representing possible vehicle parameter.
EdgeType
Possible types of edges.
Definition: ROEdge.h:76
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:463
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition: ROEdge.cpp:90
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
const SUMOVTypeParameter * getType() const
Returns the type of the vehicle.
Definition: ROVehicle.h:93
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
Definition: ROEdge.h:90
std::vector< ROEdge * > myApproachingEdges
List of edges that approached this edge.
Definition: ROEdge.h:488
bool isConnectedTo(const ROEdge *const e) const
returns the information whether this edge is directly connected to the given
Definition: ROEdge.h:229
unsigned int getLaneNo() const
Returns the number of lanes this edge has.
Definition: ROEdge.h:203
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:497
const std::vector< ROLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: ROEdge.h:431
void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:119
ROEdge * getSuccessor(unsigned int pos) const
Returns the edge at the given position from the list of reachable edges.
Definition: ROEdge.h:292
An internal edge which models walking areas for pedestrians.
Definition: ROEdge.h:86
RONode * getFromNode() const
Returns the node this edge starts at.
Definition: ROEdge.h:211
bool isWalkingArea() const
return whether this edge is walking area
Definition: ROEdge.h:147
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...
An edge where vehicles are inserted at (no vehicle may come from back)
Definition: ROEdge.h:82
A vehicle as used by router.
Definition: ROVehicle.h:59
void setType(EdgeType type)
Sets the type of te edge.
Definition: ROEdge.cpp:225
const RONode * getToJunction() const
Definition: ROEdge.h:417
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:343
bool isInternal() const
return whether this edge is an internal edge
Definition: ROEdge.h:137
RONode * myFromJunction
the junctions for this edge
Definition: ROEdge.h:502
ValueTimeLine< SUMOReal > myEfforts
Container storing passing time varying over time for the edge.
Definition: ROEdge.h:470
bool myUsingTTTimeLine
Information whether the time line shall be used instead of the length value.
Definition: ROEdge.h:465
static bool myHaveEWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:480
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...
ROEdge * getPredecessor(unsigned int pos) const
Returns the edge at the given position from the list of incoming edges.
Definition: ROEdge.h:311
T MIN2(T a, T b)
Definition: StdDefs.h:68
static void setTimeLineOptions(bool useBoundariesOnOverrideTT, bool useBoundariesOnOverrideE, bool interpolate)
Definition: ROEdge.h:399
unsigned int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition: ROEdge.h:187
An edge representing a whole district.
Definition: ROEdge.h:80
std::vector< ROLane * > myLanes
This edge&#39;s lanes.
Definition: ROEdge.h:494
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:450
virtual ~ROEdge()
Destructor.
Definition: ROEdge.cpp:82
A basic edge for routing applications.
Definition: ROEdge.h:70
Base class for objects which have an id.
Definition: Named.h:45
RONode *const *const myToNode
Definition: ROEdge.h:447
SUMOReal mySpeed
The maximum speed allowed on this edge.
Definition: ROEdge.h:456
SUMOReal maxSpeed
The vehicle type&#39;s maximum speed [m/s].
std::vector< ROEdge * > myFollowingEdges
List of edges that may be approached from this edge.
Definition: ROEdge.h:485
const RONode * getFromJunction() const
Definition: ROEdge.h:413
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:503
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:409
SUMOReal getLength() const
Returns the length of the edge.
Definition: ROEdge.h:180
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
Definition: ROEdge.h:238
A normal edge.
Definition: ROEdge.h:78
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:371
An internal edge which models pedestrian crossings.
Definition: ROEdge.h:88
void buildTimeLines(const std::string &measure)
Builds the internal representation of the travel time/effort.
Definition: ROEdge.cpp:231
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:447
static size_t dictSize()
Returns the number of edges.
Definition: ROEdge.h:395
SUMOReal getChosenSpeedFactor() const
Returns an upper bound for the speed factor of this vehicle.
Definition: ROVehicle.h:139
#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:51
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: ROEdge.h:142
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:84
static bool myHaveTTWarned
Information whether the edge has reported missing weights.
Definition: ROEdge.h:482
SVCPermissions getPermissions() const
Definition: ROEdge.h:243
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:365
EdgeType myType
The type of the edge.
Definition: ROEdge.h:491
ROEdge & operator=(const ROEdge &src)
Invalidated assignment operator.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:195
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:355