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.org/sumo
3 // Copyright (C) 2013-2020 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 //#define SWARM_DEBUG
29 #include <sstream>
30 #include <cmath>
31 #include <utility>
32 #include <vector>
34 #include "MSPhaseDefinition.h"
36 
38 protected:
39  void init(std::string prefix, const Parameterised* parameterised);
40 
41  bool pushButtonLogic(SUMOTime elapsed, bool pushButtonPressed, const MSPhaseDefinition* stage);
42 
44  std::string m_prefix;
45 };
46 
47 class SigmoidLogic {
48 protected:
49  void init(std::string prefix, const Parameterised* parameterised);
50 
51  bool sigmoidLogic(SUMOTime elapsed, const MSPhaseDefinition* stage, int vehicleCount);
52 
54  double m_k;
55  std::string m_prefix;
56 };
57 
63 class MSSOTLPolicy: public Parameterised {
64 private:
65 
73  std::string myName;
79 
80 protected:
81  virtual void init() {}
82 
83 public:
88  MSSOTLPolicy(std::string name,
89  const std::map<std::string, std::string>& parameters);
94  MSSOTLPolicy(std::string name, MSSOTLPolicyDesirability* desirabilityAlgorithm);
100  MSSOTLPolicy(std::string name, MSSOTLPolicyDesirability* desirabilityAlgorithm,
101  const std::map<std::string, std::string>& parameters);
102  virtual ~MSSOTLPolicy();
103 
104  virtual bool canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed,
105  const MSPhaseDefinition* stage, int vehicleCount) = 0;
106  virtual int decideNextPhase(SUMOTime elapsed, const MSPhaseDefinition* stage,
107  int currentPhaseIndex, int phaseMaxCTS, bool thresholdPassed, bool pushButtonPressed,
108  int vehicleCount);
109 
110  virtual double getThetaSensitivity() {
111  return theta_sensitivity;
112  }
113  virtual void setThetaSensitivity(double val) {
114  theta_sensitivity = val;
115  }
116  std::string getName() {
117  return myName;
118  }
121  }
125  double computeDesirability(double vehInMeasure, double vehOutMeasure, double vehInDispersionMeasure, double vehOutDispersionMeasure);
126 
127  double computeDesirability(double vehInMeasure, double vehOutMeasure);
128 };
129 
long long int SUMOTime
Definition: SUMOTime.h:31
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:63
std::string myName
The name of the policy.
Definition: MSSOTLPolicy.h:73
MSSOTLPolicyDesirability * myDesirabilityAlgorithm
A pointer to the policy desirability object.\nIt's an optional component related to the computeDesira...
Definition: MSSOTLPolicy.h:78
virtual void setThetaSensitivity(double val)
Definition: MSSOTLPolicy.h:113
MSSOTLPolicy(std::string name, const std::map< std::string, std::string > &parameters)
Simple constructor.
virtual ~MSSOTLPolicy()
double theta_sensitivity
The sensitivity of this policy.
Definition: MSSOTLPolicy.h:69
MSSOTLPolicyDesirability * getDesirabilityAlgorithm()
Definition: MSSOTLPolicy.h:119
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:110
virtual void init()
Definition: MSSOTLPolicy.h:81
std::string getName()
Definition: MSSOTLPolicy.h:116
An upper class for objects with additional parameters.
Definition: Parameterised.h:39
std::string m_prefix
Definition: MSSOTLPolicy.h:44
double m_pushButtonScaleFactor
Definition: MSSOTLPolicy.h:43
bool pushButtonLogic(SUMOTime elapsed, bool pushButtonPressed, const MSPhaseDefinition *stage)
void init(std::string prefix, const Parameterised *parameterised)
bool m_useSigmoid
Definition: MSSOTLPolicy.h:53
void init(std::string prefix, const Parameterised *parameterised)
std::string m_prefix
Definition: MSSOTLPolicy.h:55
bool sigmoidLogic(SUMOTime elapsed, const MSPhaseDefinition *stage, int vehicleCount)