SUMO - Simulation of Urban MObility

MSAgentbasedTrafficLightLogic.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // An agentbased traffic light logic
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef MSAgentbasedTrafficLightLogic_h
00020 #define MSAgentbasedTrafficLightLogic_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <utility>
00033 #include <vector>
00034 #include <bitset>
00035 #include <map>
00036 #include "MSTrafficLightLogic.h"
00037 #include "MSSimpleTrafficLightLogic.h"
00038 #include <microsim/output/MS_E2_ZS_CollectorOverLanes.h>
00039 #include "MSSimpleTrafficLightLogic.h"
00040 
00041 
00042 // ===========================================================================
00043 // class declarations
00044 // ===========================================================================
00045 class MSLane;
00046 class MSAgentbasedPhaseDefinition;
00047 class NLDetectorBuilder;
00048 
00049 
00050 // ===========================================================================
00051 // class definitions
00052 // ===========================================================================
00057 class MSAgentbasedTrafficLightLogic :
00058     public MSSimpleTrafficLightLogic {
00059 public:
00061     typedef std::map<MSLane*, MS_E2_ZS_CollectorOverLanes*> E2DetectorMap;
00062 
00064     typedef std::deque<SUMOReal> ValueType;
00065 
00067     typedef std::map<unsigned int, ValueType> PhaseValueMap;
00068 
00070     typedef std::map<unsigned int, SUMOReal> MeanDataMap;
00071 
00072 public:
00082     MSAgentbasedTrafficLightLogic(MSTLLogicControl& tlcontrol,
00083                                   const std::string& id, const std::string& programID,
00084                                   const MSSimpleTrafficLightLogic::Phases& phases,
00085                                   unsigned int step, SUMOTime delay,
00086                                   const std::map<std::string, std::string> &parameter);
00087 
00088 
00094     void init(NLDetectorBuilder& nb);
00095 
00096 
00098     ~MSAgentbasedTrafficLightLogic();
00099 
00100 
00101 
00104 
00110     SUMOTime trySwitch(bool isActive);
00112 
00113 
00114 protected:
00117 
00124     unsigned int nextStep();
00125 
00126 
00129     void collectData();
00130 
00131 
00134     void aggregateRawData();
00135 
00136 
00139     void calculateDuration();
00140 
00141 
00145     void lengthenCycleTime(unsigned int toLenghten);
00146 
00147 
00151     void cutCycleTime(unsigned int toCut);
00152 
00153 
00157     unsigned int findStepOfMaxValue() const;
00158 
00159 
00163     unsigned int findStepOfMinValue() const;
00165 
00166 
00167 protected:
00169     E2DetectorMap myE2Detectors;
00170 
00172     PhaseValueMap myRawDetectorData;
00173 
00175     MeanDataMap myMeanDetectorData;
00176 
00180     unsigned int tDecide;
00181 
00183     unsigned int tSinceLastDecision;
00184 
00186     unsigned int stepOfLastDecision;
00187 
00191     unsigned int numberOfValues;
00192 
00194     unsigned int tCycle;
00195 
00196     /* @brief The minimum difference between the shortest and the longest que
00197      *
00198      * Queue_Lengt_Ahead_Of_Traffic_Lights of a phase before greentime is given
00199      *  from the phase with the shortest Queue_Lengt_Ahead_Of_Traffic_Lights to the phase with
00200      *  the longest Queue_Lengt_Ahead_Of_Traffic_Lights */
00201     SUMOReal deltaLimit;
00202 
00203 };
00204 
00205 
00206 #endif
00207 
00208 /****************************************************************************/
00209 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines