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.sourceforge.net/
12 // Copyright (C) 2001-2012 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"
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