#include <MSAgentbasedTrafficLightLogic.h>

Definition at line 58 of file MSAgentbasedTrafficLightLogic.h.
Public Types | |
| typedef std::map< MSLane *, MS_E2_ZS_CollectorOverLanes * > | E2DetectorMap |
| Definition of a map from lanes to lane state detectors lying on them. | |
| typedef std::map< unsigned int, SUMOReal > | MeanDataMap |
| Definition of a map which stores the mean data of several (numberOfValues) cycles. | |
| typedef std::map< unsigned int, ValueType > | PhaseValueMap |
| Definition of a map which stores the step of the greenphases and their detector values. | |
| typedef std::deque< SUMOReal > | ValueType |
| Definition of a map which stores the detector values of one single phase. | |
Structure definitions | |
| typedef std::vector< MSLane * > | LaneVector |
| Definition of the list of links that participate in this tl-light. | |
| typedef std::vector< LaneVector > | LaneVectorVector |
| Definition of a list that holds lists of links that do have the same attribute. | |
| typedef std::vector< MSLink * > | LinkVector |
| Definition of the list of links that participate in this tl-light. | |
| typedef std::vector< LinkVector > | LinkVectorVector |
| Definition of a list that holds lists of links that do have the same attribute. | |
| typedef std::vector < MSPhaseDefinition * > | Phases |
| Definition of a list of phases, being the junction logic. | |
Public Member Functions | |
| void | init (NLDetectorBuilder &nb) throw (ProcessError) |
| Initialises the tls with information about incoming lanes. | |
| MSAgentbasedTrafficLightLogic (MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const MSSimpleTrafficLightLogic::Phases &phases, unsigned int step, SUMOTime delay, int learnHorizon, int decHorizon, SUMOReal minDiff, int tcycle) throw () | |
| Constructor. | |
| ~MSAgentbasedTrafficLightLogic () throw () | |
| Destructor. | |
Handling of controlled links | |
| virtual void | adaptLinkInformationFrom (const MSTrafficLightLogic &logic) throw () |
| Applies information about controlled links and lanes from the given logic. | |
| void | addLink (MSLink *link, MSLane *lane, unsigned int pos) throw () |
| Adds a link on building. | |
| std::map< MSLink *, std::pair < MSLink::LinkState, bool > > | collectLinkStates () const throw () |
| Returns the (uncontrolled) states of the controlled links. | |
| void | resetLinkStates (const std::map< MSLink *, std::pair< MSLink::LinkState, bool > > &vals) const throw () |
| Resets the states of controlled links. | |
Changing phases and phase durations | |
| void | addOverridingDuration (SUMOTime duration) throw () |
| Changes the duration of the next phase. | |
| void | setCurrentDurationIncrement (SUMOTime delay) throw () |
| Delays current phase by the given delay. | |
Changing phases and phase durations | |
| void | changeStepAndDuration (MSTLLogicControl &tlcontrol, SUMOTime simStep, unsigned int step, SUMOTime stepDuration) throw () |
| Changes the current phase and her duration. | |
Dynamic Information Retrieval | |
| const MSPhaseDefinition & | getCurrentPhaseDef () const throw () |
| Returns the definition of the current phase. | |
| unsigned int | getCurrentPhaseIndex () const throw () |
| Returns the current index within the program. | |
Dynamic Information Retrieval | |
| unsigned int | getDefaultCycleTime () const throw () |
| Returns the cycle time. | |
| SUMOTime | getNextSwitchTime () const throw () |
| Returns the assumed next switch time. | |
Static Information Retrieval | |
| const std::string & | getID () const throw () |
| Returns this tl-logic's id. | |
| const LaneVectorVector & | getLanes () const throw () |
| Returns the list of lists of all lanes controlled by this tls. | |
| const LaneVector & | getLanesAt (unsigned int i) const throw () |
| Returns the list of lanes that are controlled by the signals at the given position. | |
| int | getLinkIndex (const MSLink *const link) const throw () |
| Returns the index of the given link. | |
| const LinkVectorVector & | getLinks () const throw () |
| Returns the list of lists of all affected links. | |
| const LinkVector & | getLinksAt (unsigned int i) const throw () |
| Returns the list of links that are controlled by the signals at the given position. | |
| const std::string & | getSubID () const throw () |
| Returns this tl-logic's id. | |
Conversion between time and phase | |
| unsigned int | getIndexFromOffset (unsigned int offset) const throw () |
| Returns the step (the phasenumber) of a given position of the cycle. | |
| unsigned int | getOffsetFromIndex (unsigned int index) const throw () |
| Returns the position (start of a phase during a cycle) from of a given step. | |
| unsigned int | getPhaseIndexAtTime (SUMOTime simStep) const throw () |
| Returns the index of the logic at the given simulation step. | |
Algorithm parameter handling | |
| std::string | getParameterValue (const std::string &key) const throw () |
| Returns a named parameter. | |
| void | setParameter (const std::map< std::string, std::string > ¶ms) throw () |
| Inserts read parameter. | |
Static Information Retrieval | |
| const MSPhaseDefinition & | getPhase (unsigned int givenstep) const throw () |
| Returns the definition of the phase from the given position within the plan. | |
| unsigned int | getPhaseNumber () const throw () |
| Returns the number of phases. | |
| Phases & | getPhases () throw () |
| Returns the phases of this tls program. | |
| const Phases & | getPhases () const throw () |
| Returns the phases of this tls program. | |
Switching and setting current rows | |
| void | setLinkPriorities () const throw () |
| Applies the priorities resulting from the current phase to controlled links. | |
| bool | setTrafficLightSignals () const throw () |
| Clears all incoming vehicle information on links that have red. | |
Switching and setting current rows | |
| SUMOTime | trySwitch (bool isActive) throw () |
| Switches to the next phase. | |
Protected Member Functions | |
"agentbased" algorithm methods | |
| void | aggregateRawData () throw () |
| Aggregates the data of one phase, collected during different cycles. | |
| void | calculateDuration () throw () |
| Calculates the duration for all real phases except intergreen phases. | |
| void | collectData () throw () |
| Collects the traffic data. | |
| void | cutCycleTime (unsigned int toCut) throw () |
| cuts the actual cycle by an given value | |
| unsigned int | findStepOfMaxValue () const throw () |
| Returns the step of the phase with the longest Queue_Lengt_Ahead_Of_Traffic_Lights. | |
| unsigned int | findStepOfMinValue () const throw () |
| Returns the step of the phase with the shortest Queue_Lengt_Ahead_Of_Traffic_Lights. | |
| void | lengthenCycleTime (unsigned int toLenghten) throw () |
| lenghtens the actual cycle by an given value | |
| unsigned int | nextStep () throw () |
| Returns the index of the phase next to the given phase. | |
Protected Attributes | |
| SUMOReal | deltaLimit |
| SUMOTime | myCurrentDurationIncrement |
| A value for enlarge the current duration. | |
| unsigned int | myDefaultCycleTime |
| The cycle time (without changes). | |
| E2DetectorMap | myE2Detectors |
| A map from lanes to E2-detectors lying on them. | |
| std::string | myID |
| The id of the logic. | |
| LaneVectorVector | myLanes |
| The list of links which do participate in this traffic light. | |
| LinkVectorVector | myLinks |
| The list of links which do participate in this traffic light. | |
| MeanDataMap | myMeanDetectorData |
| A map of the step of the greenphases and their aggregated detectordata. | |
| std::vector< SUMOTime > | myOverridingTimes |
| A list of duration overrides. | |
| std::map< std::string, std::string > | myParameter |
| Given parameter. | |
| Phases | myPhases |
| The list of phases this logic uses. | |
| PhaseValueMap | myRawDetectorData |
| A map of the step of the greenphases and their detectorvalues for several (mumberofValues) cycles. | |
| unsigned int | myStep |
| The current step. | |
| std::string | mySubID |
| SwitchCommand * | mySwitchCommand |
| The current switch command. | |
| unsigned int | numberOfValues |
| The number of detector values whivh is considered to make a decision. | |
| unsigned int | stepOfLastDecision |
| Stores the step of the phase, when the last decision was made. | |
| unsigned int | tCycle |
| The cycletime of the trafficlight. | |
| unsigned int | tDecide |
| the interval in which the traffic light can make a decision | |
| unsigned int | tSinceLastDecision |
| The number of cycles, before the last decision was made. | |
| typedef std::map<MSLane*, MS_E2_ZS_CollectorOverLanes*> MSAgentbasedTrafficLightLogic::E2DetectorMap |
Definition of a map from lanes to lane state detectors lying on them.
Definition at line 62 of file MSAgentbasedTrafficLightLogic.h.
typedef std::vector<MSLane*> MSTrafficLightLogic::LaneVector [inherited] |
Definition of the list of links that participate in this tl-light.
Definition at line 72 of file MSTrafficLightLogic.h.
typedef std::vector<LaneVector> MSTrafficLightLogic::LaneVectorVector [inherited] |
Definition of a list that holds lists of links that do have the same attribute.
Definition at line 75 of file MSTrafficLightLogic.h.
typedef std::vector<MSLink*> MSTrafficLightLogic::LinkVector [inherited] |
Definition of the list of links that participate in this tl-light.
Definition at line 66 of file MSTrafficLightLogic.h.
typedef std::vector<LinkVector> MSTrafficLightLogic::LinkVectorVector [inherited] |
Definition of a list that holds lists of links that do have the same attribute.
Definition at line 69 of file MSTrafficLightLogic.h.
| typedef std::map<unsigned int, SUMOReal> MSAgentbasedTrafficLightLogic::MeanDataMap |
Definition of a map which stores the mean data of several (numberOfValues) cycles.
Definition at line 71 of file MSAgentbasedTrafficLightLogic.h.
typedef std::vector<MSPhaseDefinition*> MSTrafficLightLogic::Phases [inherited] |
Definition of a list of phases, being the junction logic.
Definition at line 63 of file MSTrafficLightLogic.h.
| typedef std::map<unsigned int, ValueType> MSAgentbasedTrafficLightLogic::PhaseValueMap |
Definition of a map which stores the step of the greenphases and their detector values.
Definition at line 68 of file MSAgentbasedTrafficLightLogic.h.
| typedef std::deque<SUMOReal> MSAgentbasedTrafficLightLogic::ValueType |
Definition of a map which stores the detector values of one single phase.
Definition at line 65 of file MSAgentbasedTrafficLightLogic.h.
| MSAgentbasedTrafficLightLogic::MSAgentbasedTrafficLightLogic | ( | MSTLLogicControl & | tlcontrol, | |
| const std::string & | id, | |||
| const std::string & | subid, | |||
| const MSSimpleTrafficLightLogic::Phases & | phases, | |||
| unsigned int | step, | |||
| SUMOTime | delay, | |||
| int | learnHorizon, | |||
| int | decHorizon, | |||
| SUMOReal | minDiff, | |||
| int | tcycle | |||
| ) | throw () |
Constructor.
| [in] | tlcontrol | The tls control responsible for this tls |
| [in] | id | This tls' id |
| [in] | subid | This tls' sub-id (program id) |
| [in] | phases | Definitions of the phases |
| [in] | step | The initial phase index |
| [in] | delay | The time to wait before the first switch |
| [in] | learnHorizon | !!! |
| [in] | decHorizon | !!! |
| [in] | minDiff | !!! |
| [in] | tcycle | !!! |
| MSAgentbasedTrafficLightLogic::~MSAgentbasedTrafficLightLogic | ( | ) | throw () |
| void MSTrafficLightLogic::adaptLinkInformationFrom | ( | const MSTrafficLightLogic & | logic | ) | throw () [virtual, inherited] |
Applies information about controlled links and lanes from the given logic.
If we load a logic after the network has been loaded, we do not get the information about controlled links afterwards. We have to copy them from a previously loaded logic.
| [in] | logic | The logic to use the information about controlled links/lanes from |
Reimplemented in MSOffTrafficLightLogic.
Definition at line 139 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLanes, and MSTrafficLightLogic::myLinks.
Referenced by MSOffTrafficLightLogic::adaptLinkInformationFrom().
| void MSTrafficLightLogic::addLink | ( | MSLink * | link, | |
| MSLane * | lane, | |||
| unsigned int | pos | |||
| ) | throw () [inherited] |
Adds a link on building.
| [in] | link | The controlled link |
| [in] | lane | The lane this link starts at |
| [in] | pos | The link's index (signal group) within this program |
Definition at line 122 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLanes, and MSTrafficLightLogic::myLinks.
00122 { 00123 // !!! should be done within the loader (checking necessary) 00124 myLinks.reserve(pos+1); 00125 while (myLinks.size()<=pos) { 00126 myLinks.push_back(LinkVector()); 00127 } 00128 myLinks[pos].push_back(link); 00129 // 00130 myLanes.reserve(pos+1); 00131 while (myLanes.size()<=pos) { 00132 myLanes.push_back(LaneVector()); 00133 } 00134 myLanes[pos].push_back(lane); 00135 }
| void MSTrafficLightLogic::addOverridingDuration | ( | SUMOTime | duration | ) | throw () [inherited] |
Changes the duration of the next phase.
| [in] | duration | The new duration |
Definition at line 198 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myOverridingTimes.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::cutLogic(), and MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic().
00198 { 00199 myOverridingTimes.push_back(duration); 00200 }
| void MSAgentbasedTrafficLightLogic::aggregateRawData | ( | ) | throw () [protected] |
Aggregates the data of one phase, collected during different cycles.
Definition at line 211 of file MSAgentbasedTrafficLightLogic.cpp.
References myMeanDetectorData, myRawDetectorData, and SUMOReal.
Referenced by calculateDuration().
00211 { 00212 for (PhaseValueMap::const_iterator i = myRawDetectorData.begin(); i!=myRawDetectorData.end(); i++) { 00213 SUMOReal sum = 0; 00214 for (ValueType:: const_iterator it = myRawDetectorData[(*i).first].begin(); it != myRawDetectorData[(*i).first].end(); it ++) { 00215 sum = sum + *it; 00216 } 00217 SUMOReal meanvalue = sum / myRawDetectorData[(*i).first].size(); 00218 myMeanDetectorData[(*i).first] = meanvalue; 00219 } 00220 }
| void MSAgentbasedTrafficLightLogic::calculateDuration | ( | ) | throw () [protected] |
Calculates the duration for all real phases except intergreen phases.
Definition at line 224 of file MSAgentbasedTrafficLightLogic.cpp.
References aggregateRawData(), deltaLimit, findStepOfMaxValue(), findStepOfMinValue(), myMeanDetectorData, MSSimpleTrafficLightLogic::myPhases, MSSimpleTrafficLightLogic::myStep, stepOfLastDecision, SUMOReal, and tSinceLastDecision.
Referenced by trySwitch().
00224 { 00225 aggregateRawData(); 00226 unsigned int stepOfMaxValue = findStepOfMaxValue(); 00227 if (stepOfMaxValue == myPhases.size()) { 00228 return; 00229 } 00230 unsigned int stepOfMinValue = findStepOfMinValue(); 00231 if (stepOfMinValue == myPhases.size()) { 00232 return; 00233 } 00234 if (stepOfMinValue == stepOfMaxValue) { 00235 return; 00236 } 00237 SUMOReal deltaIst = (myMeanDetectorData[stepOfMaxValue] - myMeanDetectorData[stepOfMinValue]) 00238 / myMeanDetectorData[stepOfMaxValue]; 00239 if (deltaIst > deltaLimit) { 00240 myPhases[stepOfMaxValue]->duration = myPhases[stepOfMaxValue]->duration +1; 00241 myPhases[stepOfMinValue]->duration = myPhases[stepOfMinValue]->duration -1; 00242 tSinceLastDecision = 0; 00243 stepOfLastDecision = myStep; 00244 } 00245 }
| void MSSimpleTrafficLightLogic::changeStepAndDuration | ( | MSTLLogicControl & | tlcontrol, | |
| SUMOTime | simStep, | |||
| unsigned int | step, | |||
| SUMOTime | stepDuration | |||
| ) | throw () [virtual, inherited] |
Changes the current phase and her duration.
| [in] | tlcontrol | The responsible traffic lights control |
| [in] | simStep | The current simulation step |
| [in] | step | Index of the phase to use |
| [in] | stepDuration | The left duration of the phase |
Implements MSTrafficLightLogic.
Definition at line 218 of file MSSimpleTrafficLightLogic.cpp.
References MSEventControl::ADAPT_AFTER_EXECUTION, MSEventControl::addEvent(), MSTrafficLightLogic::SwitchCommand::deschedule(), MSNet::getBeginOfTimestepEvents(), MSNet::getInstance(), MSSimpleTrafficLightLogic::myStep, and MSTrafficLightLogic::mySwitchCommand.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_GSP::adaptLogic(), GUIViewTraffic::onGamingClick(), and MSTLLogicControl::WAUTSwitchProcedure::switchToPos().
00219 { 00220 mySwitchCommand->deschedule(this); 00221 mySwitchCommand = new SwitchCommand(tlcontrol, this, stepDuration+simStep); 00222 myStep = step; 00223 MSNet::getInstance()->getBeginOfTimestepEvents().addEvent( 00224 mySwitchCommand, stepDuration+simStep, 00225 MSEventControl::ADAPT_AFTER_EXECUTION); 00226 }
| void MSAgentbasedTrafficLightLogic::collectData | ( | ) | throw () [protected] |
Collects the traffic data.
!! SUMOReal tmp = currentForLane(E2::QUEUE_LENGTH_AHEAD_OF_TRAFFIC_LIGHTS_IN_VEHICLES, *j); if (maxPerBit < tmp) { maxPerBit = tmp; } E2DetectorMap::const_iterator it=myE2Detectors.find(*j); (*it).second->resetQueueLengthAheadOfTrafficLights();
Definition at line 160 of file MSAgentbasedTrafficLightLogic.cpp.
References MSEdge::EDGEFUNCTION_INTERNAL, MSSimpleTrafficLightLogic::getCurrentPhaseDef(), MSTrafficLightLogic::getLanesAt(), MSPhaseDefinition::getState(), MSLink::LINKSTATE_TL_GREEN_MAJOR, MSLink::LINKSTATE_TL_GREEN_MINOR, myRawDetectorData, MSSimpleTrafficLightLogic::myStep, numberOfValues, size, and SUMOReal.
Referenced by trySwitch().
00160 { 00161 //collects the traffic data 00162 00163 // gets a copy of the driveMask 00164 const std::string &state = getCurrentPhaseDef().getState(); 00165 // finds the maximum QUEUE_LENGTH_AHEAD_OF_TRAFFIC_LIGHTS_IN_VEHICLES of one phase 00166 SUMOReal maxPerPhase = 0; 00167 for (unsigned int i=0; i<(unsigned int) state.size(); i++) { 00168 /* finds the maximum QUEUE_LENGTH_AHEAD_OF_TRAFFIC_LIGHTS_IN_VEHICLES 00169 of all lanes of a bit of the drivemask, that shows green */ 00170 if (state[i]==MSLink::LINKSTATE_TL_GREEN_MAJOR||state[i]==MSLink::LINKSTATE_TL_GREEN_MINOR) { 00171 const std::vector<MSLane*> &lanes = getLanesAt(i); 00172 if (lanes.empty()) { 00173 break; 00174 } 00175 SUMOReal maxPerBit = 0; 00176 for (LaneVector::const_iterator j=lanes.begin(); j!=lanes.end(); j++) { 00177 if ((*j)->getEdge().getPurpose()==MSEdge::EDGEFUNCTION_INTERNAL) { 00178 continue; 00179 } 00188 } 00189 if (maxPerPhase < maxPerBit) { 00190 maxPerPhase = maxPerBit; 00191 } 00192 } 00193 } 00194 // if still no entry for the phase exists a new entry with an empty value is created 00195 if (myRawDetectorData.find(myStep) == myRawDetectorData.end()) { 00196 ValueType firstData; 00197 myRawDetectorData[myStep] = firstData; 00198 } 00199 /* checks whether the number of values that are already in the dataqueue is 00200 the same number of values taht shall be consideres in the traffic control 00201 if both numbers are the same, the oldest value is deleted */ 00202 if (myRawDetectorData[myStep].size()== numberOfValues) { 00203 myRawDetectorData[myStep].pop_back(); 00204 } 00205 // adds the detectorvalue of the considered phase 00206 myRawDetectorData[myStep].push_front(maxPerPhase); 00207 }
| std::map< MSLink *, std::pair< MSLink::LinkState, bool > > MSTrafficLightLogic::collectLinkStates | ( | ) | const throw () [inherited] |
Returns the (uncontrolled) states of the controlled links.
Definition at line 146 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLinks.
Referenced by MSTLLogicControl::TLSLogicVariants::saveInitialStates().
00146 { 00147 std::map<MSLink*, std::pair<MSLink::LinkState, bool> > ret; 00148 for (LinkVectorVector::const_iterator i1=myLinks.begin(); i1!=myLinks.end(); ++i1) { 00149 const LinkVector &l = (*i1); 00150 for (LinkVector::const_iterator i2=l.begin(); i2!=l.end(); ++i2) { 00151 ret[*i2] = std::make_pair((*i2)->getState(), (*i2)->havePriority()); 00152 } 00153 } 00154 return ret; 00155 }
| void MSAgentbasedTrafficLightLogic::cutCycleTime | ( | unsigned int | toCut | ) | throw () [protected] |
cuts the actual cycle by an given value
| [in] | toCut | The time decrease |
Definition at line 288 of file MSAgentbasedTrafficLightLogic.cpp.
References MSSimpleTrafficLightLogic::myPhases, and SUMOReal.
00288 { 00289 typedef std::pair <unsigned int, unsigned int> contentType; 00290 typedef std::vector< std::pair <unsigned int, unsigned int> > GreenPhasesVector; 00291 GreenPhasesVector tmp_phases(myPhases.size()); 00292 tmp_phases.clear(); 00293 unsigned maxCut = 0; // the sum of all times, that is possible to cut 00294 00295 /* fills the vector tmp_phases with the difference between 00296 duration and minduration and the myStep of the phases. 00297 only phases with duration > minDuration are written in the vector. 00298 sorts the vector after the difference. */ 00299 for (unsigned i_Step = 0; i_Step!=myPhases.size(); i_Step++) { 00300 if (myPhases[i_Step]->isGreenPhase()) { 00301 unsigned int dur = myPhases[i_Step]->duration; 00302 unsigned int mindur = myPhases[i_Step]->minDuration; 00303 if (dur > mindur) { 00304 contentType tmp; 00305 tmp.second = i_Step; 00306 tmp.first = dur - mindur; 00307 tmp_phases.push_back(tmp); 00308 maxCut = maxCut + tmp.first; 00309 } 00310 } 00311 } 00312 std::sort(tmp_phases.begin(), tmp_phases.end()); 00313 //cuts the phases acording to the difference between duration and minDuration 00314 for (GreenPhasesVector::iterator i=tmp_phases.begin(); i!=tmp_phases.end(); i++) { 00315 SUMOTime toCutPerPhase = 0; 00316 SUMOReal tmpdb = ((*i).first * toCut / SUMOReal(maxCut)) + (SUMOReal) 0.5; 00317 toCutPerPhase = static_cast<SUMOTime>(tmpdb); 00318 toCut = toCut - toCutPerPhase; 00319 maxCut = maxCut - (*i).first; 00320 SUMOTime newDur = myPhases[(*i).second]->duration - toCutPerPhase; 00321 myPhases[(*i).second]->duration = newDur; 00322 } 00323 }
| unsigned int MSAgentbasedTrafficLightLogic::findStepOfMaxValue | ( | ) | const throw () [protected] |
Returns the step of the phase with the longest Queue_Lengt_Ahead_Of_Traffic_Lights.
Definition at line 327 of file MSAgentbasedTrafficLightLogic.cpp.
References myMeanDetectorData, MSSimpleTrafficLightLogic::myPhases, and SUMOReal.
Referenced by calculateDuration().
00327 { 00328 unsigned int StepOfMaxValue = (unsigned int) myPhases.size(); 00329 SUMOReal MaxValue = -1; 00330 for (MeanDataMap::const_iterator it = myMeanDetectorData.begin(); it!=myMeanDetectorData.end(); it++) { 00331 // checks whether the actual duruation is shorter than maxduration 00332 // otherwise the phase can't be lenghten 00333 unsigned int maxDur = myPhases[(*it).first]->maxDuration; 00334 unsigned int actDur = myPhases[(*it).first]->duration; 00335 if (actDur >= maxDur) { 00336 continue; 00337 } 00338 if ((*it).second > MaxValue) { 00339 MaxValue = (*it).second; 00340 StepOfMaxValue = (*it).first; 00341 } 00342 } 00343 return StepOfMaxValue; 00344 }
| unsigned int MSAgentbasedTrafficLightLogic::findStepOfMinValue | ( | ) | const throw () [protected] |
Returns the step of the phase with the shortest Queue_Lengt_Ahead_Of_Traffic_Lights.
Definition at line 348 of file MSAgentbasedTrafficLightLogic.cpp.
References myMeanDetectorData, MSSimpleTrafficLightLogic::myPhases, and SUMOReal.
Referenced by calculateDuration().
00348 { 00349 unsigned int StepOfMinValue = (unsigned int) myPhases.size(); 00350 SUMOReal MinValue = 9999; 00351 for (MeanDataMap::const_iterator it = myMeanDetectorData.begin(); it!=myMeanDetectorData.end(); it++) { 00352 // checks whether the actual duruation is longer than minduration 00353 // otherwise the phase can't be cut 00354 unsigned int minDur = myPhases[(*it).first]->minDuration; 00355 unsigned int actDur = myPhases[(*it).first]->duration; 00356 if (actDur <= minDur) { 00357 continue; 00358 } 00359 if ((*it).second < MinValue) { 00360 MinValue = (*it).second; 00361 StepOfMinValue = (*it).first; 00362 } 00363 } 00364 return StepOfMinValue; 00365 }
| const MSPhaseDefinition & MSSimpleTrafficLightLogic::getCurrentPhaseDef | ( | ) | const throw () [virtual, inherited] |
Returns the definition of the current phase.
Implements MSTrafficLightLogic.
Definition at line 159 of file MSSimpleTrafficLightLogic.cpp.
References MSSimpleTrafficLightLogic::myPhases, and MSSimpleTrafficLightLogic::myStep.
Referenced by collectData(), MSActuatedTrafficLightLogic::duration(), MSActuatedTrafficLightLogic::gapControl(), and trySwitch().
| unsigned int MSSimpleTrafficLightLogic::getCurrentPhaseIndex | ( | ) | const throw () [virtual, inherited] |
Returns the current index within the program.
Implements MSTrafficLightLogic.
Definition at line 153 of file MSSimpleTrafficLightLogic.cpp.
References MSSimpleTrafficLightLogic::myStep.
00153 { 00154 return myStep; 00155 }
| unsigned int MSTrafficLightLogic::getDefaultCycleTime | ( | ) | const throw () [inline, inherited] |
Returns the cycle time.
Definition at line 261 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myDefaultCycleTime.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::adaptLogic(), MSTLLogicControl::WAUTSwitchProcedure_GSP::adaptLogic(), and MSTLLogicControl::WAUTSwitchProcedure::isPosAtGSP().
00261 { 00262 return myDefaultCycleTime; 00263 }
| const std::string& MSTrafficLightLogic::getID | ( | ) | const throw () [inline, inherited] |
Returns this tl-logic's id.
Definition at line 168 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myID.
Referenced by GUITrafficLightLogicWrapper::begin2TrackPhases(), MSTrafficLightLogic::SwitchCommand::execute(), Command_SaveTLSSwitchStates::execute(), Command_SaveTLSSwitches::execute(), Command_SaveTLSState::execute(), MSTLLogicControl::TLSLogicVariants::getLogicInstantiatingOff(), GUITrafficLightLogicWrapper::getMicrosimID(), GUITrafficLightLogicWrapper::getPopUpMenu(), traci::TraCIServer::handleTrafficLightDomain(), GUINet::initTLMap(), MSTLLogicControl::isActive(), GUIViewTraffic::onGamingClick(), and GUITrafficLightLogicWrapper::switchTLSLogic().
00168 { 00169 return myID; 00170 }
| unsigned int MSSimpleTrafficLightLogic::getIndexFromOffset | ( | unsigned int | offset | ) | const throw () [virtual, inherited] |
Returns the step (the phasenumber) of a given position of the cycle.
| [in] | offset | The offset (time) for which the according phase shall be returned |
Implements MSTrafficLightLogic.
Definition at line 195 of file MSSimpleTrafficLightLogic.cpp.
References MSPhaseDefinition::duration, MSSimpleTrafficLightLogic::getPhase(), MSTrafficLightLogic::myDefaultCycleTime, and MSSimpleTrafficLightLogic::myPhases.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_GSP::adaptLogic(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::cutLogic(), MSTLLogicControl::WAUTSwitchProcedure::getDiffToStartOfPhase(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic(), and MSTLLogicControl::WAUTSwitchProcedure::switchToPos().
00195 { 00196 assert(offset <= myDefaultCycleTime); 00197 if (offset == myDefaultCycleTime) { 00198 return 0; 00199 } 00200 unsigned int pos = offset; 00201 unsigned int testPos = 0; 00202 for (unsigned int i=0; i < myPhases.size(); i++) { 00203 testPos = testPos + getPhase(i).duration; 00204 if (testPos > pos) { 00205 return i; 00206 } 00207 if (testPos == pos) { 00208 assert(myPhases.size() > (i+1)); 00209 return (i+1); 00210 } 00211 } 00212 return 0; 00213 }
| const LaneVectorVector& MSTrafficLightLogic::getLanes | ( | ) | const throw () [inline, inherited] |
Returns the list of lists of all lanes controlled by this tls.
Definition at line 184 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLanes.
Referenced by GUITrafficLightLogicWrapper::getCenteringBoundary(), and TraCIServerAPI_TLS::processGet().
00184 { 00185 return myLanes; 00186 }
| const LaneVector& MSTrafficLightLogic::getLanesAt | ( | unsigned int | i | ) | const throw () [inline, inherited] |
Returns the list of lanes that are controlled by the signals at the given position.
| [in] | i | The index of the signal |
Definition at line 193 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLanes.
Referenced by collectData(), traci::TraCIServer::commandGetTLStatus(), MSUnboundActuatedTrafficLightLogic::duration(), MSActuatedTrafficLightLogic::duration(), Command_SaveTLSSwitches::execute(), MSUnboundActuatedTrafficLightLogic::gapControl(), MSActuatedTrafficLightLogic::gapControl(), traci::TraCIServer::handleTrafficLightDomain(), and GUIViewTraffic::onGamingClick().
00193 { 00194 return myLanes[i]; 00195 }
| int MSTrafficLightLogic::getLinkIndex | ( | const MSLink *const | link | ) | const throw () [inherited] |
Returns the index of the given link.
| [in] | link | The link to retrieve the index for |
Definition at line 174 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLinks.
Referenced by GUITrafficLightLogicWrapper::getLinkIndex().
00174 { 00175 int index = 0; 00176 for (LinkVectorVector::const_iterator i1=myLinks.begin(); i1!=myLinks.end(); ++i1, ++index) { 00177 const LinkVector &l = (*i1); 00178 for (LinkVector::const_iterator i2=l.begin(); i2!=l.end(); ++i2) { 00179 if ((*i2)==link) { 00180 return index; 00181 } 00182 } 00183 } 00184 return -1; 00185 }
| const LinkVectorVector& MSTrafficLightLogic::getLinks | ( | ) | const throw () [inline, inherited] |
Returns the list of lists of all affected links.
Definition at line 201 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLinks.
Referenced by traci::TraCIServer::commandGetTLStatus(), GUITLLogicPhasesTrackerWindow::drawValues(), Command_SaveTLSSwitches::execute(), FXIMPLEMENT(), GUITLLogicPhasesTrackerWindow::GUITLLogicPhasesTrackerWindow(), traci::TraCIServer::handleTrafficLightDomain(), GUINet::initTLMap(), TraCIServerAPI_TLS::processGet(), and MSOffTrafficLightLogic::rebuildPhase().
00201 { 00202 return myLinks; 00203 }
| const LinkVector& MSTrafficLightLogic::getLinksAt | ( | unsigned int | i | ) | const throw () [inline, inherited] |
Returns the list of links that are controlled by the signals at the given position.
| [in] | i | The index of the signal |
Definition at line 210 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::myLinks.
00210 { 00211 return myLinks[i]; 00212 }
| SUMOTime MSTrafficLightLogic::getNextSwitchTime | ( | ) | const throw () [inherited] |
Returns the assumed next switch time.
The time may change in case of adaptive/actuated traffic lights.
Definition at line 191 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::SwitchCommand::getNextSwitchTime(), and MSTrafficLightLogic::mySwitchCommand.
Referenced by TraCIServerAPI_TLS::processGet().
00191 { 00192 return mySwitchCommand!=0 ? mySwitchCommand->getNextSwitchTime() : -1; 00193 }
| unsigned int MSSimpleTrafficLightLogic::getOffsetFromIndex | ( | unsigned int | index | ) | const throw () [virtual, inherited] |
Returns the position (start of a phase during a cycle) from of a given step.
| [in] | index | The index of the phase to return the begin of |
Implements MSTrafficLightLogic.
Definition at line 181 of file MSSimpleTrafficLightLogic.cpp.
References MSPhaseDefinition::duration, MSSimpleTrafficLightLogic::getPhase(), and MSSimpleTrafficLightLogic::myPhases.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::cutLogic(), MSTLLogicControl::WAUTSwitchProcedure::getDiffToStartOfPhase(), and MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic().
00181 { 00182 assert(index < myPhases.size()); 00183 if (index == 0) { 00184 return 0; 00185 } 00186 unsigned int pos = 0; 00187 for (unsigned int i=0; i < index; i++) { 00188 pos += getPhase(i).duration; 00189 } 00190 return pos; 00191 }
| std::string MSTrafficLightLogic::getParameterValue | ( | const std::string & | key | ) | const throw () [inherited] |
Returns a named parameter.
| [in] | key | The name of the parameter |
Definition at line 219 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myParameter.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::adaptLogic(), MSTLLogicControl::WAUTSwitchProcedure::getGSPValue(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::getStretchBereichDef(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::getStretchBereicheNo(), and MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic().
00219 { 00220 if (myParameter.find(key)==myParameter.end()) { 00221 return ""; 00222 } 00223 return myParameter.find(key)->second; 00224 }
| const MSPhaseDefinition & MSSimpleTrafficLightLogic::getPhase | ( | unsigned int | givenstep | ) | const throw () [virtual, inherited] |
Returns the definition of the phase from the given position within the plan.
| [in] | givenstep | The index of the phase within the plan |
Implements MSTrafficLightLogic.
Definition at line 145 of file MSSimpleTrafficLightLogic.cpp.
References MSSimpleTrafficLightLogic::myPhases.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_GSP::adaptLogic(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::cutLogic(), MSTLLogicControl::WAUTSwitchProcedure::getDiffToStartOfPhase(), MSSimpleTrafficLightLogic::getIndexFromOffset(), MSSimpleTrafficLightLogic::getOffsetFromIndex(), MSSimpleTrafficLightLogic::getPhaseIndexAtTime(), GUIViewTraffic::onGamingClick(), MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic(), and MSTLLogicControl::WAUTSwitchProcedure::switchToPos().
| unsigned int MSSimpleTrafficLightLogic::getPhaseIndexAtTime | ( | SUMOTime | simStep | ) | const throw () [virtual, inherited] |
Returns the index of the logic at the given simulation step.
Implements MSTrafficLightLogic.
Definition at line 166 of file MSSimpleTrafficLightLogic.cpp.
References MSPhaseDefinition::duration, MSSimpleTrafficLightLogic::getPhase(), MSTrafficLightLogic::myDefaultCycleTime, MSPhaseDefinition::myLastSwitch, and MSSimpleTrafficLightLogic::myStep.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::adaptLogic(), and MSTLLogicControl::WAUTSwitchProcedure_GSP::adaptLogic().
00166 { 00167 unsigned int position = 0; 00168 if (myStep > 0) { 00169 for (unsigned int i=0; i < myStep; i++) { 00170 position = position + getPhase(i).duration; 00171 } 00172 } 00173 position = position + simStep - getPhase(myStep).myLastSwitch; 00174 position = position % myDefaultCycleTime; 00175 assert(position <= myDefaultCycleTime); 00176 return position; 00177 }
| unsigned int MSSimpleTrafficLightLogic::getPhaseNumber | ( | ) | const throw () [virtual, inherited] |
Returns the number of phases.
Implements MSTrafficLightLogic.
Definition at line 127 of file MSSimpleTrafficLightLogic.cpp.
References MSSimpleTrafficLightLogic::myPhases.
00127 { 00128 return (unsigned int) myPhases.size(); 00129 }
| MSSimpleTrafficLightLogic::Phases & MSSimpleTrafficLightLogic::getPhases | ( | ) | throw () [inherited] |
Returns the phases of this tls program.
Definition at line 139 of file MSSimpleTrafficLightLogic.cpp.
References MSSimpleTrafficLightLogic::myPhases.
00139 { 00140 return myPhases; 00141 }
| const MSSimpleTrafficLightLogic::Phases & MSSimpleTrafficLightLogic::getPhases | ( | ) | const throw () [virtual, inherited] |
Returns the phases of this tls program.
Implements MSTrafficLightLogic.
Definition at line 133 of file MSSimpleTrafficLightLogic.cpp.
References MSSimpleTrafficLightLogic::myPhases.
Referenced by MSTLLogicControl::WAUTSwitchProcedure_Stretch::cutLogic(), and MSTLLogicControl::WAUTSwitchProcedure_Stretch::stretchLogic().
00133 { 00134 return myPhases; 00135 }
| const std::string& MSTrafficLightLogic::getSubID | ( | ) | const throw () [inline, inherited] |
Returns this tl-logic's id.
Definition at line 176 of file MSTrafficLightLogic.h.
References MSTrafficLightLogic::mySubID.
Referenced by Command_SaveTLSSwitchStates::execute(), Command_SaveTLSSwitches::execute(), Command_SaveTLSState::execute(), GUIViewTraffic::onGamingClick(), and TraCIServerAPI_TLS::processGet().
00176 { 00177 return mySubID; 00178 }
| void MSAgentbasedTrafficLightLogic::init | ( | NLDetectorBuilder & | nb | ) | throw (ProcessError) [virtual] |
Initialises the tls with information about incoming lanes.
| [in] | nb | The detector builder |
| [in] | edgeContinuations | Information about edge predecessors/successors |
| ProcessError | If something fails on initialisation |
Calculation of starting values
Reimplemented from MSTrafficLightLogic.
Definition at line 60 of file MSAgentbasedTrafficLightLogic.cpp.
References TplConvert< E >::_2SUMOReal(), DU_TL_CONTROL, MSLane::getID(), and SUMOReal.
00060 { 00061 SUMOReal det_offset = TplConvert<char>::_2SUMOReal(myParameter.find("detector_offset")->second.c_str()); 00062 LaneVectorVector::const_iterator i2; 00063 LaneVector::const_iterator i; 00064 // build the detectors 00065 for (i2=myLanes.begin(); i2!=myLanes.end(); ++i2) { 00066 const LaneVector &lanes = *i2; 00067 for (i=lanes.begin(); i!=lanes.end(); i++) { 00068 MSLane *lane = (*i); 00069 // Build the lane state detetcor and set it into the container 00070 std::string id = "TL_" + myID + "_" + mySubID + "_E2OverLanesDetectorStartingAt_" + lane->getID(); 00071 00072 if (myE2Detectors.find(lane)==myE2Detectors.end()) { 00073 MS_E2_ZS_CollectorOverLanes* det = 00074 nb.buildMultiLaneE2Det(id, 00075 DU_TL_CONTROL, lane, 0, det_offset, 00076 /*haltingTimeThreshold!!!*/ 1, 00077 /*haltingSpeedThreshold!!!*/(SUMOReal)(5.0/3.6), 00078 /*jamDistThreshold!!!*/ 10); 00079 myE2Detectors[lane] = det; 00080 } 00081 } 00082 } 00083 00084 00085 // initialise the duration 00086 unsigned int tCycleIst = 0; // the actual cycletime 00087 unsigned int tCycleMin = 0; // the minimum cycle time 00088 unsigned int tDeltaGreen = 0; // the difference between the actual cycle time and the required cycle time 00089 00091 for (unsigned int actStep = 0; actStep!=myPhases.size(); actStep++) { 00092 unsigned int dur = myPhases[actStep]->duration; 00093 tCycleIst = tCycleIst + dur; 00094 if (myPhases[actStep]->isGreenPhase()) { 00095 unsigned int mindur = myPhases[actStep]->minDuration; 00096 tCycleMin = tCycleMin + mindur; 00097 } else { 00098 tCycleMin = tCycleMin + dur; 00099 } 00100 } 00101 if (tCycle < tCycleMin) { 00102 tCycle = tCycleMin; 00103 } 00104 if (tCycleIst < tCycle) { 00105 tDeltaGreen = tCycle - tCycleIst; 00106 lengthenCycleTime(tDeltaGreen); 00107 } 00108 if (tCycleIst > tCycle) { 00109 tDeltaGreen = tCycleIst - tCycle; 00110 cutCycleTime(tDeltaGreen); 00111 } 00112 }
| void MSAgentbasedTrafficLightLogic::lengthenCycleTime | ( | unsigned int | toLenghten | ) | throw () [protected] |
lenghtens the actual cycle by an given value
| [in] | toLenghten | The time increase |
Definition at line 249 of file MSAgentbasedTrafficLightLogic.cpp.
References MSSimpleTrafficLightLogic::myPhases, and SUMOReal.
00249 { 00250 typedef std::pair <unsigned int, unsigned int> contentType; 00251 typedef std::vector< std::pair <unsigned int, unsigned int> > GreenPhasesVector; 00252 GreenPhasesVector tmp_phases(myPhases.size()); 00253 tmp_phases.clear(); 00254 unsigned int maxLengthen = 0; // the sum of all times, that is possible to lengthen 00255 00256 /* fills the vector tmp_phases with the difference between 00257 duration and maxduration and the myStep of the phases. 00258 only phases with duration < maxDuration are written in the vector. 00259 sorts the vector after the difference. */ 00260 for (unsigned int i_Step = 0; i_Step!=myPhases.size(); i_Step++) { 00261 if (myPhases[i_Step]->isGreenPhase()) { 00262 unsigned int dur = myPhases[i_Step]->duration; 00263 unsigned int maxdur = myPhases[i_Step]->maxDuration; 00264 if (dur < maxdur) { 00265 contentType tmp; 00266 tmp.second = i_Step; 00267 tmp.first = maxdur - dur; 00268 tmp_phases.push_back(tmp); 00269 maxLengthen = maxLengthen + tmp.first; 00270 } 00271 } 00272 } 00273 sort(tmp_phases.begin(), tmp_phases.end()); 00274 //lengthens the phases acording to the difference between duration and maxDuration 00275 for (GreenPhasesVector::iterator i=tmp_phases.begin(); i!=tmp_phases.end(); i++) { 00276 SUMOTime toLengthenPerPhase = 0; 00277 SUMOReal tmpdb = ((*i).first * toLengthen / SUMOReal(maxLengthen)) + (SUMOReal) 0.5; 00278 toLengthenPerPhase = static_cast<SUMOTime>(tmpdb); 00279 toLengthen = toLengthen - toLengthenPerPhase; 00280 maxLengthen = maxLengthen - (*i).first; 00281 SUMOTime newDur = myPhases[(*i).second]->duration + toLengthenPerPhase; 00282 myPhases[(*i).second]->duration = newDur; 00283 } 00284 }
| unsigned int MSAgentbasedTrafficLightLogic::nextStep | ( | ) | throw () [protected] |
Returns the index of the phase next to the given phase.
Stores the duration of the phase, which was just sent or stores the activation-time in myLastphase of the phase next
Definition at line 144 of file MSAgentbasedTrafficLightLogic.cpp.
References MSSimpleTrafficLightLogic::myPhases, MSSimpleTrafficLightLogic::myStep, stepOfLastDecision, and tSinceLastDecision.
Referenced by trySwitch().
00144 { 00145 // increment the index to the current phase 00146 myStep++; 00147 assert(myStep<=myPhases.size()); 00148 if (myStep==myPhases.size()) { 00149 myStep = 0; 00150 } 00151 // increment the number of cycles since last decision 00152 if (myStep == stepOfLastDecision) { 00153 tSinceLastDecision = tSinceLastDecision +1; 00154 } 00155 return myStep; 00156 }
| void MSTrafficLightLogic::resetLinkStates | ( | const std::map< MSLink *, std::pair< MSLink::LinkState, bool > > & | vals | ) | const throw () [inherited] |
Resets the states of controlled links.
| [in] | The | state of controlled links to use |
Definition at line 159 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLinks.
Referenced by MSTLLogicControl::TLSLogicVariants::switchTo().
00159 { 00160 for (LinkVectorVector::const_iterator i1=myLinks.begin(); i1!=myLinks.end(); ++i1) { 00161 const LinkVector &l = (*i1); 00162 for (LinkVector::const_iterator i2=l.begin(); i2!=l.end(); ++i2) { 00163 assert(vals.find(*i2)!=vals.end()); 00164 const std::pair<MSLink::LinkState, bool> &lvals = vals.find(*i2)->second; 00165 (*i2)->setTLState(lvals.first); 00166 (*i2)->setPriority(lvals.second); 00167 } 00168 } 00169 }
| void MSTrafficLightLogic::setCurrentDurationIncrement | ( | SUMOTime | delay | ) | throw () [inherited] |
Delays current phase by the given delay.
| [in] | delay | The time by which the current phase shall be delayed |
Definition at line 204 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myCurrentDurationIncrement.
00204 { 00205 myCurrentDurationIncrement = delay; 00206 }
| void MSSimpleTrafficLightLogic::setLinkPriorities | ( | ) | const throw () [virtual, inherited] |
Applies the priorities resulting from the current phase to controlled links.
Implements MSTrafficLightLogic.
Definition at line 97 of file MSSimpleTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLinks, MSSimpleTrafficLightLogic::myPhases, and MSSimpleTrafficLightLogic::myStep.
00097 { 00098 const std::string &state = myPhases[myStep]->getState(); 00099 for (size_t i=0; i<myLinks.size(); i++) { 00100 bool hasPriority = (state[i]>='A'&&state[i]<='Z'); 00101 const LinkVector &currGroup = myLinks[i]; 00102 for (LinkVector::const_iterator j=currGroup.begin(); j!=currGroup.end(); j++) { 00103 (*j)->setPriority(hasPriority); 00104 } 00105 } 00106 }
| void MSTrafficLightLogic::setParameter | ( | const std::map< std::string, std::string > & | params | ) | throw () [inherited] |
Inserts read parameter.
| [in] | params | The parameter to use |
Definition at line 213 of file MSTrafficLightLogic.cpp.
References MSTrafficLightLogic::myParameter.
Referenced by NLJunctionControlBuilder::closeTrafficLightLogic().
00213 { 00214 myParameter = params; 00215 }
| bool MSSimpleTrafficLightLogic::setTrafficLightSignals | ( | ) | const throw () [virtual, inherited] |
Clears all incoming vehicle information on links that have red.
Implements MSTrafficLightLogic.
Definition at line 110 of file MSSimpleTrafficLightLogic.cpp.
References MSTrafficLightLogic::myLinks, MSSimpleTrafficLightLogic::myPhases, and MSSimpleTrafficLightLogic::myStep.
00110 { 00111 // get the current traffic light signal combination 00112 const std::string &state = myPhases[myStep]->getState(); 00113 // go through the links 00114 for (size_t i=0; i<myLinks.size(); i++) { 00115 const LinkVector &currGroup = myLinks[i]; 00116 MSLink::LinkState ls = (MSLink::LinkState) state[i]; 00117 for (LinkVector::const_iterator j=currGroup.begin(); j!=currGroup.end(); j++) { 00118 (*j)->setTLState(ls); 00119 } 00120 } 00121 return true; 00122 }
Switches to the next phase.
| [in] | isActive | Whether this program is the currently used one |
Reimplemented from MSSimpleTrafficLightLogic.
Definition at line 120 of file MSAgentbasedTrafficLightLogic.cpp.
References calculateDuration(), collectData(), MSPhaseDefinition::duration, MSSimpleTrafficLightLogic::getCurrentPhaseDef(), MSSimpleTrafficLightLogic::myPhases, MSSimpleTrafficLightLogic::myStep, nextStep(), tDecide, and tSinceLastDecision.
00120 { 00121 assert(getCurrentPhaseDef().minDuration >=0); 00122 assert(getCurrentPhaseDef().minDuration <= getCurrentPhaseDef().duration); 00123 if (myPhases[myStep]->isGreenPhase()) { 00124 // collects the data for the signal control 00125 collectData(); 00126 // decides wheter greentime shall distributed between phases 00127 if (tDecide <= tSinceLastDecision) { 00128 calculateDuration(); 00129 } 00130 } 00131 // increment the index to the current phase 00132 nextStep(); 00133 // set the next event 00134 while (getCurrentPhaseDef().duration==0) { 00135 nextStep(); 00136 } 00137 assert(myPhases.size()>myStep); 00138 return getCurrentPhaseDef().duration; 00139 }
SUMOReal MSAgentbasedTrafficLightLogic::deltaLimit [protected] |
SUMOTime MSTrafficLightLogic::myCurrentDurationIncrement [protected, inherited] |
A value for enlarge the current duration.
Definition at line 427 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::setCurrentDurationIncrement(), and MSSimpleTrafficLightLogic::trySwitch().
unsigned int MSTrafficLightLogic::myDefaultCycleTime [protected, inherited] |
The cycle time (without changes).
Definition at line 433 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getDefaultCycleTime(), MSSimpleTrafficLightLogic::getIndexFromOffset(), and MSSimpleTrafficLightLogic::getPhaseIndexAtTime().
A map from lanes to E2-detectors lying on them.
Definition at line 173 of file MSAgentbasedTrafficLightLogic.h.
std::string MSTrafficLightLogic::myID [protected, inherited] |
The id of the logic.
Definition at line 415 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getID().
LaneVectorVector MSTrafficLightLogic::myLanes [protected, inherited] |
The list of links which do participate in this traffic light.
Definition at line 421 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::adaptLinkInformationFrom(), MSTrafficLightLogic::addLink(), MSTrafficLightLogic::getLanes(), and MSTrafficLightLogic::getLanesAt().
LinkVectorVector MSTrafficLightLogic::myLinks [protected, inherited] |
The list of links which do participate in this traffic light.
Definition at line 418 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::adaptLinkInformationFrom(), MSTrafficLightLogic::addLink(), MSTrafficLightLogic::collectLinkStates(), MSTrafficLightLogic::getLinkIndex(), MSTrafficLightLogic::getLinks(), MSTrafficLightLogic::getLinksAt(), MSTrafficLightLogic::resetLinkStates(), MSSimpleTrafficLightLogic::setLinkPriorities(), and MSSimpleTrafficLightLogic::setTrafficLightSignals().
A map of the step of the greenphases and their aggregated detectordata.
Definition at line 179 of file MSAgentbasedTrafficLightLogic.h.
Referenced by aggregateRawData(), calculateDuration(), findStepOfMaxValue(), and findStepOfMinValue().
std::vector<SUMOTime> MSTrafficLightLogic::myOverridingTimes [protected, inherited] |
A list of duration overrides.
Definition at line 424 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::addOverridingDuration(), and MSSimpleTrafficLightLogic::trySwitch().
std::map<std::string, std::string> MSTrafficLightLogic::myParameter [protected, inherited] |
Given parameter.
Definition at line 412 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getParameterValue(), and MSTrafficLightLogic::setParameter().
Phases MSSimpleTrafficLightLogic::myPhases [protected, inherited] |
The list of phases this logic uses.
Definition at line 198 of file MSSimpleTrafficLightLogic.h.
Referenced by calculateDuration(), MSUnboundActuatedTrafficLightLogic::currentPhaseDef(), cutCycleTime(), MSUnboundActuatedTrafficLightLogic::duration(), MSActuatedTrafficLightLogic::duration(), findStepOfMaxValue(), findStepOfMinValue(), MSUnboundActuatedTrafficLightLogic::gapControl(), MSActuatedTrafficLightLogic::gapControl(), MSSimpleTrafficLightLogic::getCurrentPhaseDef(), MSSimpleTrafficLightLogic::getIndexFromOffset(), MSSimpleTrafficLightLogic::getOffsetFromIndex(), MSSimpleTrafficLightLogic::getPhase(), MSSimpleTrafficLightLogic::getPhaseNumber(), MSSimpleTrafficLightLogic::getPhases(), lengthenCycleTime(), nextStep(), MSSimpleTrafficLightLogic::setLinkPriorities(), MSSimpleTrafficLightLogic::setTrafficLightSignals(), MSUnboundActuatedTrafficLightLogic::trySwitch(), MSSimpleTrafficLightLogic::trySwitch(), trySwitch(), MSActuatedTrafficLightLogic::trySwitch(), and MSSimpleTrafficLightLogic::~MSSimpleTrafficLightLogic().
A map of the step of the greenphases and their detectorvalues for several (mumberofValues) cycles.
Definition at line 176 of file MSAgentbasedTrafficLightLogic.h.
Referenced by aggregateRawData(), and collectData().
unsigned int MSSimpleTrafficLightLogic::myStep [protected, inherited] |
The current step.
Definition at line 201 of file MSSimpleTrafficLightLogic.h.
Referenced by calculateDuration(), MSSimpleTrafficLightLogic::changeStepAndDuration(), collectData(), MSUnboundActuatedTrafficLightLogic::currentPhaseDef(), MSUnboundActuatedTrafficLightLogic::duration(), MSActuatedTrafficLightLogic::duration(), MSUnboundActuatedTrafficLightLogic::gapControl(), MSActuatedTrafficLightLogic::gapControl(), MSSimpleTrafficLightLogic::getCurrentPhaseDef(), MSSimpleTrafficLightLogic::getCurrentPhaseIndex(), MSSimpleTrafficLightLogic::getPhaseIndexAtTime(), nextStep(), MSSimpleTrafficLightLogic::setLinkPriorities(), MSSimpleTrafficLightLogic::setTrafficLightSignals(), MSUnboundActuatedTrafficLightLogic::trySwitch(), MSSimpleTrafficLightLogic::trySwitch(), trySwitch(), and MSActuatedTrafficLightLogic::trySwitch().
std::string MSTrafficLightLogic::mySubID [protected, inherited] |
Definition at line 415 of file MSTrafficLightLogic.h.
Referenced by MSTrafficLightLogic::getSubID().
SwitchCommand* MSTrafficLightLogic::mySwitchCommand [protected, inherited] |
The current switch command.
Definition at line 430 of file MSTrafficLightLogic.h.
Referenced by MSSimpleTrafficLightLogic::changeStepAndDuration(), MSTrafficLightLogic::getNextSwitchTime(), MSTrafficLightLogic::MSTrafficLightLogic(), and MSTrafficLightLogic::~MSTrafficLightLogic().
unsigned int MSAgentbasedTrafficLightLogic::numberOfValues [protected] |
The number of detector values whivh is considered to make a decision.
it's only possible to get one value per cycle per greenphase
Definition at line 195 of file MSAgentbasedTrafficLightLogic.h.
Referenced by collectData().
unsigned int MSAgentbasedTrafficLightLogic::stepOfLastDecision [protected] |
Stores the step of the phase, when the last decision was made.
Definition at line 190 of file MSAgentbasedTrafficLightLogic.h.
Referenced by calculateDuration(), and nextStep().
unsigned int MSAgentbasedTrafficLightLogic::tCycle [protected] |
unsigned int MSAgentbasedTrafficLightLogic::tDecide [protected] |
the interval in which the traffic light can make a decision
The interval is given in integer numbers of cycles
Definition at line 184 of file MSAgentbasedTrafficLightLogic.h.
Referenced by trySwitch().
unsigned int MSAgentbasedTrafficLightLogic::tSinceLastDecision [protected] |
The number of cycles, before the last decision was made.
Definition at line 187 of file MSAgentbasedTrafficLightLogic.h.
Referenced by calculateDuration(), nextStep(), and trySwitch().
1.5.6