 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
17 #ifndef MSSwarmTrafficLightLogic_h
18 #define MSSwarmTrafficLightLogic_h
47 bool addValue(
const T newValue, T& replacedValue) {
60 T
at(
const int index)
const {
114 const std::string& programID,
const Phases& phases,
int step,
116 const std::map<std::string, std::string>& parameters);
188 return "swarmBasedTrafficLogic";
315 void choosePolicy(
double phero_in,
double phero_out,
double dispersion_in,
double dispersion_out);
319 return getParameter(
"POLICIES",
"Platoon;Phase;Marching;Congestion");
333 std::vector<double> phero_values;
335 for (
int i = 0; i < lanes_in / 2; i++) {
338 for (
int i = lanes_in / 2; i < lanes_in; i++) {
339 phero_values.push_back(0.0);
342 double sum_avg_tmp = 0;
344 for (
int i = 0; i < (int)phero_values.size(); i++) {
345 sum_avg_tmp += phero_values[i];
348 double mean = sum_avg_tmp / phero_values.size();
350 double sum_dev_tmp = 0;
351 for (
int i = 0; i < (int)phero_values.size(); i++) {
352 sum_dev_tmp += pow(phero_values[i] - mean, 2);
355 double deviation = sqrt(sum_dev_tmp / phero_values.size());
361 std::vector<double> phero_values;
363 for (
int i = 0; i < lanes_out / 2; i++) {
366 for (
int i = lanes_out / 2; i < lanes_out; i++) {
367 phero_values.push_back(0.0);
370 double sum_avg_tmp = 0;
371 for (
int i = 0; i < (int)phero_values.size(); i++) {
372 sum_avg_tmp += phero_values[i];
374 double mean = sum_avg_tmp / phero_values.size();
376 double sum_dev_tmp = 0;
378 for (
int i = 0; i < (int)phero_values.size(); i++) {
379 sum_dev_tmp += pow(phero_values[i] - mean, 2);
382 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