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 /****************************************************************************/
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:
173 
176 
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