25 const std::string& subid,
const Phases& phases,
int step,
26 SUMOTime delay,
const std::map<std::string, std::string>& parameters) :
47 "*** Intersection " +
getID()
48 +
" will run using MSDeterministicHiLevelTrafficLightLogic ***");
50 MSLane* currentLane = NULL;
51 for (MSTrafficLightLogic::LaneVectorVector::const_iterator laneVector =
53 for (MSTrafficLightLogic::LaneVector::const_iterator lane =
54 laneVector->begin(); lane != laneVector->end(); lane++) {
55 currentLane = (*lane);
66 for (
int i = 0; i < (int)
myLinks.size(); i++) {
68 for (
int j = 0; j < (int)oneLink.size(); j++) {
69 currentLane = oneLink[j]->getLane();
105 for (MSLaneID_set::iterator laneIterator =
inputLanes.begin();
106 laneIterator !=
inputLanes.end(); laneIterator++) {
107 std::string laneId = *laneIterator;
110 vSpeedInTot += (13.89 - maxSpeed) * 10. / 13.89;
113 std::ostringstream i_str; i_str <<
" meanVehiclesSpeed " << maxSpeed <<
" inputLane " << laneId <<
" ID " <<
getID() <<
" .";
WRITE_MESSAGE(
time2string(
MSNet::getInstance()->getCurrentTimeStep()) +
" MSDeterministicHiLevelTrafficLightLogic::getMeanSpeedForInputLanes:: in" + i_str.str());)
123 for (MSLaneID_set::iterator laneIterator =
outputLanes.begin();
124 laneIterator !=
outputLanes.end(); laneIterator++) {
125 std::string laneId = *laneIterator;
128 vSpeedOutTot += (13.89 - maxSpeed) * 10. / 13.89;
131 std::ostringstream i_str; i_str <<
" meanVehiclesSpeed " << maxSpeed <<
" outputLane " << laneId <<
" ID " <<
getID() <<
" .";
WRITE_MESSAGE(
time2string(
MSNet::getInstance()->getCurrentTimeStep()) +
" MSDeterministicHiLevelTrafficLightLogic::getMeanSpeedForOutputLanes:: out" + i_str.str());)
144 if (newPolicy != oldPolicy) {
147 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() +
" .");)
158 int index_maxStimulus = 0;
161 for (
int i = 0; i < (int)
getPolicies().size(); i++) {
164 if (stimulus > maxStimulus) {
165 maxStimulus = stimulus;
166 index_maxStimulus = i;
169 std::ostringstream so_str; so_str <<
" policy " <<
getPolicies()[i]->getName() <<
" stimulus " << stimulus;
WRITE_MESSAGE(
"MSDeterministicHiLevelTrafficLightLogic::choosePolicy::" + so_str.str());)
void decidePolicy()
Decide the current policy according to pheromone levels The decision reflects on currentPolicy value...
MSLaneID_set inputLanes
This pheronome is an indicator of congestion on input lanes. Its levels refer to the average speed of...
MSSOTLSensors * getSensors()
const std::string & getState() const
Returns the state within this phase.
Builds detectors for microsim.
Class for low-level platoon policy.
std::string time2string(SUMOTime t)
Class for low-level marching policy.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
void init(NLDetectorBuilder &nb)
Initialises the tls.
virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
void init(NLDetectorBuilder &nb)
Initialises the tls with sensors on incoming and outgoing lanes Sensors are built in the simulation a...
const std::string & getID() const
Returns the id.
~MSDeterministicHiLevelTrafficLightLogic()
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
int getPhaseIndexWithMaxCTS()
const LinkVector & getLinksAt(int i) const
Returns the list of links that are controlled by the signals at the given position.
virtual bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)=0
A self-organizing high-level traffic light logic.
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index...
A class that stores and controls tls and switching of their programs.
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
SUMOReal getMeanSpeedForOutputLanes()
std::vector< MSSOTLPolicy * > & getPolicies()
Returns the vector of the low-level policies used by this high-level tll.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.
MSLaneID_set outputLanes
This pheromone is an indicator of congestion on output lanes. Its levels refer to the average speed o...
virtual SUMOReal meanVehiclesSpeed(MSLane *lane)=0
std::vector< MSLink * > LinkVector
Definition of the list of links that participate in this tl-light.
MSSOTLPolicy * getCurrentPolicy()
Returns the low-level policy currently selected by this high-level tll.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
MSDeterministicHiLevelTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > ¶meters)
Constructor without sensors passed.
LinkVectorVector myLinks
The list of LinkVectors; each vector contains the links that belong to the same link index...
SUMOTime getCurrentPhaseElapsed()
void activate(MSSOTLPolicy *policy)
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
SUMOReal getMeanSpeedForInputLanes()
int getCurrentPhaseIndex() const
Returns the current index within the program.
Class for low-level phase policy.
void inform(std::string msg, bool addType=true)
adds a new error to the list
Class for a low-level policy.
Class for low-level congestion policy.
#define WRITE_MESSAGE(msg)
void choosePolicy(SUMOReal mean_vSpeed_in, SUMOReal mean_vSpeed_out)
Representation of a lane in the micro simulation.
bool isPushButtonPressed()
void addPolicy(MSSOTLPolicy *policy)
int countVehicles(MSPhaseDefinition phase)