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