SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // An agentbased traffic light logic 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 #ifndef MSAgentbasedTrafficLightLogic_h 00023 #define MSAgentbasedTrafficLightLogic_h 00024 00025 00026 // =========================================================================== 00027 // included modules 00028 // =========================================================================== 00029 #ifdef _MSC_VER 00030 #include <windows_config.h> 00031 #else 00032 #include <config.h> 00033 #endif 00034 00035 #include <utility> 00036 #include <vector> 00037 #include <bitset> 00038 #include <map> 00039 #include "MSTrafficLightLogic.h" 00040 #include "MSSimpleTrafficLightLogic.h" 00041 #include <microsim/output/MS_E2_ZS_CollectorOverLanes.h> 00042 #include "MSSimpleTrafficLightLogic.h" 00043 00044 00045 // =========================================================================== 00046 // class declarations 00047 // =========================================================================== 00048 class MSLane; 00049 class MSAgentbasedPhaseDefinition; 00050 class NLDetectorBuilder; 00051 00052 00053 // =========================================================================== 00054 // class definitions 00055 // =========================================================================== 00060 class MSAgentbasedTrafficLightLogic : 00061 public MSSimpleTrafficLightLogic { 00062 public: 00064 typedef std::map<MSLane*, MS_E2_ZS_CollectorOverLanes*> E2DetectorMap; 00065 00067 typedef std::deque<SUMOReal> ValueType; 00068 00070 typedef std::map<unsigned int, ValueType> PhaseValueMap; 00071 00073 typedef std::map<unsigned int, SUMOReal> MeanDataMap; 00074 00075 public: 00085 MSAgentbasedTrafficLightLogic(MSTLLogicControl& tlcontrol, 00086 const std::string& id, const std::string& programID, 00087 const MSSimpleTrafficLightLogic::Phases& phases, 00088 unsigned int step, SUMOTime delay, 00089 const std::map<std::string, std::string> ¶meter); 00090 00091 00097 void init(NLDetectorBuilder& nb); 00098 00099 00101 ~MSAgentbasedTrafficLightLogic(); 00102 00103 00104 00107 00113 SUMOTime trySwitch(bool isActive); 00115 00116 00117 protected: 00120 00127 unsigned int nextStep(); 00128 00129 00132 void collectData(); 00133 00134 00137 void aggregateRawData(); 00138 00139 00142 void calculateDuration(); 00143 00144 00148 void lengthenCycleTime(unsigned int toLenghten); 00149 00150 00154 void cutCycleTime(unsigned int toCut); 00155 00156 00160 unsigned int findStepOfMaxValue() const; 00161 00162 00166 unsigned int findStepOfMinValue() const; 00168 00169 00170 protected: 00172 E2DetectorMap myE2Detectors; 00173 00175 PhaseValueMap myRawDetectorData; 00176 00178 MeanDataMap myMeanDetectorData; 00179 00183 unsigned int tDecide; 00184 00186 unsigned int tSinceLastDecision; 00187 00189 unsigned int stepOfLastDecision; 00190 00194 unsigned int numberOfValues; 00195 00197 unsigned int tCycle; 00198 00199 /* @brief The minimum difference between the shortest and the longest que 00200 * 00201 * Queue_Lengt_Ahead_Of_Traffic_Lights of a phase before greentime is given 00202 * from the phase with the shortest Queue_Lengt_Ahead_Of_Traffic_Lights to the phase with 00203 * the longest Queue_Lengt_Ahead_Of_Traffic_Lights */ 00204 SUMOReal deltaLimit; 00205 00206 }; 00207 00208 00209 #endif 00210 00211 /****************************************************************************/ 00212