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 2001-2010 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 <microsim/MSEventControl.h>
00037 #include "MSTrafficLightLogic.h"
00038 #include "MSSimpleTrafficLightLogic.h"
00039 #include <microsim/output/MS_E2_ZS_CollectorOverLanes.h>
00040 #include "MSSimpleTrafficLightLogic.h"
00041 
00042 
00043 // ===========================================================================
00044 // class declarations
00045 // ===========================================================================
00046 class MSLane;
00047 class MSAgentbasedPhaseDefinition;
00048 class NLDetectorBuilder;
00049 
00050 
00051 // ===========================================================================
00052 // class definitions
00053 // ===========================================================================
00058 class MSAgentbasedTrafficLightLogic :
00059             public MSSimpleTrafficLightLogic {
00060 public:
00062     typedef std::map<MSLane*, MS_E2_ZS_CollectorOverLanes*> E2DetectorMap;
00063 
00065     typedef std::deque<SUMOReal> ValueType;
00066 
00068     typedef std::map<unsigned int, ValueType> PhaseValueMap;
00069 
00071     typedef std::map<unsigned int, SUMOReal> MeanDataMap;
00072 
00073 public:
00086     MSAgentbasedTrafficLightLogic(MSTLLogicControl &tlcontrol,
00087                                   const std::string &id, const std::string &subid,
00088                                   const MSSimpleTrafficLightLogic::Phases &phases,
00089                                   unsigned int step, SUMOTime delay, int learnHorizon, int decHorizon,
00090                                   SUMOReal minDiff, int tcycle) throw();
00091 
00092 
00098     void init(NLDetectorBuilder &nb) throw(ProcessError);
00099 
00100 
00102     ~MSAgentbasedTrafficLightLogic() throw();
00103 
00104 
00105 
00108 
00114     SUMOTime trySwitch(bool isActive) throw();
00116 
00117 
00118 protected:
00121 
00128     unsigned int nextStep() throw();
00129 
00130 
00133     void collectData() throw();
00134 
00135 
00138     void aggregateRawData() throw();
00139 
00140 
00143     void calculateDuration() throw();
00144 
00145 
00149     void lengthenCycleTime(unsigned int toLenghten) throw();
00150 
00151 
00155     void cutCycleTime(unsigned int toCut) throw();
00156 
00157 
00161     unsigned int findStepOfMaxValue() const throw();
00162 
00163 
00167     unsigned int findStepOfMinValue() const throw();
00169 
00170 
00171 protected:
00173     E2DetectorMap myE2Detectors;
00174 
00176     PhaseValueMap myRawDetectorData;
00177 
00179     MeanDataMap myMeanDetectorData;
00180 
00184     unsigned int tDecide;
00185 
00187     unsigned int tSinceLastDecision;
00188 
00190     unsigned int stepOfLastDecision;
00191 
00195     unsigned int numberOfValues;
00196 
00198     unsigned int tCycle;
00199 
00200     /* @brief The minimum difference between the shortest and the longest que
00201      *
00202      * Queue_Lengt_Ahead_Of_Traffic_Lights of a phase before greentime is given
00203      *  from the phase with the shortest Queue_Lengt_Ahead_Of_Traffic_Lights to the phase with
00204      *  the longest Queue_Lengt_Ahead_Of_Traffic_Lights */
00205     SUMOReal deltaLimit;
00206 
00207 };
00208 
00209 
00210 #endif
00211 
00212 /****************************************************************************/
00213 

Generated on Wed May 5 00:06:30 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6