Eclipse SUMO - Simulation of Urban MObility
MSSOTLTrafficLightLogic.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2013-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 abstract class for SOTL logics
17 /****************************************************************************/
18 
20 #include "../MSLane.h"
21 #include "../MSEdge.h"
22 #include "MSPushButton.h"
23 
24 #if 1
25 #define ANALYSIS_DBG(X) {X}
26 #else
27 #define ANALYSIS_DBG(X) DBG(X)
28 #endif
29 // ===========================================================================
30 // member method definitions
31 // ===========================================================================
33  MSTLLogicControl& tlcontrol,
34  const std::string& id,
35  const std::string& programID,
36  const TrafficLightType logicType,
37  const Phases& phases,
38  int step,
39  SUMOTime delay,
40  const std::map<std::string, std::string>& parameters)
41  : MSPhasedTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay, parameters) {
42  this->mySensors = nullptr;
43  this->myCountSensors = nullptr;
44  sensorsSelfBuilt = true;
45  checkPhases();
46  setupCTS();
48 }
49 
51  MSTLLogicControl& tlcontrol,
52  const std::string& id,
53  const std::string& programID,
54  const TrafficLightType logicType,
55  const Phases& phases,
56  int step,
57  SUMOTime delay,
58  const std::map<std::string, std::string>& parameters,
59  MSSOTLSensors* sensors)
60  : MSPhasedTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay, parameters) {
61  this->mySensors = sensors;
62  sensorsSelfBuilt = false;
63  checkPhases();
64  setupCTS();
66 }
67 
69  for (PhasePushButtons::iterator mapIt = m_pushButtons.begin(); mapIt != m_pushButtons.end(); ++mapIt)
70  for (std::vector<MSPushButton*>::iterator vIt = mapIt->second.begin(); vIt != mapIt->second.end(); ++vIt) {
71  delete *vIt;
72  }
73  m_pushButtons.clear();
74  for (int i = 0; i < (int)myPhases.size(); i++) {
75  delete myPhases[i];
76  }
77  if (sensorsSelfBuilt) {
78  delete mySensors;
79 // delete myCountSensors;
80  }
81 }
82 
84 
85 }
86 
87 void
89  for (int step = 0; step < (int)getPhases().size(); step++) {
90  if (getPhase(step).isUndefined()) {
91  MsgHandler::getErrorInstance()->inform("Step " + toString(step) + " of traffic light logic " + myID + " phases declaration has its type undeclared!");
92  }
93  }
94 }
95 
96 void
98  for (int phaseStep = 0; phaseStep < (int)getPhases().size(); phaseStep++) {
99  if (getPhase(phaseStep).isTarget()) {
100  targetPhasesCTS[phaseStep] = 0;
102  targetPhasesLastSelection[phaseStep] = 0;
103  }
104  }
105 }
106 
107 void
109  for (int step = 0; step < (int)getPhases().size(); step++) {
110  if (getPhase(step).isTarget()) {
111  setStep(step);
112  lastChain = step;
113  return;
114  }
115  }
116  MsgHandler::getErrorInstance()->inform("No phase of type target found for traffic light logic " + myID + " The logic could malfunction. Check phases declaration.");
117 }
118 
119 
120 void
122 
124 
126  decayThreshold = 1;
127  }
128  if (sensorsSelfBuilt) {
129  //Building SOTLSensors
130  switch (SENSORS_TYPE) {
131  case SENSORS_TYPE_E1:
132  assert(0); // Throw exception because TLS can only handle E2 sensors
133  case SENSORS_TYPE_E2:
134 
135  //Adding Sensors to the ingoing Lanes
136 
138 
139  DBG(
140  WRITE_MESSAGE("Listing lanes for TLS " + getID());
141 
142  for (int i = 0; i < lvv.size(); i++) {
143  LaneVector lv = lvv[i];
144 
145  for (int j = 0; j < lv.size(); j++) {
146  MSLane* lane = lv[j];
147  WRITE_MESSAGE(lane ->getID());
148  }
149  }
150  )
151 
155  if (getParameter("USE_VEHICLE_TYPES_WEIGHTS", "0") == "1") {
156  ((MSSOTLE2Sensors*) mySensors)->setVehicleWeigths(getParameter("VEHICLE_TYPES_WEIGHTS", ""));
157  }
158 
159  //threshold speed param for tuning with irace
160  ((MSSOTLE2Sensors*)mySensors)->setSpeedThresholdParam(getSpeedThreshold());
161 
162  myCountSensors = new MSSOTLE2Sensors(myID + "Count", &(getPhases()));
165 
166  //Adding Sensors to the outgoing Lanes
167 
169 
170 
171  DBG(
172  WRITE_MESSAGE("Listing output lanes");
173  for (int i = 0; i < myLinks.size(); i++) {
174  LinkVector oneLink = getLinksAt(i);
175 
176  for (int j = 0; j < oneLink.size(); j++) {
177 
178  MSLane* lane = oneLink[j]->getLane();
179  WRITE_MESSAGE(lane ->getID());
180 
181  }
182  }
183  )
184 
185 
186  LaneVectorVector myLaneVector;
187 
188  LaneVector outLanes;
189  LinkVectorVector myoutLinks = getLinks();
190 
191  for (int i = 0; i < (int)myLinks.size(); i++) {
192  LinkVector oneLink = getLinksAt(i);
193  for (int j = 0; j < (int)oneLink.size(); j++) {
194  MSLane* lane = oneLink[j]->getLane();
195  outLanes.push_back(lane);
196  }
197  }
198 
199  if (outLanes.size() > 0) {
200  myLaneVector.push_back(outLanes);
201  }
202  if (myLaneVector.size() > 0) {
203  ((MSSOTLE2Sensors*)mySensors)->buildOutSensors(myLaneVector, nb, getOutputSensorsLength());
204  myCountSensors->buildCountOutSensors(myLaneVector, nb);
205  }
206 
207  }
208  }
209 }
210 
211 
212 void
214  std::map<int, SUMOTime>::iterator phaseIterator = targetPhasesCTS.find(phaseStep);
215  if (phaseIterator != targetPhasesCTS.end()) {
216  phaseIterator->second = 0;
218  }
219 }
220 
221 void
223  SUMOTime elapsedTimeSteps = 0;
225  //Iterate over the target phase map and update CTS value for every target phase except for the one belonging to the current steps chain
226  for (std::map<int, SUMOTime>::iterator mapIterator = targetPhasesCTS.begin();
227  mapIterator != targetPhasesCTS.end();
228  mapIterator++) {
229  int chain = mapIterator->first;
230  SUMOTime oldVal = mapIterator->second;
231  if (chain != lastChain) {
232  //Get the number of timesteps since the last check for that phase
233  elapsedTimeSteps = now - lastCheckForTargetPhase[chain];
234  //Update the last check time
235  lastCheckForTargetPhase[chain] = now;
236  //Increment the CTS
237  //SWITCH between 3 counting vehicles function
238  switch (getMode()) {
239  case (0):
240  mapIterator->second += elapsedTimeSteps
241  * countVehicles(getPhase(chain)); //SUMO
242  break;
243  case (1):
244  mapIterator->second += elapsedTimeSteps
245  * countVehicles(getPhase(chain)); //COMPLEX
246  break;
247  case (2):
248  mapIterator->second = countVehicles(getPhase(chain)); //QUEUE
249  break;
250  default:
251  WRITE_ERROR("Unrecognized traffic threshold calculation mode");
252  }
253  std::ostringstream oss;
254  oss << "MSSOTLTrafficLightLogic::updateCTS->TLC " << getID() << " chain " << chain << " oldVal " << oldVal << " newVal " << mapIterator->second;
255  WRITE_MESSAGE(oss.str());
256  }
259  }
260  }
261 }
262 
263 int
265 
266  if (!phase.isTarget()) {
267  return 0;
268  }
269 
270  int accumulator = 0;
271  //Iterate over the target lanes for the current target phase to get the number of approaching vehicles
273  for (MSPhaseDefinition::LaneIdVector::const_iterator laneIterator = targetLanes.begin(); laneIterator != targetLanes.end(); laneIterator++) {
274  //SWITCH between 3 counting vehicles function
275  switch (getMode()) {
276  case (0):
277  accumulator += mySensors->countVehicles((*laneIterator)); //SUMO
278  break;
279  case (1):
280  accumulator += ((MSSOTLE2Sensors*)mySensors)->estimateVehicles((*laneIterator)); //COMPLEX
281  break;
282  case (2):
283  accumulator = MAX2((int)((MSSOTLE2Sensors*)mySensors)->getEstimateQueueLength((*laneIterator)), accumulator); //QUEUE
284  break;
285  default:
286  WRITE_ERROR("Unrecognized traffic threshold calculation mode");
287  }
288  }
289  return accumulator;
290 }
291 
292 void
294  if (getCurrentPhaseDef().isGreenPhase()) {
296  }
297 // ANALYSIS_DBG(
298  DBG(
299  std::stringstream out;
300  out << decayThreshold;
301  WRITE_MESSAGE("\n" + time2string(MSNet::getInstance()->getCurrentTimeStep()) + "\tMSSOTLTrafficLightLogic::updateDecayThreshold():: " + out.str());
302  )
303 }
304 bool
306 
307  DBG(
308  // WRITE_MESSAGE("\n" +time2string(MSNet::getInstance()->getCurrentTimeStep()) +"\tMSSOTLTrafficLightLogic::isThresholdPassed():: " + " tlsid=" + getID());
309 
310  std::ostringstream threshold_str;
311  // threshold_str << "tlsid=" << getID() << " targetPhaseCTS size=" << targetPhasesCTS.size();
312 // threshold_str << "\n";
313  WRITE_MESSAGE(threshold_str.str());
314  )
315  /*
316  * if a dynamic threshold based on the exponential decrease, if passed we force the phase change
317  */
318 // double random = ((double) RandHelper::rand(RAND_MAX) / (RAND_MAX));
319  double random = RandHelper::rand();
320 // ANALYSIS_DBG(
321  DBG(
323  std::ostringstream str;
324  str << time2string(MSNet::getInstance()->getCurrentTimeStep()) << "\tMSSOTLTrafficLightLogic::isThresholdPassed():: "
325  << " tlsid=" << getID() << " decayThreshold=" << decayThreshold << " random=" << random << ">" << (1 - decayThreshold)
326  << (random > (1 - decayThreshold) ? " true" : " false");
327 
328  WRITE_MESSAGE(str.str());
329  }
330  )
331  if (!isDecayThresholdActivated() || (isDecayThresholdActivated() && random > (1 - decayThreshold))) {
332  for (std::map<int, SUMOTime>::const_iterator iterator =
333  targetPhasesCTS.begin(); iterator != targetPhasesCTS.end();
334  iterator++) {
335  DBG(
336  SUMOTime step = MSNet::getInstance()->getCurrentTimeStep();
337  std::ostringstream threshold_str;
338  // threshold_str <<"\tTL " +getID()<<" time " +time2string(step)<< "(getThreshold()= " << getThreshold()
339  // << ", targetPhaseCTS= " << iterator->second << " )" << " phase="<<getPhase(iterator->first).getState();
340  threshold_str << getCurrentPhaseDef().getState() << ";" << time2string(step) << ";" << getThreshold()
341  << ";" << iterator->second << ";" << getPhase(iterator->first).getState() << ";"
342  << iterator->first << "!=" << lastChain;
343  WRITE_MESSAGE(threshold_str.str());
344  );
345  //Note that the current chain is not eligible to be directly targeted again, it would be unfair
346  if ((iterator->first != lastChain) && (getThreshold() <= iterator->second)) {
347  return true;
348  }
349  }
350  return false;
351  } else {
352  return true;
353  }
354 }
355 
356 
357 SUMOTime
359  MSPhaseDefinition currentPhase = getCurrentPhaseDef();
360 
362  SUMOTime elapsed = now - currentPhase.myLastSwitch;
363 
364  return elapsed;
365 }
366 
367 
368 int
370  SUMOTime maxCTS = 0;
371  int maxLastStep = getTargetPhaseMaxLastSelection();
372  bool usedMaxCTS = false;
373  std::vector<int> equalIndexes;
374  for (std::map<int, int>::const_iterator it = targetPhasesLastSelection.begin();
375  it != targetPhasesLastSelection.end(); ++it) {
376  if (it->first != lastChain) {
377  if (maxLastStep < it->second) {
378  maxLastStep = it->second;
379  equalIndexes.clear();
380  equalIndexes.push_back(it->first);
381  } else if (maxLastStep == it->second) {
382  equalIndexes.push_back(it->first);
383  }
384  }
385  }
386  if (equalIndexes.size() == 0) {
387  usedMaxCTS = true;
388  for (std::map<int, SUMOTime>::const_iterator iterator = targetPhasesCTS.begin();
389  iterator != targetPhasesCTS.end(); ++iterator) {
390  if (iterator->first != lastChain) {
391  if (maxCTS < iterator->second) {
392  maxCTS = iterator->second;
393  equalIndexes.clear();
394  equalIndexes.push_back(iterator->first);
395  } else if (maxCTS == iterator->second) {
396  equalIndexes.push_back(iterator->first);
397  }
398  }
399  }
400  }
401 
402  std::ostringstream oss;
403  oss << "MSSOTLTrafficLightLogic::getPhaseIndexWithMaxCTS-> TLC " << getID();
404  if (usedMaxCTS) {
405  oss << " maxCTS " << maxCTS;
406  } else {
407  oss << " forcing selection since not selected for " << maxLastStep;
408  }
409  if (equalIndexes.size() == 1) {
410  oss << " phase " << equalIndexes[0];
411  WRITE_MESSAGE(oss.str());
412  return equalIndexes[0];
413  } else {
414  const int index = RandHelper::getRandomFrom(equalIndexes);
415  oss << " phases [";
416  for (std::vector<int>::const_iterator it = equalIndexes.begin(); it != equalIndexes.end(); ++it) {
417  oss << *it << ", ";
418  }
419  oss << "]. Random select " << index;
420  WRITE_MESSAGE(oss.str());
421  return index;
422  }
423 }
424 
425 int
427  MSPhaseDefinition currentPhase = getCurrentPhaseDef();
428  //If the junction was in a commit step
429  //=> go to the target step that gives green to the set with the current highest CTS
430  // and return computeReturnTime()
431  if (currentPhase.isCommit()) {
432  // decide which chain to activate. Gotta work on this
433  return getPhaseIndexWithMaxCTS();
434  }
435  if (currentPhase.isTransient()) {
436  //If the junction was in a transient step
437  //=> go to the next step and return computeReturnTime()
438  return getCurrentPhaseIndex() + 1;
439  }
440 
441  if (currentPhase.isDecisional()) {
442 
443  if (canRelease()) {
444  return getCurrentPhaseIndex() + 1;
445  }
446  }
447 
448  return getCurrentPhaseIndex();
449 }
450 
451 SUMOTime
453  if (MSNet::getInstance()->getCurrentTimeStep() % 1000 == 0) {
454  WRITE_MESSAGE("MSSOTLTrafficLightLogic::trySwitch()")
455  // To check if decideNextPhase changes the step
456  int previousStep = getCurrentPhaseIndex() ;
457  SUMOTime elapsed = getCurrentPhaseElapsed();
458  // Update CTS according to sensors
459  updateCTS();
460 
461  // Invoking the function member, specialized for each SOTL logic
463  MSPhaseDefinition currentPhase = getCurrentPhaseDef();
464 
465  //At the end, check if new step started
466  if (getCurrentPhaseIndex() != previousStep) {
467  //Check if a new steps chain started
468  if (currentPhase.isTarget()) {
469  //Reset CTS for the ending steps chain
471  //Update lastTargetPhase
473  for (std::map<int, int>::iterator it = targetPhasesLastSelection.begin(); it != targetPhasesLastSelection.end(); ++ it) {
474  if (it->first == lastChain) {
475  if (it->second >= getTargetPhaseMaxLastSelection()) {
476  std::ostringstream oss;
477  oss << "Forced selection of the phase " << lastChain << " since its last selection was " << it->second << " changes ago";
478  WRITE_MESSAGE(oss.str())
479  }
480  it->second = 0;
481  } else if (it->first != previousStep) {
482  ++it->second;
483  }
484  }
486  decayThreshold = 1;
487  }
488  }
489  //Inform the sensors logic
491  //Store the time the new phase started
494  decayThreshold = 1;
495  }
496  ANALYSIS_DBG(
497  std::ostringstream oss;
498  oss << getID() << " from " << getPhase(previousStep).getState() << " to " << currentPhase.getState() << " after " << time2string(elapsed);
499  WRITE_MESSAGE(time2string(MSNet::getInstance()->getCurrentTimeStep()) + "\tMSSOTLTrafficLightLogic::trySwitch " + oss.str());
500  )
501  }
502  }
503  return computeReturnTime();
504 }
505 
507  if (getParameter("USE_PUSH_BUTTON", "0") == "0") {
508  return false;
509  }
510  const MSPhaseDefinition currentPhase = getCurrentPhaseDef();
511  if (m_pushButtons.find(currentPhase.getState()) == m_pushButtons.end()) {
512  m_pushButtons[currentPhase.getState()] = MSPedestrianPushButton::loadPushButtons(&currentPhase);
513  }
514  return MSPushButton::anyActive(m_pushButtons[currentPhase.getState()]);
515 }
516 
MSSOTLTrafficLightLogic::getTargetPhaseMaxLastSelection
int getTargetPhaseMaxLastSelection()
Definition: MSSOTLTrafficLightLogic.h:225
MSSOTLTrafficLightLogic::getMode
int getMode()
Definition: MSSOTLTrafficLightLogic.h:274
MSSOTLTrafficLightLogic::trySwitch
SUMOTime trySwitch()
Switches to the next phase.
Definition: MSSOTLTrafficLightLogic.cpp:452
MSSOTLTrafficLightLogic::mySensors
MSSOTLSensors * mySensors
Definition: MSSOTLTrafficLightLogic.h:202
MSTrafficLightLogic::getLinksAt
const LinkVector & getLinksAt(int i) const
Returns the list of links that are controlled by the signals at the given position.
Definition: MSTrafficLightLogic.h:212
MSTrafficLightLogic::myLinks
LinkVectorVector myLinks
The list of LinkVectors; each vector contains the links that belong to the same link index.
Definition: MSTrafficLightLogic.h:417
MSTrafficLightLogic::myLanes
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index.
Definition: MSTrafficLightLogic.h:420
MSPhaseDefinition::myLastSwitch
SUMOTime myLastSwitch
Stores the timestep of the last on-switched of the phase.
Definition: MSPhaseDefinition.h:82
MSSOTLE2Sensors::buildCountSensors
void buildCountSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
Definition: MSSOTLE2Sensors.cpp:63
MSSOTLTrafficLightLogic::resetCTS
void resetCTS(int phaseStep)
Definition: MSSOTLTrafficLightLogic.cpp:213
MSSOTLTrafficLightLogic::updateDecayThreshold
void updateDecayThreshold()
Definition: MSSOTLTrafficLightLogic.cpp:293
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSPhaseDefinition::isTransient
bool isTransient() const
Definition: MSPhaseDefinition.h:278
MSSOTLTrafficLightLogic::isThresholdPassed
bool isThresholdPassed()
Definition: MSSOTLTrafficLightLogic.cpp:305
MSSOTLSensors::stepChanged
virtual void stepChanged(int newStep)
Definition: MSSOTLSensors.h:127
MSSOTLTrafficLightLogic::updateCTS
void updateCTS()
Definition: MSSOTLTrafficLightLogic.cpp:222
MSSOTLE2Sensors::buildSensors
void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
This function member has to be extended to properly build sensors for the input lanes Sensors has to ...
Definition: MSSOTLE2Sensors.cpp:36
MSSOTLTrafficLightLogic::lastChain
int lastChain
Definition: MSSOTLTrafficLightLogic.h:235
MSPhasedTrafficLightLogic::myPhases
Phases myPhases
The list of phases this logic uses.
Definition: MSPhasedTrafficLightLogic.h:175
MSPhasedTrafficLightLogic::getPhase
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
Definition: MSPhasedTrafficLightLogic.cpp:117
DBG
#define DBG(X)
Definition: SwarmDebug.h:26
MSPhasedTrafficLightLogic::getCurrentPhaseDef
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
Definition: MSPhasedTrafficLightLogic.cpp:131
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:61
MSPushButton::anyActive
static bool anyActive(const std::vector< MSPushButton * > &)
Checks if any pushbutton in the vector is active.
Definition: MSPushButton.cpp:35
MSSOTLTrafficLightLogic::getSpeedThreshold
double getSpeedThreshold()
Definition: MSSOTLTrafficLightLogic.h:155
MsgHandler::inform
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:118
TrafficLightType
TrafficLightType
Definition: SUMOXMLDefinitions.h:1197
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSSOTLTrafficLightLogic::myCountSensors
MSSOTLE2Sensors * myCountSensors
Definition: MSSOTLTrafficLightLogic.h:207
MSSOTLTrafficLightLogic::canRelease
virtual bool canRelease()=0
MSPhaseDefinition::LaneIdVector
std::vector< std::string > LaneIdVector
Definition: MSPhaseDefinition.h:66
MSSOTLSensors::countVehicles
virtual int countVehicles(MSLane *lane)=0
MSSOTLTrafficLightLogic::getOutputSensorsLength
double getOutputSensorsLength()
Definition: MSSOTLTrafficLightLogic.h:163
MSSOTLTrafficLightLogic::isPushButtonPressed
bool isPushButtonPressed()
Definition: MSSOTLTrafficLightLogic.cpp:506
Parameterised::getParameter
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
Definition: Parameterised.cpp:72
MSPhasedTrafficLightLogic::setStep
void setStep(int step)
Forces a specific step.
Definition: MSPhasedTrafficLightLogic.cpp:96
MSSOTLTrafficLightLogic::getInputSensorsLength
double getInputSensorsLength()
Definition: MSSOTLTrafficLightLogic.h:159
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
MSSOTLTrafficLightLogic::getThreshold
int getThreshold()
Definition: MSSOTLTrafficLightLogic.h:151
MSPhaseDefinition::isDecisional
bool isDecisional() const
Definition: MSPhaseDefinition.h:285
MSTrafficLightLogic::LaneVector
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
Definition: MSTrafficLightLogic.h:70
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:53
MSPushButton.h
MSSOTLTrafficLightLogic::computeReturnTime
virtual SUMOTime computeReturnTime()
Definition: MSSOTLTrafficLightLogic.h:188
MSSOTLTrafficLightLogic::~MSSOTLTrafficLightLogic
~MSSOTLTrafficLightLogic()
Destructor.
Definition: MSSOTLTrafficLightLogic.cpp:68
MSSOTLTrafficLightLogic::isDecayThresholdActivated
bool isDecayThresholdActivated()
Definition: MSSOTLTrafficLightLogic.h:282
MSSOTLTrafficLightLogic::decideNextPhase
virtual int decideNextPhase()
Definition: MSSOTLTrafficLightLogic.cpp:426
MSPhaseDefinition::getState
const std::string & getState() const
Returns the state within this phase.
Definition: MSPhaseDefinition.h:199
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:283
MSSOTLTrafficLightLogic::setToATargetPhase
void setToATargetPhase()
Definition: MSSOTLTrafficLightLogic.cpp:108
MSSOTLTrafficLightLogic::getDecayConstant
double getDecayConstant()
Definition: MSSOTLTrafficLightLogic.h:286
MSPhaseDefinition::isCommit
bool isCommit() const
Definition: MSPhaseDefinition.h:292
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:67
RandHelper::getRandomFrom
static const T & getRandomFrom(const std::vector< T > &v, std::mt19937 *rng=0)
Returns a random element from the given vector.
Definition: RandHelper.h:149
MSSOTLTrafficLightLogic::checkPhases
void checkPhases()
Definition: MSSOTLTrafficLightLogic.cpp:88
MSSOTLTrafficLightLogic::sensorsSelfBuilt
bool sensorsSelfBuilt
Definition: MSSOTLTrafficLightLogic.h:213
MSPhaseDefinition::getTargetLaneSet
const LaneIdVector & getTargetLaneSet() const
Definition: MSPhaseDefinition.h:207
MSPhasedTrafficLightLogic::getPhases
const Phases & getPhases() const
Returns the phases of this tls program.
Definition: MSPhasedTrafficLightLogic.cpp:112
MSSOTLTrafficLightLogic::MSSOTLTrafficLightLogic
MSSOTLTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const TrafficLightType logicType, const Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > &parameters)
Constructor without sensors passed.
Definition: MSSOTLTrafficLightLogic.cpp:32
MSSOTLTrafficLightLogic::getPhaseIndexWithMaxCTS
int getPhaseIndexWithMaxCTS()
Definition: MSSOTLTrafficLightLogic.cpp:369
ANALYSIS_DBG
#define ANALYSIS_DBG(X)
Definition: MSSOTLTrafficLightLogic.cpp:25
MSPhasedTrafficLightLogic::getCurrentPhaseIndex
int getCurrentPhaseIndex() const
Returns the current index within the program.
Definition: MSPhasedTrafficLightLogic.cpp:125
MSTrafficLightLogic::getLaneVectors
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
Definition: MSTrafficLightLogic.h:182
MSPhaseDefinition::isUndefined
bool isUndefined() const
Definition: MSPhaseDefinition.h:264
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
MSTrafficLightLogic::getLinks
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
Definition: MSTrafficLightLogic.h:203
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
MSSOTLE2Sensors
Definition: MSSOTLE2Sensors.h:32
SENSORS_TYPE
#define SENSORS_TYPE
Definition: MSSOTLDefinitions.h:42
MSPedestrianPushButton::loadPushButtons
static std::vector< MSPushButton * > loadPushButtons(const MSPhaseDefinition *)
Loads all the pushbuttons for all the controlled lanes of a stage.
Definition: MSPushButton.cpp:148
MSSOTLTrafficLightLogic.h
MSSOTLTrafficLightLogic::countVehicles
int countVehicles(MSPhaseDefinition phase)
Definition: MSSOTLTrafficLightLogic.cpp:264
MSSOTLTrafficLightLogic::targetPhasesCTS
std::map< int, SUMOTime > targetPhasesCTS
Definition: MSSOTLTrafficLightLogic.h:216
MSSOTLTrafficLightLogic::m_pushButtons
PhasePushButtons m_pushButtons
Definition: MSSOTLTrafficLightLogic.h:117
MSTrafficLightLogic::LaneVectorVector
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
Definition: MSTrafficLightLogic.h:73
MSSOTLSensors
Definition: MSSOTLSensors.h:32
MSSOTLTrafficLightLogic::targetPhasesLastSelection
std::map< int, int > targetPhasesLastSelection
Definition: MSSOTLTrafficLightLogic.h:223
SENSORS_TYPE_E2
#define SENSORS_TYPE_E2
Definition: MSSOTLDefinitions.h:41
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:59
MSPhaseDefinition::isTarget
bool isTarget() const
Definition: MSPhaseDefinition.h:271
MSSOTLTrafficLightLogic::decayThreshold
double decayThreshold
Definition: MSSOTLTrafficLightLogic.h:237
MSSOTLTrafficLightLogic::lastCheckForTargetPhase
std::map< int, SUMOTime > lastCheckForTargetPhase
Definition: MSSOTLTrafficLightLogic.h:220
MSPhaseDefinition
The definition of a single phase of a tls logic.
Definition: MSPhaseDefinition.h:51
MsgHandler::getErrorInstance
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:81
MSTrafficLightLogic::init
virtual void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
Definition: MSTrafficLightLogic.cpp:115
MSTrafficLightLogic::LinkVectorVector
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
Definition: MSTrafficLightLogic.h:67
MSSOTLTrafficLightLogic::logStatus
void logStatus()
Definition: MSSOTLTrafficLightLogic.cpp:83
MSSOTLTrafficLightLogic::init
void init(NLDetectorBuilder &nb)
Initialises the tls with sensors on incoming and outgoing lanes Sensors are built in the simulation a...
Definition: MSSOTLTrafficLightLogic.cpp:121
Named::myID
std::string myID
The name of the object.
Definition: Named.h:133
SENSORS_TYPE_E1
#define SENSORS_TYPE_E1
Definition: MSSOTLDefinitions.h:40
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283
MSTrafficLightLogic::LinkVector
std::vector< MSLink * > LinkVector
Definition of the list of links that are subjected to this tls.
Definition: MSTrafficLightLogic.h:64
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
MSSOTLTrafficLightLogic::setupCTS
void setupCTS()
Definition: MSSOTLTrafficLightLogic.cpp:97
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:55
MSSOTLTrafficLightLogic::getCurrentPhaseElapsed
SUMOTime getCurrentPhaseElapsed()
Definition: MSSOTLTrafficLightLogic.cpp:358
MSSOTLE2Sensors::buildCountOutSensors
void buildCountOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
Definition: MSSOTLE2Sensors.cpp:80
MSPhasedTrafficLightLogic
A fixed traffic light logic.
Definition: MSPhasedTrafficLightLogic.h:47