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