 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
18 #ifndef MSSwarmTrafficLightLogic_h
19 #define MSSwarmTrafficLightLogic_h
48 bool addValue(
const T newValue, T& replacedValue) {
61 T
at(
const int index)
const {
115 const std::string& programID,
const Phases& phases,
int step,
117 const std::map<std::string, std::string>& parameters);
189 return "swarmBasedTrafficLogic";
316 void choosePolicy(
double phero_in,
double phero_out,
double dispersion_in,
double dispersion_out);
320 return getParameter(
"POLICIES",
"Platoon;Phase;Marching;Congestion");
334 std::vector<double> phero_values;
336 for (
int i = 0; i < lanes_in / 2; i++) {
339 for (
int i = lanes_in / 2; i < lanes_in; i++) {
340 phero_values.push_back(0.0);
343 double sum_avg_tmp = 0;
345 for (
int i = 0; i < (int)phero_values.size(); i++) {
346 sum_avg_tmp += phero_values[i];
349 double mean = sum_avg_tmp / phero_values.size();
351 double sum_dev_tmp = 0;
352 for (
int i = 0; i < (int)phero_values.size(); i++) {
353 sum_dev_tmp += pow(phero_values[i] - mean, 2);
356 double deviation = sqrt(sum_dev_tmp / phero_values.size());
362 std::vector<double> phero_values;
364 for (
int i = 0; i < lanes_out / 2; i++) {
367 for (
int i = lanes_out / 2; i < lanes_out; i++) {
368 phero_values.push_back(0.0);
371 double sum_avg_tmp = 0;
372 for (
int i = 0; i < (int)phero_values.size(); i++) {
373 sum_avg_tmp += phero_values[i];
375 double mean = sum_avg_tmp / phero_values.size();
377 double sum_dev_tmp = 0;
379 for (
int i = 0; i < (int)phero_values.size(); i++) {
380 sum_dev_tmp += pow(phero_values[i] - mean, 2);
383 double deviation = sqrt(sum_dev_tmp / phero_values.size());
virtual SUMOTime computeReturnTime()
double getScaleFactorDispersionIn()
Representation of a lane in the micro simulation.
double calculateEtaRatio()
bool skipEta
When true indicates that we can skip the evaluation of eta since we've a congestion policy that is la...
void initScaleFactorDispersionOut(int lanes_out)
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
std::vector< std::string > LaneIdVector
std::map< MSLane *, bool > LaneCheckMap
LaneIdVector targetLanes
A copy of the target lanes of this phase.
~MSSwarmTrafficLightLogic()
void init(NLDetectorBuilder &nb)
Initialises the tls with sensors on incoming and outgoing lanes Sensors are built in the simulation a...
std::ofstream swarmLogFile
A self-organizing high-level traffic light logic.
bool allowLine(MSLane *)
Check if a lane is allowed to be added to the maps pheromoneInputLanes and pheromoneOutputLanes Contr...
LaneCheckMap laneCheck
Map to check if a lane was already controlled during the elaboration of eta.
std::map< std::string, std::string > m_pheroLevelLog
bool mustChange
When true, indicates that the current policy MUST be changed. It's used to force the exit from the co...
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
void initScaleFactorDispersionIn(int lanes_in)
double scaleFactorDispersionIn
bool addValue(const T newValue, T &replacedValue)
std::map< std::string, std::vector< int > > m_laneIndexMap
std::string getLaneLightState(const std::string &laneId)
T at(const int index) const
int getReinforcementMode()
double scaleFactorDispersionOut
void resetPheromone()
Resets pheromone levels.
void push_front(const T value)
std::string getPoliciesParam()
double getDispersionForOutputLanes(double average_phero_out)
MSLaneId_PheromoneMap pheromoneOutputLanes
This pheromone is an indicator of congestion on output lanes. Its levels refer to the average speed o...
bool gotTargetLane
When true indicates that we've already acquired the target lanes for this particular phase.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
bool m_useVehicleTypesWeights
MSLaneId_PheromoneMap pheromoneInputLanes
This pheronome is an indicator of congestion on input lanes. Its levels refer to the average speed of...
const std::string getLogicType() const
Returns the type of the logic as a string.
MSSwarmTrafficLightLogic(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.
void updatePheromoneLevels()
Update pheromone levels Pheromone on input lanes is costantly updated Pheromone follows a discrete-ti...
std::map< std::string, double > MSLaneId_PheromoneMap
double getDistanceOfMaxPheroForInputLanes()
virtual ~CircularBuffer()
SUMOTime getMaxCongestionDuration()
void updateSensitivities()
double getChangePlanProbability()
double getForgettingCox()
void insert(const T &value)
SUMOTime congestion_steps
double getDispersionForInputLanes(double average_phero_in)
double calculatePhi(int factor)
Method that should calculate the valor of phi a coefficient to amplify/attenuate eta based on a facto...
A class that stores and controls tls and switching of their programs.
SUMOTime lastThetaSensitivityUpdate
double getPheromoneForInputLanes()
void choosePolicy(double phero_in, double phero_out, double dispersion_in, double dispersion_out)
double calculateEtaDiff()
Method that should calculate the valor of eta a coefficient to evaluate the current policy's work....
double getDistanceOfMaxPheroForOutputLanes()
void decidePolicy()
Decide the current policy according to pheromone levels The decision reflects on currentPolicy value.
double getPheromoneForOutputLanes()
Builds detectors for microsim.
double getScaleFactorDispersionOut()
std::map< std::string, CircularBuffer< double > * > m_meanSpeedHistory
std::map< std::string, CircularBuffer< double > * > m_derivativeHistory