SUMO - Simulation of Urban MObility
MSAgentbasedTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // An agentbased traffic light logic
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2003-2014 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 #ifndef MSAgentbasedTrafficLightLogic_h
24 #define MSAgentbasedTrafficLightLogic_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <utility>
37 #include <vector>
38 #include <bitset>
39 #include <map>
40 #include "MSTrafficLightLogic.h"
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class MSLane;
49 class MSAgentbasedPhaseDefinition;
50 class NLDetectorBuilder;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
62 public:
64  typedef std::map<MSLane*, MS_E2_ZS_CollectorOverLanes*> E2DetectorMap;
65 
67  typedef std::deque<SUMOReal> ValueType;
68 
70  typedef std::map<unsigned int, ValueType> PhaseValueMap;
71 
73  typedef std::map<unsigned int, SUMOReal> MeanDataMap;
74 
75 public:
86  const std::string& id, const std::string& programID,
88  unsigned int step, SUMOTime delay,
89  const std::map<std::string, std::string>& parameter);
90 
91 
97  void init(NLDetectorBuilder& nb);
98 
99 
102 
103 
104 
107 
113  SUMOTime trySwitch(bool isActive);
115 
116 
117 protected:
120 
127  unsigned int nextStep();
128 
129 
132  void collectData();
133 
134 
137  void aggregateRawData();
138 
139 
142  void calculateDuration();
143 
144 
148  void lengthenCycleTime(unsigned int toLenghten);
149 
150 
154  void cutCycleTime(unsigned int toCut);
155 
156 
160  unsigned int findStepOfMaxValue() const;
161 
162 
166  unsigned int findStepOfMinValue() const;
168 
169 
170 protected:
172  E2DetectorMap myE2Detectors;
173 
175  PhaseValueMap myRawDetectorData;
176 
178  MeanDataMap myMeanDetectorData;
179 
183  unsigned int tDecide;
184 
186  unsigned int tSinceLastDecision;
187 
189  unsigned int stepOfLastDecision;
190 
194  unsigned int numberOfValues;
195 
197  unsigned int tCycle;
198 
199  /* @brief The minimum difference between the shortest and the longest que
200  *
201  * Queue_Lengt_Ahead_Of_Traffic_Lights of a phase before greentime is given
202  * from the phase with the shortest Queue_Lengt_Ahead_Of_Traffic_Lights to the phase with
203  * the longest Queue_Lengt_Ahead_Of_Traffic_Lights */
205 
206 };
207 
208 
209 #endif
210 
211 /****************************************************************************/
212 
void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
PhaseValueMap myRawDetectorData
A map of the step of the greenphases and their detectorvalues for several (mumberofValues) cycles...
unsigned int numberOfValues
The number of detector values whivh is considered to make a decision.
An agentbased traffic light logic.
Builds detectors for microsim.
void lengthenCycleTime(unsigned int toLenghten)
lenghtens the actual cycle by an given value
void calculateDuration()
Calculates the duration for all real phases except intergreen phases.
std::deque< SUMOReal > ValueType
Definition of a map which stores the detector values of one single phase.
unsigned int nextStep()
Returns the index of the phase next to the given phase.
MSAgentbasedTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const MSSimpleTrafficLightLogic::Phases &phases, unsigned int step, SUMOTime delay, const std::map< std::string, std::string > &parameter)
Constructor.
A fixed traffic light logic.
A class that stores and controls tls and switching of their programs.
unsigned int findStepOfMaxValue() const
Returns the step of the phase with the longest Queue_Lengt_Ahead_Of_Traffic_Lights.
unsigned int tCycle
The cycletime of the trafficlight.
void aggregateRawData()
Aggregates the data of one phase, collected during different cycles.
MeanDataMap myMeanDetectorData
A map of the step of the greenphases and their aggregated detectordata.
std::map< unsigned int, SUMOReal > MeanDataMap
Definition of a map which stores the mean data of several (numberOfValues) cycles.
unsigned int tDecide
the interval in which the traffic light can make a decision
SUMOTime trySwitch(bool isActive)
Switches to the next phase.
void collectData()
Collects the traffic data.
unsigned int tSinceLastDecision
The number of cycles, before the last decision was made.
E2DetectorMap myE2Detectors
A map from lanes to E2 detectors lying on them.
std::map< MSLane *, MS_E2_ZS_CollectorOverLanes * > E2DetectorMap
Definition of a map from lanes to lane state detectors lying on them.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
std::map< unsigned int, ValueType > PhaseValueMap
Definition of a map which stores the step of the greenphases and their detector values.
void cutCycleTime(unsigned int toCut)
cuts the actual cycle by an given value
#define SUMOReal
Definition: config.h:215
unsigned int findStepOfMinValue() const
Returns the step of the phase with the shortest Queue_Lengt_Ahead_Of_Traffic_Lights.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
unsigned int stepOfLastDecision
Stores the step of the phase, when the last decision was made.