SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSAgentbasedTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // An agentbased traffic light logic
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef MSAgentbasedTrafficLightLogic_h
23 #define MSAgentbasedTrafficLightLogic_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <utility>
36 #include <vector>
37 #include <bitset>
38 #include <map>
39 #include "MSTrafficLightLogic.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class MSLane;
48 class MSAgentbasedPhaseDefinition;
49 class NLDetectorBuilder;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
61 public:
63  typedef std::map<MSLane*, MS_E2_ZS_CollectorOverLanes*> E2DetectorMap;
64 
66  typedef std::deque<SUMOReal> ValueType;
67 
69  typedef std::map<unsigned int, ValueType> PhaseValueMap;
70 
72  typedef std::map<unsigned int, SUMOReal> MeanDataMap;
73 
74 public:
85  const std::string& id, const std::string& programID,
87  unsigned int step, SUMOTime delay,
88  const std::map<std::string, std::string>& parameter);
89 
90 
96  void init(NLDetectorBuilder& nb);
97 
98 
101 
102 
103 
106 
112  SUMOTime trySwitch(bool isActive);
114 
115 
116 protected:
119 
126  unsigned int nextStep();
127 
128 
131  void collectData();
132 
133 
136  void aggregateRawData();
137 
138 
141  void calculateDuration();
142 
143 
147  void lengthenCycleTime(unsigned int toLenghten);
148 
149 
153  void cutCycleTime(unsigned int toCut);
154 
155 
159  unsigned int findStepOfMaxValue() const;
160 
161 
165  unsigned int findStepOfMinValue() const;
167 
168 
169 protected:
172 
175 
178 
182  unsigned int tDecide;
183 
185  unsigned int tSinceLastDecision;
186 
188  unsigned int stepOfLastDecision;
189 
193  unsigned int numberOfValues;
194 
196  unsigned int tCycle;
197 
198  /* @brief The minimum difference between the shortest and the longest que
199  *
200  * Queue_Lengt_Ahead_Of_Traffic_Lights of a phase before greentime is given
201  * from the phase with the shortest Queue_Lengt_Ahead_Of_Traffic_Lights to the phase with
202  * the longest Queue_Lengt_Ahead_Of_Traffic_Lights */
204 
205 };
206 
207 
208 #endif
209 
210 /****************************************************************************/
211 
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.