SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBOwnTLDef.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // A traffic light logics which must be computed (only nodes/edges are given)
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include <cassert>
36 #include <iterator>
38 #include "NBNode.h"
39 #include "NBOwnTLDef.h"
40 #include "NBTrafficLightLogic.h"
43 #include <utils/common/ToString.h>
45 #include <utils/options/Option.h>
46 
47 #ifdef CHECK_MEMORY_LEAKS
48 #include <foreign/nvwa/debug_new.h>
49 #endif // CHECK_MEMORY_LEAKS
50 
51 
52 // ===========================================================================
53 // member method definitions
54 // ===========================================================================
55 NBOwnTLDef::NBOwnTLDef(const std::string& id,
56  const std::vector<NBNode*>& junctions, SUMOTime offset,
57  TrafficLightType type) :
58  NBTrafficLightDefinition(id, junctions, DefaultProgramID, offset, type),
59  myHaveSinglePhase(false)
60 {}
61 
62 
63 NBOwnTLDef::NBOwnTLDef(const std::string& id, NBNode* junction, SUMOTime offset,
64  TrafficLightType type) :
65  NBTrafficLightDefinition(id, junction, DefaultProgramID, offset, type),
66  myHaveSinglePhase(false)
67 {}
68 
69 
70 NBOwnTLDef::NBOwnTLDef(const std::string& id, SUMOTime offset,
71  TrafficLightType type) :
72  NBTrafficLightDefinition(id, DefaultProgramID, offset, type),
73  myHaveSinglePhase(false)
74 {}
75 
76 
78 
79 
80 int
81 NBOwnTLDef::getToPrio(const NBEdge* const e) {
82  return e->getJunctionPriority(e->getToNode());
83 }
84 
85 
88  switch (dir) {
89  case LINKDIR_STRAIGHT:
90  case LINKDIR_PARTLEFT:
91  case LINKDIR_PARTRIGHT:
92  return 2.;
93  case LINKDIR_LEFT:
94  case LINKDIR_RIGHT:
95  return .5;
96  default:
97  break;
98  }
99  return 0;
100 }
101 
102 SUMOReal
104  SUMOReal val = 0;
105  for (unsigned int e1l = 0; e1l < e1->getNumLanes(); e1l++) {
106  std::vector<NBEdge::Connection> approached1 = e1->getConnectionsFromLane(e1l);
107  for (unsigned int e2l = 0; e2l < e2->getNumLanes(); e2l++) {
108  std::vector<NBEdge::Connection> approached2 = e2->getConnectionsFromLane(e2l);
109  for (std::vector<NBEdge::Connection>::iterator e1c = approached1.begin(); e1c != approached1.end(); ++e1c) {
110  if (e1->getTurnDestination() == (*e1c).toEdge) {
111  continue;
112  }
113  for (std::vector<NBEdge::Connection>::iterator e2c = approached2.begin(); e2c != approached2.end(); ++e2c) {
114  if (e2->getTurnDestination() == (*e2c).toEdge) {
115  continue;
116  }
117  if (!foes(e1, (*e1c).toEdge, e2, (*e2c).toEdge)) {
118  val += getDirectionalWeight(e1->getToNode()->getDirection(e1, (*e1c).toEdge));
119  val += getDirectionalWeight(e2->getToNode()->getDirection(e2, (*e2c).toEdge));
120  }
121  }
122  }
123  }
124  }
125  return val;
126 }
127 
128 
129 std::pair<NBEdge*, NBEdge*>
131  std::pair<NBEdge*, NBEdge*> bestPair(static_cast<NBEdge*>(0), static_cast<NBEdge*>(0));
132  SUMOReal bestValue = -1;
133  for (EdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
134  for (EdgeVector::const_iterator j = i + 1; j != edges.end(); ++j) {
135  const SUMOReal value = computeUnblockedWeightedStreamNumber(*i, *j);
136  if (value > bestValue) {
137  bestValue = value;
138  bestPair = std::pair<NBEdge*, NBEdge*>(*i, *j);
139  } else if (value == bestValue) {
140  const SUMOReal ca = GeomHelper::getMinAngleDiff((*i)->getAngleAtNode((*i)->getToNode()), (*j)->getAngleAtNode((*j)->getToNode()));
141  const SUMOReal oa = GeomHelper::getMinAngleDiff(bestPair.first->getAngleAtNode(bestPair.first->getToNode()), bestPair.second->getAngleAtNode(bestPair.second->getToNode()));
142  if (fabs(oa - ca) < NUMERICAL_EPS) { // break ties by id
143  if (bestPair.first->getID() < (*i)->getID()) {
144  bestPair = std::pair<NBEdge*, NBEdge*>(*i, *j);
145  }
146  } else if (oa < ca) {
147  bestPair = std::pair<NBEdge*, NBEdge*>(*i, *j);
148  }
149  }
150  }
151  }
152  return bestPair;
153 }
154 
155 
156 std::pair<NBEdge*, NBEdge*>
158  if (incoming.size() == 1) {
159  // only one there - return the one
160  std::pair<NBEdge*, NBEdge*> ret(*incoming.begin(), static_cast<NBEdge*>(0));
161  incoming.clear();
162  return ret;
163  }
164  // determine the best combination
165  // by priority, first
166  EdgeVector used;
167  std::sort(incoming.begin(), incoming.end(), edge_by_incoming_priority_sorter());
168  used.push_back(*incoming.begin()); // the first will definitely be used
169  // get the ones with the same priority
170  int prio = getToPrio(*used.begin());
171  for (EdgeVector::iterator i = incoming.begin() + 1; i != incoming.end() && prio == getToPrio(*i); ++i) {
172  used.push_back(*i);
173  }
174  // if there only lower priorised, use these, too
175  if (used.size() < 2) {
176  used = incoming;
177  }
178  std::pair<NBEdge*, NBEdge*> ret = getBestCombination(used);
179  incoming.erase(find(incoming.begin(), incoming.end(), ret.first));
180  incoming.erase(find(incoming.begin(), incoming.end(), ret.second));
181  return ret;
182 }
183 
185 NBOwnTLDef::myCompute(const NBEdgeCont&, unsigned int brakingTimeSeconds) {
186  return computeLogicAndConts(brakingTimeSeconds);
187 }
188 
190 NBOwnTLDef::computeLogicAndConts(unsigned int brakingTimeSeconds, bool onlyConts) {
191  myNeedsContRelation.clear();
192  const SUMOTime brakingTime = TIME2STEPS(brakingTimeSeconds);
193  const SUMOTime leftTurnTime = TIME2STEPS(6); // make configurable
194  // build complete lists first
195  const EdgeVector& incoming = getIncomingEdges();
196  EdgeVector fromEdges, toEdges;
197  std::vector<bool> isTurnaround;
198  std::vector<int> fromLanes;
199  unsigned int noLanesAll = 0;
200  unsigned int noLinksAll = 0;
201  for (unsigned int i1 = 0; i1 < incoming.size(); i1++) {
202  unsigned int noLanes = incoming[i1]->getNumLanes();
203  noLanesAll += noLanes;
204  for (unsigned int i2 = 0; i2 < noLanes; i2++) {
205  NBEdge* fromEdge = incoming[i1];
206  std::vector<NBEdge::Connection> approached = fromEdge->getConnectionsFromLane(i2);
207  noLinksAll += (unsigned int) approached.size();
208  for (unsigned int i3 = 0; i3 < approached.size(); i3++) {
209  if (!fromEdge->mayBeTLSControlled(i2, approached[i3].toEdge, approached[i3].toLane)) {
210  --noLinksAll;
211  continue;
212  }
213  assert(i3 < approached.size());
214  NBEdge* toEdge = approached[i3].toEdge;
215  fromEdges.push_back(fromEdge);
216  fromLanes.push_back((int)i2);
217  toEdges.push_back(toEdge);
218  if (toEdge != 0) {
219  isTurnaround.push_back(fromEdge->isTurningDirectionAt(toEdge));
220  } else {
221  isTurnaround.push_back(true);
222  }
223  }
224  }
225  }
226  // collect crossings
227  std::vector<NBNode::Crossing> crossings;
228  for (std::vector<NBNode*>::iterator i = myControlledNodes.begin(); i != myControlledNodes.end(); i++) {
229  const std::vector<NBNode::Crossing>& c = (*i)->getCrossings();
230  if (!onlyConts) {
231  // set tl indices for crossings
232  (*i)->setCrossingTLIndices(noLinksAll);
233  }
234  copy(c.begin(), c.end(), std::back_inserter(crossings));
235  noLinksAll += (unsigned int)c.size();
236  }
237 
238  NBTrafficLightLogic* logic = new NBTrafficLightLogic(getID(), getProgramID(), noLinksAll, myOffset, myType);
239  EdgeVector toProc = incoming;
240  const SUMOTime greenTime = TIME2STEPS(OptionsCont::getOptions().getInt("tls.green.time"));
241  // build all phases
242  while (toProc.size() > 0) {
243  std::pair<NBEdge*, NBEdge*> chosen;
244  if (incoming.size() == 2) {
245  // if there are only 2 incoming edges we need to decide whether they are a crossing or a "continuation"
246  // @node: this heuristic could be extended to also check the number of outgoing edges
247  SUMOReal angle = fabs(NBHelpers::relAngle(incoming[0]->getAngleAtNode(incoming[0]->getToNode()), incoming[1]->getAngleAtNode(incoming[1]->getToNode())));
248  // angle would be 180 for straight opposing incoming edges
249  if (angle < 135) {
250  chosen = std::pair<NBEdge*, NBEdge*>(toProc[0], static_cast<NBEdge*>(0));
251  toProc.erase(toProc.begin());
252  } else {
253  chosen = getBestPair(toProc);
254  }
255  } else {
256  chosen = getBestPair(toProc);
257  }
258  unsigned int pos = 0;
259  std::string state((size_t) noLinksAll, 'r');
260  // plain straight movers
261  for (unsigned int i1 = 0; i1 < (unsigned int) incoming.size(); ++i1) {
262  NBEdge* fromEdge = incoming[i1];
263  const bool inChosen = fromEdge == chosen.first || fromEdge == chosen.second; //chosen.find(fromEdge)!=chosen.end();
264  const unsigned int numLanes = fromEdge->getNumLanes();
265  for (unsigned int i2 = 0; i2 < numLanes; i2++) {
266  std::vector<NBEdge::Connection> approached = fromEdge->getConnectionsFromLane(i2);
267  for (unsigned int i3 = 0; i3 < approached.size(); ++i3) {
268  if (!fromEdge->mayBeTLSControlled(i2, approached[i3].toEdge, approached[i3].toLane)) {
269  continue;
270  }
271  if (inChosen) {
272  state[pos] = 'G';
273  } else {
274  state[pos] = 'r';
275  }
276  ++pos;
277  }
278  }
279  }
280  // correct behaviour for those that are not in chosen, but may drive, though
281  for (unsigned int i1 = 0; i1 < pos; ++i1) {
282  if (state[i1] == 'G') {
283  continue;
284  }
285  bool isForbidden = false;
286  for (unsigned int i2 = 0; i2 < pos && !isForbidden; ++i2) {
287  if (state[i2] == 'G' && !isTurnaround[i2] &&
288  (forbids(fromEdges[i2], toEdges[i2], fromEdges[i1], toEdges[i1], true) || forbids(fromEdges[i1], toEdges[i1], fromEdges[i2], toEdges[i2], true))) {
289  isForbidden = true;
290  }
291  }
292  if (!isForbidden && !hasCrossing(fromEdges[i1], toEdges[i1], crossings)) {
293  state[i1] = 'G';
294  }
295  }
296  // correct behaviour for those that have to wait (mainly left-mover)
297  bool haveForbiddenLeftMover = false;
298  std::vector<bool> rightTurnConflicts(pos, false);
299  for (unsigned int i1 = 0; i1 < pos; ++i1) {
300  if (state[i1] != 'G') {
301  continue;
302  }
303  for (unsigned int i2 = 0; i2 < pos; ++i2) {
304  if ((state[i2] == 'G' || state[i2] == 'g')) {
306  fromEdges[i1], toEdges[i1], fromLanes[i1], fromEdges[i2], toEdges[i2], fromLanes[i2])) {
307  rightTurnConflicts[i1] = true;
308  }
309  if (forbids(fromEdges[i2], toEdges[i2], fromEdges[i1], toEdges[i1], true) || rightTurnConflicts[i1]) {
310  state[i1] = 'g';
311  myNeedsContRelation.insert(StreamPair(fromEdges[i1], toEdges[i1], fromEdges[i2], toEdges[i2]));
312  if (!isTurnaround[i1]) {
313  haveForbiddenLeftMover = true;
314  }
315  }
316  }
317  }
318  }
319  const std::string vehicleState = state; // backup state before pedestrian modifications
320  state = addPedestrianPhases(logic, greenTime, state, crossings, fromEdges, toEdges);
321  // pedestrians have 'r' from here on
322  for (unsigned int i1 = pos; i1 < pos + crossings.size(); ++i1) {
323  state[i1] = 'r';
324  }
325 
326  if (brakingTime > 0) {
327  // build yellow (straight)
328  for (unsigned int i1 = 0; i1 < pos; ++i1) {
329  if (state[i1] != 'G' && state[i1] != 'g') {
330  continue;
331  }
332  if ((vehicleState[i1] >= 'a' && vehicleState[i1] <= 'z') && haveForbiddenLeftMover && !rightTurnConflicts[i1]) {
333  continue;
334  }
335  state[i1] = 'y';
336  }
337  // add step
338  logic->addStep(brakingTime, state);
339  }
340 
341  if (haveForbiddenLeftMover && !myHaveSinglePhase) {
342  // build left green
343  for (unsigned int i1 = 0; i1 < pos; ++i1) {
344  if (state[i1] == 'Y' || state[i1] == 'y') {
345  state[i1] = 'r';
346  continue;
347  }
348  if (state[i1] == 'g') {
349  state[i1] = 'G';
350  }
351  }
352  // add step
353  logic->addStep(leftTurnTime, state);
354 
355  // build left yellow
356  if (brakingTime > 0) {
357  for (unsigned int i1 = 0; i1 < pos; ++i1) {
358  if (state[i1] != 'G' && state[i1] != 'g') {
359  continue;
360  }
361  state[i1] = 'y';
362  }
363  // add step
364  logic->addStep(brakingTime, state);
365  }
366  }
367  }
368  const SUMOTime totalDuration = logic->getDuration();
369  // this computation only makes sense for single nodes
371  if (totalDuration > 0) {
372  if (totalDuration > 3 * (greenTime + 2 * brakingTime + leftTurnTime)) {
373  WRITE_WARNING("The traffic light '" + getID() + "' has a high cycle time of " + time2string(totalDuration) + ".");
374  }
375  logic->closeBuilding();
376  return logic;
377  } else {
378  delete logic;
379  return 0;
380  }
381 }
382 
383 
384 bool
385 NBOwnTLDef::hasCrossing(const NBEdge* from, const NBEdge* to, const std::vector<NBNode::Crossing>& crossings) {
386  assert(from != 0);
387  assert(to != 0);
388  for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
389  const NBNode::Crossing& cross = *it;
390  // only check connections at this crossings node
391  if (from->getToNode() == cross.node) {
392  for (EdgeVector::const_iterator it_e = cross.edges.begin(); it_e != cross.edges.end(); ++it_e) {
393  const NBEdge* edge = *it_e;
394  if (edge == from || edge == to) {
395  return true;
396  }
397  }
398  }
399  }
400  return false;
401 }
402 
403 
404 std::string
406  std::string state, const std::vector<NBNode::Crossing>& crossings, const EdgeVector& fromEdges, const EdgeVector& toEdges) {
407  const SUMOTime pedClearingTime = TIME2STEPS(5); // compute based on length of the crossing
408  const SUMOTime minPedTime = TIME2STEPS(4); // compute: must be able to reach the middle of the second "Richtungsfahrbahn"
409  const std::string orig = state;
410  state = patchStateForCrossings(state, crossings, fromEdges, toEdges);
411  if (orig == state) {
412  // add step
413  logic->addStep(greenTime, state);
414  } else {
415  const SUMOTime pedTime = greenTime - pedClearingTime;
416  if (pedTime >= minPedTime) {
417  // ensure clearing time for pedestrians
418  const size_t pedStates = crossings.size();
419  logic->addStep(pedTime, state);
420  state = state.substr(0, state.size() - pedStates) + std::string(pedStates, 'r');
421  logic->addStep(pedClearingTime, state);
422  } else {
423  state = orig;
424  // not safe for pedestrians.
425  logic->addStep(greenTime, state);
426  }
427  }
428  return state;
429 }
430 
431 
432 std::string
433 NBOwnTLDef::patchStateForCrossings(const std::string& state, const std::vector<NBNode::Crossing>& crossings, const EdgeVector& fromEdges, const EdgeVector& toEdges) {
434  std::string result = state;
435  const unsigned int pos = (unsigned int)(state.size() - crossings.size()); // number of controlled vehicle links
436  for (int ic = 0; ic < (int)crossings.size(); ++ic) {
437  const int i1 = pos + ic;
438  const NBNode::Crossing& cross = crossings[ic];
439  bool isForbidden = false;
440  for (unsigned int i2 = 0; i2 < pos && !isForbidden; ++i2) {
441  // only check connections at this crossings node
442  if (fromEdges[i2] != 0 && toEdges[i2] != 0 && fromEdges[i2]->getToNode() == cross.node) {
443  for (EdgeVector::const_iterator it = cross.edges.begin(); it != cross.edges.end(); ++it) {
444  const NBEdge* edge = *it;
445  const LinkDirection i2dir = cross.node->getDirection(fromEdges[i2], toEdges[i2]);
446  if (state[i2] != 'r' && (edge == fromEdges[i2] ||
447  (edge == toEdges[i2] && (i2dir == LINKDIR_STRAIGHT || i2dir == LINKDIR_PARTLEFT || i2dir == LINKDIR_PARTRIGHT)))) {
448  isForbidden = true;
449  break;
450  }
451  }
452  }
453  }
454  if (!isForbidden) {
455  result[i1] = 'G';
456  } else {
457  result[i1] = 'r';
458  }
459  }
460 
461  // correct behaviour for roads that are in conflict with a pedestrian crossing
462  for (unsigned int i1 = 0; i1 < pos; ++i1) {
463  if (result[i1] == 'G') {
464  for (int ic = 0; ic < (int)crossings.size(); ++ic) {
465  const NBNode::Crossing& crossing = crossings[ic];
466  if (fromEdges[i1] != 0 && toEdges[i1] != 0 && fromEdges[i1]->getToNode() == crossing.node) {
467  const int i2 = pos + ic;
468  if (result[i2] == 'G' && crossing.node->mustBrakeForCrossing(fromEdges[i1], toEdges[i1], crossing)) {
469  result[i1] = 'g';
470  break;
471  }
472  }
473  }
474  }
475  }
476  return result;
477 }
478 
479 
480 void
482 
483 
484 void
486  collectAllLinks();
487 }
488 
489 
490 void
492  // assign participating nodes to the request
493  collectNodes();
494  // collect the information about participating edges and links
495  collectEdges();
496  collectLinks();
497 }
498 
499 
500 void
502  // set the information about the link's positions within the tl into the
503  // edges the links are starting at, respectively
504  for (NBConnectionVector::const_iterator j = myControlledLinks.begin(); j != myControlledLinks.end(); ++j) {
505  const NBConnection& conn = *j;
506  NBEdge* edge = conn.getFrom();
507  edge->setControllingTLInformation(conn, getID());
508  }
509 }
510 
511 
512 void
513 NBOwnTLDef::remapRemoved(NBEdge* /*removed*/, const EdgeVector& /*incoming*/,
514  const EdgeVector& /*outgoing*/) {}
515 
516 
517 void
518 NBOwnTLDef::replaceRemoved(NBEdge* /*removed*/, int /*removedLane*/,
519  NBEdge* /*by*/, int /*byLane*/) {}
520 
521 
522 void
525  assert(myControlledNodes.size() > 0);
526  // there are basically 2 cases for controlling multiple nodes
527  // a) a complex (unjoined) intersection. Here, internal junctions should
528  // not be needed since real nodes are used instead
529  // b) two far-away junctions which shall be coordinated
530  // This is likely to mess up the bestPair computation for each
531  // individual node and thus generate incorrect needsCont data
532  //
533  // Therefore we compute needsCont for individual nodes which doesn't
534  // matter for a) and is better for b)
535  myNeedsContRelation.clear();
536  for (std::vector<NBNode*>::const_iterator i = myControlledNodes.begin(); i != myControlledNodes.end(); i++) {
537  NBNode* n = *i;
538  NBOwnTLDef dummy("dummy", n, 0, TLTYPE_STATIC);
540  dummy.computeLogicAndConts(0, true);
541  myNeedsContRelation.insert(dummy.myNeedsContRelation.begin(), dummy.myNeedsContRelation.end());
542  n->removeTrafficLight(&dummy);
543  }
545  }
546 
547 }
548 
549 /****************************************************************************/
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:433
The link is a partial left direction.
bool setControllingTLInformation(const NBConnection &c, const std::string &tlID)
Returns if the link could be set as to be controlled.
Definition: NBEdge.cpp:1924
TrafficLightType myType
The algorithm type for the traffic light.
void collectAllLinks()
helper method for use in NBOwnTLDef and NBLoadedSUMOTLDef
void closeBuilding()
closes the building process
A SUMO-compliant built logic for a traffic light.
const std::string & getProgramID() const
Returns the ProgramID.
The representation of a single edge during network building.
Definition: NBEdge.h:71
bool mayBeTLSControlled(int fromLane, NBEdge *toEdge, int toLane) const
Definition: NBEdge.cpp:1913
void collectNodes()
Collects the nodes participating in this traffic light.
Definition: NBOwnTLDef.cpp:481
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:61
The base class for traffic light logic definitions.
static bool hasCrossing(const NBEdge *from, const NBEdge *to, const std::vector< NBNode::Crossing > &crossings)
compute whether the given connection is crossed by pedestrians
Definition: NBOwnTLDef.cpp:385
bool isForbidden(SVCPermissions permissions)
Returns whether an edge with the given permission is a forbidden edge.
const EdgeVector & getIncomingEdges() const
Returns the list of incoming edges (must be build first)
NBTrafficLightLogic * computeLogicAndConts(unsigned int brakingTimeSeconds, bool onlyConts=false)
helper function for myCompute
Definition: NBOwnTLDef.cpp:190
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
Definition: NBNode.cpp:316
std::vector< Connection > getConnectionsFromLane(unsigned int lane) const
Returns connections from a given lane.
Definition: NBEdge.cpp:771
SUMOTime myOffset
The offset in the program.
NBEdge * getFrom() const
returns the from-edge (start of the connection)
The link is a (hard) left direction.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
std::pair< NBEdge *, NBEdge * > getBestPair(EdgeVector &incoming)
Returns the combination of two edges from the given which has most unblocked streams.
Definition: NBOwnTLDef.cpp:157
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
static bool rightTurnConflict(const NBEdge *from, const NBEdge *to, int fromLane, const NBEdge *prohibitorFrom, const NBEdge *prohibitorTo, int prohibitorFromLane, bool lefthand=false)
return whether the given laneToLane connection is a right turn which must yield to a bicycle crossing...
Definition: NBNode.cpp:1201
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
The link is a straight direction.
const std::string & getID() const
Returns the id.
Definition: Named.h:60
virtual void collectEdges()
Build the list of participating edges.
bool mustBrakeForCrossing(const NBEdge *const from, const NBEdge *const to, const Crossing &crossing) const
Returns the information whether the described flow must brake for the given crossing.
Definition: NBNode.cpp:1195
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces a removed edge/lane.
Definition: NBOwnTLDef.cpp:518
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:130
bool myHaveSinglePhase
Whether left-mover should not have an additional phase.
Definition: NBOwnTLDef.h:245
unsigned int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:343
~NBOwnTLDef()
Destructor.
Definition: NBOwnTLDef.cpp:77
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
Definition: NBEdge.cpp:1858
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
The link is a (hard) right direction.
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:405
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:1365
The link is a partial right direction.
SUMOTime getDuration() const
Returns the duration of the complete cycle.
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
Definition: NBEdge.cpp:1228
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:103
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:367
void setTLControllingInformation(const NBEdgeCont &ec) const
Informs edges about being controlled by a tls.
Definition: NBOwnTLDef.cpp:501
void collectLinks()
Collects the links participating in this traffic light If a link could not be found.
Definition: NBOwnTLDef.cpp:485
SUMOReal getDirectionalWeight(LinkDirection dir)
Returns the weight of a stream given its direction.
Definition: NBOwnTLDef.cpp:87
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:41
NBTrafficLightLogic * myCompute(const NBEdgeCont &ec, unsigned int brakingTimeSeconds)
Computes the traffic light logic finally in dependence to the type.
Definition: NBOwnTLDef.cpp:185
static SUMOReal getMinAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
Definition: GeomHelper.cpp:405
const NBNode * node
The parent node of this crossing.
Definition: NBNode.h:138
EdgeVector edges
The edges being crossed.
Definition: NBNode.h:140
Represents a single node (junction) during network building.
Definition: NBNode.h:75
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 &quot;prohibited&quot; flow must let &quot;prohibitor&quot; flow pass.
A definition of a pedestrian crossing.
Definition: NBNode.h:133
#define SUMOReal
Definition: config.h:215
void initNeedsContRelation() const
Definition: NBOwnTLDef.cpp:523
static SUMOReal relAngle(SUMOReal angle1, SUMOReal angle2)
Definition: NBHelpers.cpp:63
#define NUMERICAL_EPS
Definition: config.h:162
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:54
void addStep(SUMOTime duration, const std::string &state, int index=-1)
Adds a phase to the logic.
Sorts edges by their priority within the node they end at.
Definition: NBOwnTLDef.h:228
void setParticipantsInformation()
Builds the list of participating nodes/edges/links.
Definition: NBOwnTLDef.cpp:491
NBConnectionVector myControlledLinks
The list of controlled links.
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:2150
int getToPrio(const NBEdge *const e)
Returns this edge&#39;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:513
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.