SUMO - Simulation of Urban MObility
NBTrafficLightDefinition.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // The base class for traffic light logic definitions
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 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 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <vector>
34 #include <string>
35 #include <algorithm>
36 #include <cassert>
37 #include <iterator>
39 #include <utils/common/ToString.h>
43 #include "NBTrafficLightLogic.h"
44 #include "NBOwnTLDef.h"
45 #include "NBContHelper.h"
46 
47 //#define DEBUG_RIGHT_OF_WAY
48 #define DEBUGCOND true
49 
50 // ===========================================================================
51 // static members
52 // ===========================================================================
53 const std::string NBTrafficLightDefinition::DefaultProgramID = "0";
54 const std::string NBTrafficLightDefinition::DummyID = "dummy";
56 
57 // ===========================================================================
58 // method definitions
59 // ===========================================================================
61  const std::vector<NBNode*>& junctions, const std::string& programID,
62  SUMOTime offset, TrafficLightType type) :
63  Named(id),
64  myControlledNodes(junctions),
65  mySubID(programID), myOffset(offset),
66  myType(type),
67  myNeedsContRelationReady(false),
68  myRightOnRedConflictsReady(false) {
69  std::vector<NBNode*>::iterator i = myControlledNodes.begin();
70  while (i != myControlledNodes.end()) {
71  for (std::vector<NBNode*>::iterator j = i + 1; j != myControlledNodes.end();) {
72  if (*i == *j) {
73  j = myControlledNodes.erase(j);
74  } else {
75  j++;
76  }
77  }
78  i++;
79  }
81  for (std::vector<NBNode*>::const_iterator i = junctions.begin(); i != junctions.end(); i++) {
82  (*i)->addTrafficLight(this);
83  }
84 }
85 
86 
88  NBNode* junction, const std::string& programID, SUMOTime offset, TrafficLightType type) :
89  Named(id),
90  mySubID(programID),
91  myOffset(offset),
92  myType(type),
95  addNode(junction);
96 }
97 
98 
99 NBTrafficLightDefinition::NBTrafficLightDefinition(const std::string& id, const std::string& programID,
100  SUMOTime offset, TrafficLightType type) :
101  Named(id),
102  mySubID(programID),
103  myOffset(offset),
104  myType(type),
107 }
108 
109 
111 
112 
115  // it is not really a traffic light if no incoming edge exists
116  if (amInvalid()) {
117  // make a copy of myControlledNodes because it will be modified;
118  std::vector<NBNode*> nodes = myControlledNodes;
119  for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
120  (*it)->removeTrafficLight(this);
121  }
122  WRITE_WARNING("The traffic light '" + getID() + "' does not control any links; it will not be build.");
123  return 0;
124  }
125  // compute the time needed to brake
126  int brakingTime = computeBrakingTime(oc.getFloat("tls.yellow.min-decel"));
127  // perform the computation depending on whether the traffic light
128  // definition was loaded or shall be computed new completely
129  if (!oc.isDefault("tls.yellow.time")) {
130  brakingTime = oc.getInt("tls.yellow.time");
131  }
132  NBTrafficLightLogic* ret = myCompute(brakingTime);
133  ret->addParameter(getMap());
134  return ret;
135 }
136 
137 
138 bool
140  return myControlledLinks.size() == 0;
141 }
142 
143 
144 int
147  if (vmax < 71 / 3.6) {
148  // up to 50kmh: 3 seconds , 60km/h: 4, 70kmh: 5
149  // @note: these are German regulations, other countries may differ
150  return 3 + (int)MAX2(0.0, (floor((vmax - 50 / 3.6) * 0.37)));
151  } else {
152  // above 70km/h we use a function that grows according to the "natural"
153  // formula (vmax / 2 * minDecel) but continues smoothly where the german
154  // rules leave of
155  return (int)(1.8 + vmax / 2 / minDecel);
156  }
157 }
158 
159 
160 void
162  // collect the information about participating edges and links
163  collectEdges();
164  collectLinks();
165 }
166 
167 std::set<NBEdge*>
168 NBTrafficLightDefinition::collectReachable(EdgeVector outer, const EdgeVector& within, bool checkControlled) {
169  std::set<NBEdge*> reachable;
170  while (outer.size() > 0) {
171  NBEdge* from = outer.back();
172  outer.pop_back();
173  std::vector<NBEdge::Connection>& cons = from->getConnections();
174  for (std::vector<NBEdge::Connection>::iterator k = cons.begin(); k != cons.end(); k++) {
175  NBEdge* to = (*k).toEdge;
176  if (reachable.count(to) == 0 &&
177  (find(within.begin(), within.end(), to) != within.end()) &&
178  (!checkControlled || from->mayBeTLSControlled((*k).fromLane, to, (*k).toLane))) {
179  reachable.insert(to);
180  outer.push_back(to);
181  }
182  }
183  }
184  return reachable;
185 }
186 
187 
188 void
190  myIncomingEdges.clear();
191  myEdgesWithin.clear();
192  EdgeVector myOutgoing;
193  // collect the edges from the participating nodes
194  for (std::vector<NBNode*>::iterator i = myControlledNodes.begin(); i != myControlledNodes.end(); i++) {
195  const EdgeVector& incoming = (*i)->getIncomingEdges();
196  copy(incoming.begin(), incoming.end(), back_inserter(myIncomingEdges));
197  const EdgeVector& outgoing = (*i)->getOutgoingEdges();
198  copy(outgoing.begin(), outgoing.end(), back_inserter(myOutgoing));
199  }
200  EdgeVector outer;
201  // check which of the edges are completely within the junction
202  // add them to the list of edges lying within the node
203  for (EdgeVector::iterator j = myIncomingEdges.begin(); j != myIncomingEdges.end(); ++j) {
204  NBEdge* edge = *j;
205  // an edge lies within the logic if it is outgoing as well as incoming
206  EdgeVector::iterator k = find(myOutgoing.begin(), myOutgoing.end(), edge);
207  if (k != myOutgoing.end()) {
208  myEdgesWithin.push_back(edge);
209  } else {
210  outer.push_back(edge);
211  }
212  }
213  // collect edges that are reachable from the outside via controlled connections
214  std::set<NBEdge*> reachable = collectReachable(outer, myEdgesWithin, true);
215  // collect edges that are reachable from the outside regardless of controllability
216  std::set<NBEdge*> reachable2 = collectReachable(outer, myEdgesWithin, false);
217 
218  const bool uncontrolledWithin = OptionsCont::getOptions().getBool("tls.uncontrolled-within");
219  for (EdgeVector::iterator j = myEdgesWithin.begin(); j != myEdgesWithin.end(); ++j) {
220  NBEdge* edge = *j;
221  // edges that are marked as 'inner' will not get their own phase when
222  // computing traffic light logics (unless they cannot be reached from the outside at all)
223  if (reachable.count(edge) == 1) {
224  edge->setIsInnerEdge();
225  // legacy behavior
226  if (uncontrolledWithin && myControlledInnerEdges.count(edge->getID()) == 0) {
227  myIncomingEdges.erase(find(myIncomingEdges.begin(), myIncomingEdges.end(), edge));
228  }
229  }
230  if (reachable2.count(edge) == 0 && edge->getFirstNonPedestrianLaneIndex(NBNode::FORWARD, true) >= 0
231  && getID() != DummyID) {
232  WRITE_WARNING("Unreachable edge '" + edge->getID() + "' within tlLogic '" + getID() + "'");
233  }
234  }
235 }
236 
237 
238 bool
239 NBTrafficLightDefinition::mustBrake(const NBEdge* const from, const NBEdge* const to) const {
240  std::vector<NBNode*>::const_iterator i =
241  find_if(myControlledNodes.begin(), myControlledNodes.end(),
243  assert(i != myControlledNodes.end());
244  NBNode* node = *i;
245  if (!node->hasOutgoing(to)) {
246  return true; // !!!
247  }
248  // @todo recheck relevance of lane indices
249  return node->mustBrake(from, to, -1, -1, true);
250 }
251 
252 
253 bool
254 NBTrafficLightDefinition::mustBrake(const NBEdge* const possProhibitedFrom,
255  const NBEdge* const possProhibitedTo,
256  const NBEdge* const possProhibitorFrom,
257  const NBEdge* const possProhibitorTo,
258  bool regardNonSignalisedLowerPriority) const {
259  return forbids(possProhibitorFrom, possProhibitorTo,
260  possProhibitedFrom, possProhibitedTo,
261  regardNonSignalisedLowerPriority);
262 }
263 
264 
265 bool
267  const NBConnection& possProhibitor,
268  bool regardNonSignalisedLowerPriority) const {
269  return forbids(possProhibitor.getFrom(), possProhibitor.getTo(),
270  possProhibited.getFrom(), possProhibited.getTo(),
271  regardNonSignalisedLowerPriority);
272 }
273 
274 
275 bool
276 NBTrafficLightDefinition::forbids(const NBEdge* const possProhibitorFrom,
277  const NBEdge* const possProhibitorTo,
278  const NBEdge* const possProhibitedFrom,
279  const NBEdge* const possProhibitedTo,
280  bool regardNonSignalisedLowerPriority,
281  bool sameNodeOnly) const {
282  if (possProhibitorFrom == 0 || possProhibitorTo == 0 || possProhibitedFrom == 0 || possProhibitedTo == 0) {
283  return false;
284  }
285  // retrieve both nodes
286  std::vector<NBNode*>::const_iterator incoming =
287  find_if(myControlledNodes.begin(), myControlledNodes.end(), NBContHelper::node_with_incoming_finder(possProhibitorFrom));
288  std::vector<NBNode*>::const_iterator outgoing =
289  find_if(myControlledNodes.begin(), myControlledNodes.end(), NBContHelper::node_with_outgoing_finder(possProhibitedTo));
290  assert(incoming != myControlledNodes.end());
291  NBNode* incnode = *incoming;
292  NBNode* outnode = *outgoing;
293  EdgeVector::const_iterator i;
294 
295 #ifdef DEBUG_RIGHT_OF_WAY
296  if (DEBUGCOND) {
297  std::cout << "foribds tls=" << getID() << " from=" << possProhibitedFrom->getID() << " to=" << possProhibitedTo->getID() << " foeFrom=" << possProhibitorFrom->getID() << " foeTo=" << possProhibitorTo->getID() << " rnslp=" << regardNonSignalisedLowerPriority << " sameNodeOnly=" << sameNodeOnly;
298  }
299 #endif
300  if (incnode != outnode) {
301  if (sameNodeOnly) {
302 #ifdef DEBUG_RIGHT_OF_WAY
303  if (DEBUGCOND) {
304  std::cout << " differentNodes: allows (no check)\n";
305  }
306 #endif
307  return false;
308  }
309  // the links are located at different nodes
310  const EdgeVector& ev1 = possProhibitedTo->getConnectedEdges();
311  // go through the following edge,
312  // check whether one of these connections is prohibited
313  for (i = ev1.begin(); i != ev1.end(); ++i) {
314  std::vector<NBNode*>::const_iterator outgoing2 =
316  if (outgoing2 == myControlledNodes.end()) {
317  continue;
318  }
319  NBNode* outnode2 = *outgoing2;
320  if (incnode != outnode2) {
321  continue;
322  }
323  if (incnode->getDirection(possProhibitedTo, *i) != LINKDIR_STRAIGHT) {
324  continue;
325  }
326  bool ret1 = incnode->foes(possProhibitorFrom, possProhibitorTo,
327  possProhibitedTo, *i);
328  bool ret2 = incnode->forbids(possProhibitorFrom, possProhibitorTo,
329  possProhibitedTo, *i,
330  regardNonSignalisedLowerPriority);
331  bool ret = ret1 || ret2;
332  if (ret) {
333 #ifdef DEBUG_RIGHT_OF_WAY
334  if (DEBUGCOND) {
335  std::cout << " differentNodes: forbids\n";
336  }
337 #endif
338  return true;
339  }
340  }
341 
342  const EdgeVector& ev2 = possProhibitorTo->getConnectedEdges();
343  // go through the following edge,
344  // check whether one of these connections is prohibited
345  for (i = ev2.begin(); i != ev2.end(); ++i) {
346  std::vector<NBNode*>::const_iterator incoming2 =
347  find_if(myControlledNodes.begin(), myControlledNodes.end(), NBContHelper::node_with_incoming_finder(possProhibitorTo));
348  if (incoming2 == myControlledNodes.end()) {
349  continue;
350  }
351  NBNode* incnode2 = *incoming2;
352  if (incnode2 != outnode) {
353  continue;
354  }
355  if (incnode2->getDirection(possProhibitorTo, *i) != LINKDIR_STRAIGHT) {
356  continue;
357  }
358  bool ret1 = incnode2->foes(possProhibitorTo, *i,
359  possProhibitedFrom, possProhibitedTo);
360  bool ret2 = incnode2->forbids(possProhibitorTo, *i,
361  possProhibitedFrom, possProhibitedTo,
362  regardNonSignalisedLowerPriority);
363  bool ret = ret1 || ret2;
364  if (ret) {
365 #ifdef DEBUG_RIGHT_OF_WAY
366  if (DEBUGCOND) {
367  std::cout << " differentNodes: forbids (2)\n";
368  }
369 #endif
370  return true;
371  }
372  }
373 #ifdef DEBUG_RIGHT_OF_WAY
374  if (DEBUGCOND) {
375  std::cout << " differentNodes: allows\n";
376  }
377 #endif
378  return false;
379  }
380  // both links are located at the same node
381  // check using this node's information
382  const bool result = incnode->forbids(possProhibitorFrom, possProhibitorTo,
383  possProhibitedFrom, possProhibitedTo,
384  regardNonSignalisedLowerPriority);
385 #ifdef DEBUG_RIGHT_OF_WAY
386  if (DEBUGCOND) {
387  std::cout << " sameNodes: " << (result ? "forbids" : "allows") << "\n";
388  }
389 #endif
390  return result;
391 }
392 
393 
394 bool
395 NBTrafficLightDefinition::foes(const NBEdge* const from1, const NBEdge* const to1,
396  const NBEdge* const from2, const NBEdge* const to2) const {
397  if (to1 == 0 || to2 == 0) {
398  return false;
399  }
400  // retrieve both nodes (it is possible that a connection
401  std::vector<NBNode*>::const_iterator incoming =
402  find_if(myControlledNodes.begin(), myControlledNodes.end(),
404  std::vector<NBNode*>::const_iterator outgoing =
405  find_if(myControlledNodes.begin(), myControlledNodes.end(),
407  assert(incoming != myControlledNodes.end());
408  NBNode* incnode = *incoming;
409  NBNode* outnode = *outgoing;
410  if (incnode != outnode) {
411  return false;
412  }
413  return incnode->foes(from1, to1, from2, to2);
414 }
415 
416 
417 void
419  if (std::find(myControlledNodes.begin(), myControlledNodes.end(), node) == myControlledNodes.end()) {
420  myControlledNodes.push_back(node);
422  }
423  node->addTrafficLight(this);
424 }
425 
426 
427 void
429  std::vector<NBNode*>::iterator i = std::find(myControlledNodes.begin(), myControlledNodes.end(), node);
430  if (i != myControlledNodes.end()) {
431  myControlledNodes.erase(i);
432  }
433  // !!! remove in node?
434 }
435 
436 
437 void
438 NBTrafficLightDefinition::addControlledInnerEdges(const std::vector<std::string>& edges) {
439  myControlledInnerEdges.insert(edges.begin(), edges.end());
440 }
441 
442 
443 std::vector<std::string>
445  return std::vector<std::string>(myControlledInnerEdges.begin(), myControlledInnerEdges.end());
446 }
447 
448 
449 const EdgeVector&
451  return myIncomingEdges;
452 }
453 
454 
455 void
457  myControlledLinks.clear();
458  int tlIndex = 0;
459  // build the list of links which are controled by the traffic light
460  for (EdgeVector::iterator i = myIncomingEdges.begin(); i != myIncomingEdges.end(); i++) {
461  NBEdge* incoming = *i;
462  int noLanes = incoming->getNumLanes();
463  for (int j = 0; j < noLanes; j++) {
464  std::vector<NBEdge::Connection> connected = incoming->getConnectionsFromLane(j);
465  for (std::vector<NBEdge::Connection>::iterator k = connected.begin(); k != connected.end(); k++) {
466  const NBEdge::Connection& el = *k;
467  if (incoming->mayBeTLSControlled(el.fromLane, el.toEdge, el.toLane)) {
468  if (el.toEdge != 0 && el.toLane >= (int) el.toEdge->getNumLanes()) {
469  throw ProcessError("Connection '" + incoming->getID() + "_" + toString(j) + "->" + el.toEdge->getID() + "_" + toString(el.toLane) + "' yields in a not existing lane.");
470  }
471  if (incoming->getToNode()->getType() != NODETYPE_RAIL_CROSSING || !isRailway(incoming->getPermissions())) {
472  myControlledLinks.push_back(NBConnection(incoming, el.fromLane, el.toEdge, el.toLane, tlIndex++));
473  } else {
474  myControlledLinks.push_back(NBConnection(incoming, el.fromLane, el.toEdge, el.toLane, -1));
475  }
476  }
477  }
478  }
479  }
480  if (myControlledLinks.size() > 0 && tlIndex == 0) {
481  WRITE_WARNING("The rail crossing '" + getID() + "' does not have any roads.");
482  }
483 }
484 
485 
486 bool
487 NBTrafficLightDefinition::needsCont(const NBEdge* fromE, const NBEdge* toE, const NBEdge* otherFromE, const NBEdge* otherToE) const {
490  assert(myNeedsContRelationReady);
491  }
492  return std::find(myNeedsContRelation.begin(), myNeedsContRelation.end(),
493  StreamPair(fromE, toE, otherFromE, otherToE)) != myNeedsContRelation.end();
494 }
495 
496 
497 void
499  if (!amInvalid()) {
501  dummy.initNeedsContRelation();
503  for (std::vector<NBNode*>::const_iterator i = myControlledNodes.begin(); i != myControlledNodes.end(); i++) {
504  (*i)->removeTrafficLight(&dummy);
505  }
506  }
508 }
509 
510 
511 bool
512 NBTrafficLightDefinition::rightOnRedConflict(int index, int foeIndex) const {
516  NBTrafficLightLogic* tllDummy = dummy.computeLogicAndConts(0, true);
517  delete tllDummy;
519  for (std::vector<NBNode*>::const_iterator i = myControlledNodes.begin(); i != myControlledNodes.end(); i++) {
520  (*i)->removeTrafficLight(&dummy);
521  }
523  //std::cout << " rightOnRedConflicts tls=" << getID() << " pro=" << getProgramID() << "\n";
524  //for (RightOnRedConflicts::const_iterator it = myRightOnRedConflicts.begin(); it != myRightOnRedConflicts.end(); ++it) {
525  // std::cout << " " << it->first << ", " << it->second << "\n";
526  //}
527  }
528  return std::find(myRightOnRedConflicts.begin(), myRightOnRedConflicts.end(), std::make_pair(index, foeIndex)) != myRightOnRedConflicts.end();
529 }
530 
531 /****************************************************************************/
532 
virtual void setParticipantsInformation()
Builds the list of participating nodes/edges/links.
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:165
int toLane
The lane the connections yields in.
Definition: NBEdge.h:191
TrafficLightType myType
The algorithm type for the traffic light.
static double maxSpeed(const EdgeVector &ev)
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
void collectAllLinks()
helper method for use in NBOwnTLDef and NBLoadedSUMOTLDef
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:188
static const std::string DummyID
id for temporary definitions
std::vector< Connection > getConnectionsFromLane(int lane) const
Returns connections from a given lane.
Definition: NBEdge.cpp:1023
RightOnRedConflicts myRightOnRedConflicts
std::vector< std::string > getControlledInnerEdges() const
Retrieve the ids of edges explicitly controlled by the tls.
A SUMO-compliant built logic for a traffic light.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
EdgeVector myIncomingEdges
The list of incoming edges.
virtual ~NBTrafficLightDefinition()
Destructor.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
Definition: NBEdge.h:71
bool mayBeTLSControlled(int fromLane, NBEdge *toEdge, int toLane) const
return true if certain connection must be controlled by TLS
Definition: NBEdge.cpp:2475
NBTrafficLightLogic * compute(OptionsCont &oc)
Computes the traffic light logic.
Used for sorting the cells by the begin time they describe.
Definition: NBNode.h:654
T MAX2(T a, T b)
Definition: StdDefs.h:74
static const SUMOTime UNSPECIFIED_DURATION
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
const EdgeVector & getIncomingEdges() const
Returns the list of incoming edges (must be build first)
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permission is a railway edge.
SUMOTime myOffset
The offset in the program.
NBEdge * getFrom() const
returns the from-edge (start of the connection)
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
virtual void collectLinks()=0
Collects the links participating in this traffic light If a link could not be found.
EdgeVector getConnectedEdges() const
Returns the list of outgoing edges unsorted.
Definition: NBEdge.cpp:1120
The link is a straight direction.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
virtual void collectEdges()
Build the list of participating edges.
int computeBrakingTime(double minDecel) const
Computes the time vehicles may need to brake.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
static const int FORWARD
edge directions (for pedestrian related stuff)
Definition: NBNode.h:197
std::set< std::string > myControlledInnerEdges
Set of inner edges that shall be controlled, though.
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:185
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:260
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:414
virtual NBTrafficLightLogic * myCompute(int brakingTime)=0
Computes the traffic light logic finally in dependence to the type.
int getFirstNonPedestrianLaneIndex(int direction, bool exclusive=false) const
return the first lane with permissions other than SVC_PEDESTRIAN and 0
Definition: NBEdge.cpp:3030
static const std::string DefaultProgramID
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
void addControlledInnerEdges(const std::vector< std::string > &edges)
Adds the given ids into the list of inner edges controlled by the tls.
bool mustBrake(const NBEdge *const from, const NBEdge *const to) const
Returns the information whether the described flow must let any other flow pass.
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream&#39;s direction.
Definition: NBNode.cpp:1539
virtual void removeNode(NBNode *node)
Removes the given node from the list of controlled nodes.
Base class for objects which have an id.
Definition: Named.h:46
#define DEBUGCOND
bool forbids(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority, bool sameNodeOnly=false) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:2988
void addParameter(const std::string &key, const std::string &value)
Adds a parameter.
bool needsCont(const NBEdge *fromE, const NBEdge *toE, const NBEdge *otherFromE, const NBEdge *otherToE) const
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:435
void addTrafficLight(NBTrafficLightDefinition *tlDef)
Adds a traffic light to the list of traffic lights that control this node.
Definition: NBNode.cpp:312
NBTrafficLightLogic * computeLogicAndConts(int brakingTimeSeconds, bool onlyConts=false)
helper function for myCompute
Definition: NBOwnTLDef.cpp:196
bool mustBrake(const NBEdge *const from, const NBEdge *const to, int fromLane, int toLane, bool includePedCrossings) const
Returns the information whether the described flow must let any other flow pass.
Definition: NBNode.cpp:1355
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:41
A storage for options typed value containers)
Definition: OptionsCont.h:99
void setIsInnerEdge()
Marks this edge being within an intersection.
Definition: NBEdge.h:935
NBEdge * getTo() const
returns the to-edge (end of the connection)
Represents a single node (junction) during network building.
Definition: NBNode.h:75
void initNeedsContRelation() const
Definition: NBOwnTLDef.cpp:565
long long int SUMOTime
Definition: TraCIDefs.h:52
data structure for caching needsCont information
std::vector< NBNode * > myControlledNodes
The container with participating nodes.
NBTrafficLightDefinition(const std::string &id, const std::vector< NBNode * > &junctions, const std::string &programID, SUMOTime offset, TrafficLightType type)
Constructor.
A traffic light logics which must be computed (only nodes/edges are given)
Definition: NBOwnTLDef.h:54
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
bool foes(const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
Returns the information whether the given flows cross.
Definition: NBNode.cpp:1451
static std::set< NBEdge * > collectReachable(EdgeVector outer, const EdgeVector &within, bool checkControlled)
NBConnectionVector myControlledLinks
The list of controlled links.
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:835
EdgeVector myEdgesWithin
The list of edges within the area controlled by the tls.
std::string mySubID
The tls program&#39;s subid.
virtual bool rightOnRedConflict(int index, int foeIndex) const
whether the given index must yield to the foeIndex while turing right on a red light ...
TrafficLightType
bool forbids(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
Definition: NBNode.cpp:1441
bool foes(const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
Returns the information whether the given flows cross.
virtual void initNeedsContRelation() const