Eclipse SUMO - Simulation of Urban MObility
MSSOTLPolicy.h
Go to the documentation of this file.
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 /****************************************************************************/
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>
32 #include "MSPhaseDefinition.h"
34 
36 protected:
37  void init(std::string prefix, const Parameterised* parameterised);
38 
39  bool pushButtonLogic(SUMOTime elapsed, bool pushButtonPressed, const MSPhaseDefinition* stage);
40 
42  std::string m_prefix;
43 };
44 
45 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 
52  double m_k;
53  std::string m_prefix;
54 };
55 
61 class MSSOTLPolicy: public Parameterised {
62 private:
63 
71  std::string myName;
77 
78 protected:
79  virtual void init() {}
80 
81 public:
86  MSSOTLPolicy(std::string name,
87  const Parameterised::Map& parameters);
92  MSSOTLPolicy(std::string name, MSSOTLPolicyDesirability* desirabilityAlgorithm);
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  virtual double getThetaSensitivity() {
109  return theta_sensitivity;
110  }
111  virtual void setThetaSensitivity(double val) {
112  theta_sensitivity = val;
113  }
114  std::string getName() {
115  return myName;
116  }
119  }
123  double computeDesirability(double vehInMeasure, double vehOutMeasure, double vehInDispersionMeasure, double vehOutDispersionMeasure);
124 
125  double computeDesirability(double vehInMeasure, double vehOutMeasure);
126 };
long long int SUMOTime
Definition: GUI.h:35
The definition of a single phase of a tls logic.
This class determines the desirability algorithm of a MSSOTLPolicy when used in combination with a hi...
Class for a low-level policy.
Definition: MSSOTLPolicy.h:61
std::string myName
The name of the policy.
Definition: MSSOTLPolicy.h:71
MSSOTLPolicyDesirability * myDesirabilityAlgorithm
A pointer to the policy desirability object.\nIt's an optional component related to the computeDesira...
Definition: MSSOTLPolicy.h:76
virtual void setThetaSensitivity(double val)
Definition: MSSOTLPolicy.h:111
virtual ~MSSOTLPolicy()
MSSOTLPolicy(std::string name, const Parameterised::Map &parameters)
Simple constructor.
double theta_sensitivity
The sensitivity of this policy.
Definition: MSSOTLPolicy.h:67
MSSOTLPolicyDesirability * getDesirabilityAlgorithm()
Definition: MSSOTLPolicy.h:117
virtual bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed, const MSPhaseDefinition *stage, int vehicleCount)=0
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...
virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition *stage, int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed, int vehicleCount)
virtual double getThetaSensitivity()
Definition: MSSOTLPolicy.h:108
virtual void init()
Definition: MSSOTLPolicy.h:79
std::string getName()
Definition: MSSOTLPolicy.h:114
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
std::string m_prefix
Definition: MSSOTLPolicy.h:42
double m_pushButtonScaleFactor
Definition: MSSOTLPolicy.h:41
bool pushButtonLogic(SUMOTime elapsed, bool pushButtonPressed, const MSPhaseDefinition *stage)
void init(std::string prefix, const Parameterised *parameterised)
bool m_useSigmoid
Definition: MSSOTLPolicy.h:51
void init(std::string prefix, const Parameterised *parameterised)
std::string m_prefix
Definition: MSSOTLPolicy.h:53
bool sigmoidLogic(SUMOTime elapsed, const MSPhaseDefinition *stage, int vehicleCount)