Eclipse SUMO - Simulation of Urban MObility
MSActuatedTrafficLightLogic.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // An actuated (adaptive) traffic light logic
17 /****************************************************************************/
18 #ifndef MSActuatedTrafficLightLogic_h
19 #define MSActuatedTrafficLightLogic_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <utility>
28 #include <vector>
29 #include <bitset>
30 #include <map>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class NLDetectorBuilder;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
51 public:
62  const std::string& id, const std::string& programID,
64  int step, SUMOTime delay,
65  const std::map<std::string, std::string>& parameter,
66  const std::string& basePath);
67 
68 
73  void init(NLDetectorBuilder& nb);
74 
75 
78 
79 
80 
83 
90 
92  void activateProgram();
93  void deactivateProgram();
94 
95  bool showDetectors() const {
96  return myShowDetectors;
97  }
98 
99  void setShowDetectors(bool show);
100 
101 protected:
102  struct InductLoopInfo {
103  InductLoopInfo(MSInductLoop* _loop, int numPhases):
104  loop(_loop),
105  servedPhase(numPhases, false)
106  {}
109  std::vector<bool> servedPhase;
110  };
111 
113  typedef std::vector<std::vector<InductLoopInfo*> > InductLoopMap;
114 
117 
122  SUMOTime duration(const double detectionGap) const;
123 
126 
129  double gapControl();
130 
131 
133  bool hasMajor(const std::string& state, const LaneVector& lanes) const;
135 
137  int decideNextPhase();
138 
139  int getDetectorPriority(const InductLoopInfo& loopInfo) const;
140 
142  int getPhasePriority(int step) const;
143 
145  int getTarget(int step);
146 
147 protected:
150 
151  std::vector<InductLoopInfo> myInductLoops;
152 
153 
155  double myMaxGap;
156 
159 
162 
165 
168 
170  std::string myFile;
171 
174 
176  std::string myVehicleTypes;
177 
178 };
179 
180 
181 #endif
182 
183 /****************************************************************************/
184 
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSTrafficLightLogic::Phases
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Definition: MSTrafficLightLogic.h:61
MSActuatedTrafficLightLogic::myShowDetectors
bool myShowDetectors
Whether the detectors shall be shown in the GUI.
Definition: MSActuatedTrafficLightLogic.h:167
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSInductLoop
An unextended detector measuring at a fixed position on a fixed lane.
Definition: MSInductLoop.h:64
MSActuatedTrafficLightLogic::myInductLoops
std::vector< InductLoopInfo > myInductLoops
Definition: MSActuatedTrafficLightLogic.h:151
MSActuatedTrafficLightLogic::InductLoopInfo
Definition: MSActuatedTrafficLightLogic.h:102
MSActuatedTrafficLightLogic::~MSActuatedTrafficLightLogic
~MSActuatedTrafficLightLogic()
Destructor.
Definition: MSActuatedTrafficLightLogic.cpp:80
MSSimpleTrafficLightLogic.h
MSActuatedTrafficLightLogic::decideNextPhase
int decideNextPhase()
select am candidate phases based on detector states
Definition: MSActuatedTrafficLightLogic.cpp:506
MSActuatedTrafficLightLogic::trySwitch
SUMOTime trySwitch()
Switches to the next phase.
Definition: MSActuatedTrafficLightLogic.cpp:393
MSTrafficLightLogic.h
MSActuatedTrafficLightLogic::duration
SUMOTime duration(const double detectionGap) const
Returns the minimum duration of the current phase.
Definition: MSActuatedTrafficLightLogic.cpp:445
MSTrafficLightLogic::LaneVector
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
Definition: MSTrafficLightLogic.h:70
MSActuatedTrafficLightLogic::getTarget
int getTarget(int step)
get the green phase following step
Definition: MSActuatedTrafficLightLogic.cpp:564
MSActuatedTrafficLightLogic::myFile
std::string myFile
The output file for generated detectors.
Definition: MSActuatedTrafficLightLogic.h:170
MSActuatedTrafficLightLogic::myVehicleTypes
std::string myVehicleTypes
Whether detector output separates by vType.
Definition: MSActuatedTrafficLightLogic.h:176
MSActuatedTrafficLightLogic::getMinimumMinDuration
SUMOTime getMinimumMinDuration(MSLane *lane) const
get the minimum min duration for all stretchable phases that affect the given lane
Definition: MSActuatedTrafficLightLogic.cpp:338
MSActuatedTrafficLightLogic::InductLoopInfo::lastGreenTime
SUMOTime lastGreenTime
Definition: MSActuatedTrafficLightLogic.h:108
MSSimpleTrafficLightLogic
A fixed traffic light logic.
Definition: MSSimpleTrafficLightLogic.h:54
MSActuatedTrafficLightLogic
An actuated (adaptive) traffic light logic.
Definition: MSActuatedTrafficLightLogic.h:50
MSActuatedTrafficLightLogic::myFreq
SUMOTime myFreq
The frequency for aggregating detector output.
Definition: MSActuatedTrafficLightLogic.h:173
MSActuatedTrafficLightLogic::InductLoopInfo::InductLoopInfo
InductLoopInfo(MSInductLoop *_loop, int numPhases)
Definition: MSActuatedTrafficLightLogic.h:103
MSActuatedTrafficLightLogic::showDetectors
bool showDetectors() const
Definition: MSActuatedTrafficLightLogic.h:95
MSActuatedTrafficLightLogic::setShowDetectors
void setShowDetectors(bool show)
Definition: MSActuatedTrafficLightLogic.cpp:627
MSActuatedTrafficLightLogic::InductLoopInfo::loop
MSInductLoop * loop
Definition: MSActuatedTrafficLightLogic.h:107
MSActuatedTrafficLightLogic::getDetectorPriority
int getDetectorPriority(const InductLoopInfo &loopInfo) const
Definition: MSActuatedTrafficLightLogic.cpp:585
MSActuatedTrafficLightLogic::InductLoopInfo::servedPhase
std::vector< bool > servedPhase
Definition: MSActuatedTrafficLightLogic.h:109
MSActuatedTrafficLightLogic::myInactiveThreshold
SUMOTime myInactiveThreshold
The time threshold to avoid starved phases.
Definition: MSActuatedTrafficLightLogic.h:164
MSActuatedTrafficLightLogic::hasMajor
bool hasMajor(const std::string &state, const LaneVector &lanes) const
return whether there is a major link from the given lane in the given phase
Definition: MSActuatedTrafficLightLogic.cpp:358
MSActuatedTrafficLightLogic::myDetectorGap
double myDetectorGap
The detector distance in seconds.
Definition: MSActuatedTrafficLightLogic.h:161
MSActuatedTrafficLightLogic::init
void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
Definition: MSActuatedTrafficLightLogic.cpp:83
MSActuatedTrafficLightLogic::gapControl
double gapControl()
Return the minimum detection gap of all detectors if the current phase should be extended and double:...
Definition: MSActuatedTrafficLightLogic.cpp:465
config.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:59
MSActuatedTrafficLightLogic::myInductLoopsForPhase
InductLoopMap myInductLoopsForPhase
A map from phase to induction loops to be used for gap control.
Definition: MSActuatedTrafficLightLogic.h:149
MSActuatedTrafficLightLogic::MSActuatedTrafficLightLogic
MSActuatedTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const MSSimpleTrafficLightLogic::Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > &parameter, const std::string &basePath)
Constructor.
Definition: MSActuatedTrafficLightLogic.cpp:62
MSActuatedTrafficLightLogic::InductLoopMap
std::vector< std::vector< InductLoopInfo * > > InductLoopMap
Definition of a map from phases to induct loops controlling them.
Definition: MSActuatedTrafficLightLogic.h:113
MSEventControl.h
MSActuatedTrafficLightLogic::myPassingTime
double myPassingTime
The passing time used in seconds.
Definition: MSActuatedTrafficLightLogic.h:158
MSInductLoop.h
MSActuatedTrafficLightLogic::myMaxGap
double myMaxGap
The maximum gap to check in seconds.
Definition: MSActuatedTrafficLightLogic.h:155
MSActuatedTrafficLightLogic::activateProgram
void activateProgram()
called when switching programs
Definition: MSActuatedTrafficLightLogic.cpp:376
MSActuatedTrafficLightLogic::deactivateProgram
void deactivateProgram()
Definition: MSActuatedTrafficLightLogic.cpp:385
NLDetectorBuilder
Builds detectors for microsim.
Definition: NLDetectorBuilder.h:55
MSActuatedTrafficLightLogic::getPhasePriority
int getPhasePriority(int step) const
count the number of active detectors for the given step
Definition: MSActuatedTrafficLightLogic.cpp:617