 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
22 const std::string& programID,
const Phases& phases,
int step,
23 SUMOTime delay,
const std::map<std::string, std::string>& parameters) :
43 "*** Intersection " +
getID()
44 +
" will run using MSDeterministicHiLevelTrafficLightLogic ***");
46 MSLane* currentLane =
nullptr;
47 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
49 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
50 laneVector->begin(); lane != laneVector->end(); lane++) {
51 currentLane = (*lane);
62 for (
int i = 0; i < (int)
myLinks.size(); i++) {
64 for (
int j = 0; j < (int)oneLink.size(); j++) {
65 currentLane = oneLink[j]->getLane();
100 double vSpeedInTot = 0;
101 for (MSLaneID_set::iterator laneIterator =
inputLanes.begin();
102 laneIterator !=
inputLanes.end(); laneIterator++) {
103 std::string laneId = *laneIterator;
106 vSpeedInTot += (13.89 - maxSpeed) * 10. / 13.89;
109 std::ostringstream i_str; i_str <<
" meanVehiclesSpeed " << maxSpeed <<
" inputLane " << laneId <<
" ID " <<
getID() <<
" .";
WRITE_MESSAGE(
time2string(
MSNet::getInstance()->getCurrentTimeStep()) +
" MSDeterministicHiLevelTrafficLightLogic::getMeanSpeedForInputLanes:: in" + i_str.str());)
118 double vSpeedOutTot = 0;
119 for (MSLaneID_set::iterator laneIterator =
outputLanes.begin();
120 laneIterator !=
outputLanes.end(); laneIterator++) {
121 std::string laneId = *laneIterator;
124 vSpeedOutTot += (13.89 - maxSpeed) * 10. / 13.89;
127 std::ostringstream i_str; i_str <<
" meanVehiclesSpeed " << maxSpeed <<
" outputLane " << laneId <<
" ID " <<
getID() <<
" .";
WRITE_MESSAGE(
time2string(
MSNet::getInstance()->getCurrentTimeStep()) +
" MSDeterministicHiLevelTrafficLightLogic::getMeanSpeedForOutputLanes:: out" + i_str.str());)
140 if (newPolicy != oldPolicy) {
143 std::ostringstream phero_str; phero_str <<
" (mean_vSpeed_in= " << mean_vSpeed_in <<
" ,mean_vSpeed_out= " << mean_vSpeed_out <<
" )";
WRITE_MESSAGE(
"TL " +
getID() +
" time " +
time2string(step) +
" Policy: " + newPolicy->
getName() + phero_str.str() +
" OldPolicy: " + oldPolicy->
getName() +
" id " +
getID() +
" .");)
152 double mean_vSpeed_in,
double mean_vSpeed_out) {
154 int index_maxStimulus = 0;
155 double maxStimulus = -1;
157 for (
int i = 0; i < (int)
getPolicies().size(); i++) {
158 double stimulus =
getPolicies()[i]->computeDesirability(mean_vSpeed_in,
160 if (stimulus > maxStimulus) {
161 maxStimulus = stimulus;
162 index_maxStimulus = i;
165 std::ostringstream so_str; so_str <<
" policy " <<
getPolicies()[i]->getName() <<
" stimulus " << stimulus;
WRITE_MESSAGE(
"MSDeterministicHiLevelTrafficLightLogic::choosePolicy::" + so_str.str());)
virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
const LinkVector & getLinksAt(int i) const
Returns the list of links that are controlled by the signals at the given position.
LinkVectorVector myLinks
The list of LinkVectors; each vector contains the links that belong to the same link index.
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index.
~MSDeterministicHiLevelTrafficLightLogic()
Class for a low-level policy.
Representation of a lane in the micro simulation.
Class for low-level marching policy.
void init(NLDetectorBuilder &nb)
Initialises the tls with sensors on incoming and outgoing lanes Sensors are built in the simulation a...
void decidePolicy()
Decide the current policy according to pheromone levels The decision reflects on currentPolicy value.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
MSDeterministicHiLevelTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > ¶meters)
Constructor without sensors passed.
A self-organizing high-level traffic light logic.
MSLaneID_set inputLanes
This pheronome is an indicator of congestion on input lanes. Its levels refer to the average speed of...
MSSOTLSensors * getSensors()
bool isPushButtonPressed()
virtual double meanVehiclesSpeed(MSLane *lane)=0
Class for low-level congestion policy.
double getMeanSpeedForInputLanes()
const std::string & getState() const
Returns the state within this phase.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
std::string time2string(SUMOTime t)
int getPhaseIndexWithMaxCTS()
MSSOTLPolicy * getCurrentPolicy()
Returns the low-level policy currently selected by this high-level tll.
int getCurrentPhaseIndex() const
Returns the current index within the program.
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
Class for low-level phase policy.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
int countVehicles(MSPhaseDefinition phase)
MSLaneID_set outputLanes
This pheromone is an indicator of congestion on output lanes. Its levels refer to the average speed o...
std::vector< MSSOTLPolicy * > & getPolicies()
Returns the vector of the low-level policies used by this high-level tll.
void addPolicy(MSSOTLPolicy *policy)
double getMeanSpeedForOutputLanes()
virtual bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)=0
void choosePolicy(double mean_vSpeed_in, double mean_vSpeed_out)
A class that stores and controls tls and switching of their programs.
Class for low-level platoon policy.
void init(NLDetectorBuilder &nb)
Initialises the tls.
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
const std::string & getID() const
Returns the id.
std::vector< MSLink * > LinkVector
Definition of the list of links that are subjected to this tls.
#define WRITE_MESSAGE(msg)
Builds detectors for microsim.
SUMOTime getCurrentPhaseElapsed()
void activate(MSSOTLPolicy *policy)
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.