SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBOwnTLDef.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A traffic light logics which must be computed (only nodes/edges are given)
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NBOwnTLDef_h
23 #define NBOwnTLDef_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <set>
39 #include "NBNode.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
55 public:
62  NBOwnTLDef(const std::string& id,
63  const std::vector<NBNode*>& junctions,
64  SUMOTime offset,
65  TrafficLightType type);
66 
67 
74  NBOwnTLDef(const std::string& id, NBNode* junction, SUMOTime offset,
75  TrafficLightType type);
76 
77 
83  NBOwnTLDef(const std::string& id, SUMOTime offset, TrafficLightType type);
84 
85 
87  ~NBOwnTLDef();
88 
89 
94 
95 
98 
105  void remapRemoved(NBEdge* removed,
106  const EdgeVector& incoming, const EdgeVector& outgoing);
107 
108 
113  void setTLControllingInformation(const NBEdgeCont& ec) const;
115 
116 
119  void setSinglePhase() {
120  myHaveSinglePhase = true;
121  }
122 
124  static std::string addPedestrianPhases(NBTrafficLightLogic* logic, SUMOTime greenTime,
125  std::string state, const std::vector<NBNode::Crossing>& crossings, const EdgeVector& fromEdges, const EdgeVector& toEdges);
126 
128  static std::string patchStateForCrossings(const std::string& state,
129  const std::vector<NBNode::Crossing>& crossings, const EdgeVector& fromEdges, const EdgeVector& toEdges);
130 
131 protected:
134 
142  unsigned int brakingTimeSeconds);
143 
144 
148  void collectNodes();
149 
150 
155  void collectLinks();
156 
157 
165  void replaceRemoved(NBEdge* removed, int removedLane,
166  NBEdge* by, int byLane);
168 
169 
170 protected:
177 
178 
183  int getToPrio(const NBEdge* const e);
184 
185 
191  SUMOReal computeUnblockedWeightedStreamNumber(const NBEdge* const e1, const NBEdge* const e2);
192 
193 
198  std::pair<NBEdge*, NBEdge*> getBestCombination(const EdgeVector& edges);
199 
200 
208  std::pair<NBEdge*, NBEdge*> getBestPair(EdgeVector& incoming);
209 
210 
215  public:
220  int operator()(const NBEdge* const e1, const NBEdge* const e2) const {
221  if (e1->getJunctionPriority(e1->getToNode()) != e2->getJunctionPriority(e2->getToNode())) {
222  return e1->getJunctionPriority(e1->getToNode()) > e2->getJunctionPriority(e2->getToNode());
223  }
224  return e1->getID() > e2->getID();
225  }
226  };
227 
228 private:
231 
232 
233 };
234 
235 
236 #endif
237 
238 /****************************************************************************/
239 
static std::string patchStateForCrossings(const std::string &state, const std::vector< NBNode::Crossing > &crossings, const EdgeVector &fromEdges, const EdgeVector &toEdges)
compute phase state in regard to pedestrian crossings
Definition: NBOwnTLDef.cpp:395
void setSinglePhase()
Forces the definition not to compute an additional phase for left-movers.
Definition: NBOwnTLDef.h:119
A SUMO-compliant built logic for a traffic light.
The representation of a single edge during network building.
Definition: NBEdge.h:71
void collectNodes()
Collects the nodes participating in this traffic light.
Definition: NBOwnTLDef.cpp:443
The base class for traffic light logic definitions.
std::pair< NBEdge *, NBEdge * > getBestPair(EdgeVector &incoming)
Returns the combination of two edges from the given which has most unblocked streams.
Definition: NBOwnTLDef.cpp:158
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
const std::string & getID() const
Returns the id.
Definition: Named.h:60
int operator()(const NBEdge *const e1, const NBEdge *const e2) const
comparing operator
Definition: NBOwnTLDef.h:220
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces a removed edge/lane.
Definition: NBOwnTLDef.cpp:480
std::pair< NBEdge *, NBEdge * > getBestCombination(const EdgeVector &edges)
Returns the combination of two edges from the given which has most unblocked streams.
Definition: NBOwnTLDef.cpp:131
bool myHaveSinglePhase
Whether left-mover should not have an additional phase.
Definition: NBOwnTLDef.h:230
~NBOwnTLDef()
Destructor.
Definition: NBOwnTLDef.cpp:77
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
static std::string addPedestrianPhases(NBTrafficLightLogic *logic, SUMOTime greenTime, std::string state, const std::vector< NBNode::Crossing > &crossings, const EdgeVector &fromEdges, const EdgeVector &toEdges)
add 1 or 2 phases depending on the presence of pedestrian crossings
Definition: NBOwnTLDef.cpp:367
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
Definition: NBEdge.cpp:1142
SUMOReal computeUnblockedWeightedStreamNumber(const NBEdge *const e1, const NBEdge *const e2)
Returns how many streams outgoing from the edges can pass the junction without being blocked...
Definition: NBOwnTLDef.cpp:104
NBOwnTLDef(const std::string &id, const std::vector< NBNode * > &junctions, SUMOTime offset, TrafficLightType type)
Constructor.
Definition: NBOwnTLDef.cpp:55
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:368
void setTLControllingInformation(const NBEdgeCont &ec) const
Informs edges about being controlled by a tls.
Definition: NBOwnTLDef.cpp:463
void collectLinks()
Collects the links participating in this traffic light If a link could not be found.
Definition: NBOwnTLDef.cpp:447
SUMOReal getDirectionalWeight(LinkDirection dir)
Returns the weight of a stream given its direction.
Definition: NBOwnTLDef.cpp:87
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:38
NBTrafficLightLogic * myCompute(const NBEdgeCont &ec, unsigned int brakingTimeSeconds)
Computes the traffic light logic finally in dependence to the type.
Definition: NBOwnTLDef.cpp:187
int SUMOTime
Definition: SUMOTime.h:43
Represents a single node (junction) during network building.
Definition: NBNode.h:75
#define SUMOReal
Definition: config.h:215
A traffic light logics which must be computed (only nodes/edges are given)
Definition: NBOwnTLDef.h:54
Sorts edges by their priority within the node they end at.
Definition: NBOwnTLDef.h:214
void setParticipantsInformation()
Builds the list of participating nodes/edges/links.
Definition: NBOwnTLDef.cpp:453
int getToPrio(const NBEdge *const e)
Returns this edge's priority at the node it ends at.
Definition: NBOwnTLDef.cpp:81
TrafficLightType
void remapRemoved(NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.
Definition: NBOwnTLDef.cpp:475