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-2013 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 ParameterMap& 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