30 const std::string& programID,
const Phases& phases,
int step,
51 "*** Intersection " +
getID()
52 +
" will run using MSDeterministicHiLevelTrafficLightLogic ***");
54 MSLane* currentLane =
nullptr;
55 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
57 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
58 laneVector->begin(); lane != laneVector->end(); lane++) {
59 currentLane = (*lane);
70 for (
int j = 0; j < (int)oneLink.size(); j++) {
71 currentLane = oneLink[j]->getLane();
86 std::ostringstream dnp;
97 std::ostringstream str;
98 str <<
"tlsID=" <<
getID() <<
" currentPolicyname=" + getCurrentPolicy()->getName();
113 double vSpeedInTot = 0;
114 for (MSLaneID_set::iterator laneIterator =
inputLanes.begin();
115 laneIterator !=
inputLanes.end(); laneIterator++) {
116 std::string laneId = *laneIterator;
119 vSpeedInTot += (13.89 - maxSpeed) * 10. / 13.89;
122 std::ostringstream i_str;
123 i_str <<
" meanVehiclesSpeed " << maxSpeed <<
" inputLane " << laneId <<
" ID " <<
getID() <<
" .";
127 return vSpeedInTot / (double)
inputLanes.size();
134 double vSpeedOutTot = 0;
135 for (MSLaneID_set::iterator laneIterator =
outputLanes.begin();
136 laneIterator !=
outputLanes.end(); laneIterator++) {
137 std::string laneId = *laneIterator;
140 vSpeedOutTot += (13.89 - maxSpeed) * 10. / 13.89;
143 std::ostringstream i_str;
144 i_str <<
" meanVehiclesSpeed " << maxSpeed <<
" outputLane " << laneId <<
" ID " <<
getID() <<
" .";
162 if (newPolicy != oldPolicy) {
164 std::ostringstream phero_str;
165 phero_str <<
" (mean_vSpeed_in= " << mean_vSpeed_in <<
" ,mean_vSpeed_out= " << mean_vSpeed_out <<
" )";
168 std::ostringstream phero_str;
169 phero_str <<
" (mean_vSpeed_in= " << mean_vSpeed_in <<
" ,mean_vSpeed_out= " << mean_vSpeed_out <<
" )";
177 double mean_vSpeed_in,
double mean_vSpeed_out) {
179 int index_maxStimulus = 0;
180 double maxStimulus = -1;
182 for (
int i = 0; i < (int)
myPolicies.size(); i++) {
183 double stimulus =
myPolicies[i]->computeDesirability(mean_vSpeed_in,
185 if (stimulus > maxStimulus) {
186 maxStimulus = stimulus;
187 index_maxStimulus = i;
190 std::ostringstream so_str;
191 so_str <<
" policy " << getPolicies()[i]->getName() <<
" stimulus " << stimulus;
192 WRITE_MESSAGE(
"MSDeterministicHiLevelTrafficLightLogic::choosePolicy::" + so_str.str());
201 std::ostringstream phero_str;
203 WRITE_MESSAGE(
"\nMSDeterministicHiLevelTrafficLightLogic::canRelease(): " + phero_str.str());
#define WRITE_MESSAGE(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
void choosePolicy(double mean_vSpeed_in, double mean_vSpeed_out)
double getMeanSpeedForOutputLanes()
void init(NLDetectorBuilder &nb)
Initialises the tls with sensors on incoming and outgoing lanes Sensors are built in the simulation a...
MSLaneID_set inputLanes
This pheronome is an indicator of congestion on input lanes. Its levels refer to the average speed of...
~MSDeterministicHiLevelTrafficLightLogic()
void decidePolicy()
Decide the current policy according to pheromone levels The decision reflects on currentPolicy value.
MSLaneID_set outputLanes
This pheromone is an indicator of congestion on output lanes. Its levels refer to the average speed o...
double getMeanSpeedForInputLanes()
MSDeterministicHiLevelTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const Phases &phases, int step, SUMOTime delay, const Parameterised::Map ¶meters)
Constructor without sensors passed.
Representation of a lane in the micro simulation.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
const std::string & getState() const
Returns the state within this phase.
Class for low-level congestion policy.
A self-organizing high-level traffic light logic.
std::vector< MSSOTLPolicy * > myPolicies
void addPolicy(MSSOTLPolicy *policy)
MSSOTLPolicy * myCurrentPolicy
void activate(MSSOTLPolicy *policy)
void init(NLDetectorBuilder &nb)
Initialises the tls.
Class for low-level marching policy.
Class for low-level phase policy.
Class for low-level platoon policy.
Class for a low-level policy.
virtual bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)=0
virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
virtual double meanVehiclesSpeed(MSLane *lane)=0
int getPhaseIndexWithMaxCTS()
int countVehicles(MSPhaseDefinition phase)
SUMOTime getCurrentPhaseElapsed()
bool isPushButtonPressed()
MSSOTLSensors * getSensors()
int getCurrentPhaseIndex() const override
Returns the current index within the program.
const MSPhaseDefinition & getCurrentPhaseDef() const override
Returns the definition of the current phase.
A class that stores and controls tls and switching of their programs.
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
std::vector< MSLink * > LinkVector
Definition of the list of links that are subjected to this tls.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.
Builds detectors for microsim.
const std::string & getID() const
Returns the id.
std::map< std::string, std::string > Map
parameters map