39 std::ostringstream oss;
50 m_useSigmoid = parameterised->
getParameter(
"PLATOON_USE_SIGMOID",
"0") !=
"0";
66 if (m_useSigmoid && vehicleCount == 0) {
67 SUMOReal sigmoidValue = 1.0 / (1.0 + exp(-m_k * (elapsed / 1000 - stage->
duration / 1000)));
70 std::ostringstream oss;
71 oss <<
m_prefix <<
"::sigmoidLogic [k=" << m_k <<
" elapsed " << elapsed <<
" stage->duration " << stage->
duration <<
" ] value " 73 oss <<
" rnd " << rnd <<
" retval " << (rnd < sigmoidValue ?
"true" :
"false");
76 return rnd < sigmoidValue;
83 const std::map<std::string, std::string>& parameters) :
91 desirabilityAlgorithm) {
97 const std::map<std::string, std::string>& parameters) :
99 desirabilityAlgorithm) {
109 std::ostringstream str; str <<
"\nMSSOTLPolicy::computeStimulus\n" <<
getName();
WRITE_MESSAGE(str.str());)
118 std::ostringstream str; str <<
"\nMSSOTLPolicy::computeStimulus\n" <<
getName();
WRITE_MESSAGE(str.str());)
126 int phaseMaxCTS,
bool thresholdPassed,
bool pushButtonPressed,
int vehicleCount) {
138 return currentPhaseIndex + 1;
143 std::ostringstream phero_str;
144 phero_str <<
"getCurrentPhaseElapsed()=" <<
time2string(elapsed) <<
" isThresholdPassed()=" << thresholdPassed <<
" countVehicles()=" << vehicleCount;
145 WRITE_MESSAGE(
"MSSOTLPolicy::decideNextPhase: " + phero_str.str());
147 if (
canRelease(elapsed, thresholdPassed, pushButtonPressed, stage, vehicleCount)) {
148 return currentPhaseIndex + 1;
152 return currentPhaseIndex;
static SUMOReal _2SUMOReal(const E *const data)
converts a char-type array into the SUMOReal value described by it
static SUMOReal rand()
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)
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.
SUMOReal computeDesirability(SUMOReal vehInMeasure, SUMOReal vehOutMeasure, SUMOReal vehInDispersionMeasure, SUMOReal vehOutDispersionMeasure)
Computes the desirability of this policy, necessary when used in combination with an high level polic...
MSSOTLPolicy(std::string name, const std::map< std::string, std::string > ¶meters)
Simple constructor.
SUMOReal theta_sensitivity
The sensitivity of this policy.
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.
virtual SUMOReal computeDesirability(SUMOReal vehInMeasure, SUMOReal vehOutMeasure)=0
Calculates the desirability of the policy.
#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...