Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2013-2024 German Aerospace Center (DLR) and others. 4 : // This program and the accompanying materials are made available under the 5 : // terms of the Eclipse Public License 2.0 which is available at 6 : // https://www.eclipse.org/legal/epl-2.0/ 7 : // This Source Code may also be made available under the following Secondary 8 : // Licenses when the conditions for such availability set forth in the Eclipse 9 : // Public License 2.0 are satisfied: GNU General Public License, version 2 10 : // or later which is available at 11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 13 : /****************************************************************************/ 14 : /// @file MSSOTLPolicy.h 15 : /// @author Alessio Bonfietti 16 : /// @author Riccardo Belletti 17 : /// @author Anna Chiara Bellini 18 : /// @author Federico Caselli 19 : /// @date Jun 2013 20 : /// 21 : // The class for low-level policy 22 : /****************************************************************************/ 23 : 24 : #pragma once 25 : #include <config.h> 26 : 27 : #include <sstream> 28 : #include <cmath> 29 : #include <utility> 30 : #include <vector> 31 : #include <utils/common/Parameterised.h> 32 : #include "MSPhaseDefinition.h" 33 : #include "MSSOTLPolicyDesirability.h" 34 : 35 0 : class PushButtonLogic { 36 : protected: 37 : void init(std::string prefix, const Parameterised* parameterised); 38 : 39 : bool pushButtonLogic(SUMOTime elapsed, bool pushButtonPressed, const MSPhaseDefinition* stage); 40 : 41 : double m_pushButtonScaleFactor; 42 : std::string m_prefix; 43 : }; 44 : 45 0 : class SigmoidLogic { 46 : protected: 47 : void init(std::string prefix, const Parameterised* parameterised); 48 : 49 : bool sigmoidLogic(SUMOTime elapsed, const MSPhaseDefinition* stage, int vehicleCount); 50 : 51 : bool m_useSigmoid; 52 : double m_k; 53 : std::string m_prefix; 54 : }; 55 : 56 : /** 57 : * @class MSSOTLPolicy 58 : * @brief Class for a low-level policy. 59 : * 60 : */ 61 : class MSSOTLPolicy: public Parameterised { 62 : private: 63 : 64 : /** 65 : * \brief The sensitivity of this policy 66 : */ 67 : double theta_sensitivity; 68 : /** 69 : * \brief The name of the policy 70 : */ 71 : std::string myName; 72 : /** 73 : * \brief A pointer to the policy desirability object.\nIt's an optional component related to the computeDesirability() method and it's necessary 74 : * only when the policy is used in combination with an high level policy. 75 : */ 76 : MSSOTLPolicyDesirability* myDesirabilityAlgorithm; 77 : 78 : protected: 79 0 : virtual void init() {} 80 : 81 : public: 82 : /** @brief Simple constructor 83 : * @param[in] name The name of the policy 84 : * @param[in] parameters Parameters defined for the policy 85 : */ 86 : MSSOTLPolicy(std::string name, 87 : const Parameterised::Map& parameters); 88 : /** @brief Constructor when the policy is a low-level policy used by an high level policy 89 : * @param[in] name The name of the policy 90 : * @param[in] desirabilityAlgorithm The desirability algorithm to be used for this policy 91 : */ 92 : MSSOTLPolicy(std::string name, MSSOTLPolicyDesirability* desirabilityAlgorithm); 93 : /** @brief Constructor when the policy is a low-level policy used by an high level policy 94 : * @param[in] name The name of the policy 95 : * @param[in] desirabilityAlgorithm The desirability algorithm to be used for this policy 96 : * @param[in] parameters Parameters defined for the policy 97 : */ 98 : MSSOTLPolicy(std::string name, MSSOTLPolicyDesirability* desirabilityAlgorithm, 99 : const Parameterised::Map& parameters); 100 : virtual ~MSSOTLPolicy(); 101 : 102 : virtual bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, 103 : const MSPhaseDefinition* stage, int vehicleCount) = 0; 104 : virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition* stage, 105 : int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, 106 : int vehicleCount); 107 : 108 1288 : virtual double getThetaSensitivity() { 109 1288 : return theta_sensitivity; 110 : } 111 1128 : virtual void setThetaSensitivity(double val) { 112 1128 : theta_sensitivity = val; 113 1128 : } 114 : std::string getName() { 115 32080 : return myName; 116 : } 117 : MSSOTLPolicyDesirability* getDesirabilityAlgorithm() { 118 128 : return myDesirabilityAlgorithm; 119 : } 120 : /** 121 : * @brief Computes the desirability of this policy, necessary when used in combination with an high level policy. 122 : */ 123 : double computeDesirability(double vehInMeasure, double vehOutMeasure, double vehInDispersionMeasure, double vehOutDispersionMeasure); 124 : 125 : double computeDesirability(double vehInMeasure, double vehOutMeasure); 126 : };