21 #ifndef MSSwarmTrafficLightLogic_h 22 #define MSSwarmTrafficLightLogic_h 55 bool addValue(
const T newValue, T& replacedValue) {
68 T
at(
const int index)
const {
100 m_buffer[m_currentIndex++] = value;
101 if (m_currentIndex == m_size) {
122 const std::string& subid,
const Phases& phases,
int step,
124 const std::map<std::string, std::string>& parameters);
185 return scaleFactorDispersionIn;
189 return scaleFactorDispersionOut;
196 return "swarmBasedTrafficLogic";
228 int decideNextPhase();
244 void resetPheromone();
249 SUMOReal getPheromoneForInputLanes();
254 SUMOReal getPheromoneForOutputLanes();
269 SUMOReal getDistanceOfMaxPheroForInputLanes();
274 SUMOReal getDistanceOfMaxPheroForOutputLanes();
280 void updatePheromoneLevels();
292 void updateSensitivities();
322 void resetLaneCheck();
327 return getParameter(
"POLICIES",
"Platoon;Phase;Marching;Congestion");
341 std::vector<SUMOReal> phero_values;
343 for (
int i = 0; i < lanes_in / 2; i++) {
344 phero_values.push_back(getPheroMaxVal());
346 for (
int i = lanes_in / 2; i < lanes_in; i++) {
347 phero_values.push_back(0.0);
352 for (
int i = 0; i < (int)phero_values.size(); i++) {
353 sum_avg_tmp += phero_values[i];
356 SUMOReal mean = sum_avg_tmp / phero_values.size();
359 for (
int i = 0; i < (int)phero_values.size(); i++) {
360 sum_dev_tmp += pow(phero_values[i] - mean, 2);
363 SUMOReal deviation = sqrt(sum_dev_tmp / phero_values.size());
365 scaleFactorDispersionIn = getPheroMaxVal() / deviation;
369 std::vector<SUMOReal> phero_values;
371 for (
int i = 0; i < lanes_out / 2; i++) {
372 phero_values.push_back(getPheroMaxVal());
374 for (
int i = lanes_out / 2; i < lanes_out; i++) {
375 phero_values.push_back(0.0);
379 for (
int i = 0; i < (int)phero_values.size(); i++) {
380 sum_avg_tmp += phero_values[i];
382 SUMOReal mean = sum_avg_tmp / phero_values.size();
386 for (
int i = 0; i < (int)phero_values.size(); i++) {
387 sum_dev_tmp += pow(phero_values[i] - mean, 2);
390 SUMOReal deviation = sqrt(sum_dev_tmp / phero_values.size());
392 scaleFactorDispersionOut = getPheroMaxVal() / deviation;
442 std::string getLaneLightState(
const std::string& laneId);
virtual SUMOTime computeReturnTime()
void initScaleFactorDispersionOut(int lanes_out)
Builds detectors for microsim.
std::map< std::string, CircularBuffer< SUMOReal > * > m_derivativeHistory
SUMOReal getScaleFactorDispersionOut()
static SUMOReal _2SUMOReal(const E *const data)
converts a char-type array into the SUMOReal value described by it
int getReinforcementMode()
std::map< std::string, CircularBuffer< SUMOReal > * > m_meanSpeedHistory
SUMOTime getMaxCongestionDuration()
SUMOReal getLearningCox()
std::string getPoliciesParam()
std::ofstream swarmLogFile
SUMOTime congestion_steps
LaneIdVector targetLanes
A copy of the target lanes of this phase.
std::map< MSLane *, bool > LaneCheckMap
A self-organizing high-level traffic light logic.
bool addValue(const T newValue, T &replacedValue)
A class that stores and controls tls and switching of their programs.
bool mustChange
When true, indicates that the current policy MUST be changed. It's used to force the exit from the co...
T at(const int index) const
virtual ~CircularBuffer()
std::map< std::string, SUMOReal > MSLaneId_PheromoneMap
std::map< std::string, std::string > m_pheroLevelLog
SUMOReal m_derivativeAlpha
bool skipEta
When true indicates that we can skip the evaluation of eta since we've a congestion policy that is la...
const std::string getLogicType() const
Returns the type of the logic as a string.
SUMOReal getScaleFactorDispersionIn()
SUMOReal scaleFactorDispersionIn
bool gotTargetLane
When true indicates that we've already acquired the target lanes for this particular phase...
SUMOReal getForgettingCox()
void push_front(const T value)
MSLaneId_PheromoneMap pheromoneOutputLanes
This pheromone is an indicator of congestion on output lanes. Its levels refer to the average speed o...
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
void insert(const T &value)
SUMOReal getPheroMaxVal()
MSLaneId_PheromoneMap pheromoneInputLanes
This pheronome is an indicator of congestion on input lanes. Its levels refer to the average speed of...
SUMOTime lastThetaSensitivityUpdate
bool m_useVehicleTypesWeights
void initScaleFactorDispersionIn(int lanes_in)
LaneCheckMap laneCheck
Map to check if a lane was already controlled during the elaboration of eta.
std::vector< std::string > LaneIdVector
Representation of a lane in the micro simulation.
std::map< std::string, std::vector< int > > m_laneIndexMap
SUMOReal scaleFactorDispersionOut
SUMOReal getChangePlanProbability()