36 std::ostringstream oss;
47 m_useSigmoid = parameterised->
getParameter(
"PLATOON_USE_SIGMOID",
"0") !=
"0";
63 if (m_useSigmoid && vehicleCount == 0) {
64 double sigmoidValue = 1.0 / (1.0 + exp(-m_k * (elapsed / 1000 - stage->
duration / 1000)));
67 std::ostringstream oss;
68 oss <<
m_prefix <<
"::sigmoidLogic [k=" << m_k <<
" elapsed " << elapsed <<
" stage->duration " << stage->
duration <<
" ] value " 70 oss <<
" rnd " << rnd <<
" retval " << (rnd < sigmoidValue ?
"true" :
"false");
73 return rnd < sigmoidValue;
80 const std::map<std::string, std::string>& parameters) :
88 desirabilityAlgorithm) {
94 const std::map<std::string, std::string>& parameters) :
96 desirabilityAlgorithm) {
106 std::ostringstream str; str <<
"\nMSSOTLPolicy::computeStimulus\n" <<
getName();
WRITE_MESSAGE(str.str());)
115 std::ostringstream str; str <<
"\nMSSOTLPolicy::computeStimulus\n" <<
getName();
WRITE_MESSAGE(str.str());)
123 int phaseMaxCTS,
bool thresholdPassed,
bool pushButtonPressed,
int vehicleCount) {
135 return currentPhaseIndex + 1;
140 std::ostringstream phero_str;
141 phero_str <<
"getCurrentPhaseElapsed()=" <<
time2string(elapsed) <<
" isThresholdPassed()=" << thresholdPassed <<
" countVehicles()=" << vehicleCount;
142 WRITE_MESSAGE(
"MSSOTLPolicy::decideNextPhase: " + phero_str.str());
144 if (
canRelease(elapsed, thresholdPassed, pushButtonPressed, stage, vehicleCount)) {
145 return currentPhaseIndex + 1;
149 return currentPhaseIndex;
virtual double computeDesirability(double vehInMeasure, double vehOutMeasure)=0
Calculates the desirability of the policy.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
std::string time2string(SUMOTime t)
void init(std::string prefix, const Parameterised *parameterised)
virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
double theta_sensitivity
The sensitivity of this policy.
virtual bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)=0
bool sigmoidLogic(SUMOTime elapsed, const MSPhaseDefinition *stage, int vehicleCount)
SUMOTime duration
The duration of the phase.
MSSOTLPolicy(std::string name, const std::map< std::string, std::string > ¶meters)
Simple constructor.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
An upper class for objects with additional parameters.
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
#define WRITE_MESSAGE(msg)
std::string myName
The name of the policy.
The definition of a single phase of a tls logic.
bool isDecisional() const
MSSOTLPolicyDesirability * myDesirabilityAlgorithm
A pointer to the policy desirability object.'s an optional component related to the computeDesirabili...
double computeDesirability(double vehInMeasure, double vehOutMeasure, double vehInDispersionMeasure, double vehOutDispersionMeasure)
Computes the desirability of this policy, necessary when used in combination with an high level polic...