AIToolbox
A library that offers tools for AI problem solving.
HystereticQLearning.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_MDP_HYSTERETIC_QLEARNING_HEADER_FILE
2 #define AI_TOOLBOX_MDP_HYSTERETIC_QLEARNING_HEADER_FILE
3 
4 #include <stddef.h>
5 
9 
10 namespace AIToolbox::MDP {
49  public:
68  HystereticQLearning(size_t S, size_t A, double discount = 1.0, double alpha = 0.1, double beta = 0.01);
69 
91  template <IsGenerativeModel M>
92  HystereticQLearning(const M& model, double alpha = 0.1, double beta = 0.01);
93 
106  void setPositiveLearningRate(double a);
107 
113  double getPositiveLearningRate() const;
114 
129  void setNegativeLearningRate(double b);
130 
136  double getNegativeLearningRate() const;
137 
150  void setDiscount(double d);
151 
157  double getDiscount() const;
158 
171  void stepUpdateQ(size_t s, size_t a, size_t s1, double rew);
172 
178  size_t getS() const;
179 
185  size_t getA() const;
186 
195  const QFunction & getQFunction() const;
196 
197  private:
198  size_t S, A;
199  double alpha_, beta_;
200  double discount_;
201 
202  QFunction q_;
203  };
204 
205  template <IsGenerativeModel M>
206  HystereticQLearning::HystereticQLearning(const M& model, const double alpha, const double beta) :
207  HystereticQLearning(model.getS(), model.getA(), model.getDiscount(), alpha, beta) {}
208 
209 }
210 #endif
AIToolbox::MDP::HystereticQLearning::setNegativeLearningRate
void setNegativeLearningRate(double b)
This function sets the learning rate parameter for negative updates.
AIToolbox::MDP::HystereticQLearning::stepUpdateQ
void stepUpdateQ(size_t s, size_t a, size_t s1, double rew)
This function updates the internal QFunction using the discount set during construction.
AIToolbox::MDP::QFunction
Matrix2D QFunction
Definition: Types.hpp:52
AIToolbox::MDP::HystereticQLearning
This class represents the Hysteretic QLearning algorithm.
Definition: HystereticQLearning.hpp:48
AIToolbox::MDP::HystereticQLearning::getS
size_t getS() const
This function returns the number of states on which HystereticQLearning is working.
AIToolbox::MDP::HystereticQLearning::getA
size_t getA() const
This function returns the number of actions on which HystereticQLearning is working.
AIToolbox::MDP
Definition: DoubleQLearning.hpp:10
AIToolbox::MDP::HystereticQLearning::getQFunction
const QFunction & getQFunction() const
This function returns a reference to the internal QFunction.
Utils.hpp
AIToolbox::MDP::HystereticQLearning::getDiscount
double getDiscount() const
This function returns the currently set discount parameter.
AIToolbox::MDP::HystereticQLearning::getPositiveLearningRate
double getPositiveLearningRate() const
This function will return the currently set learning rate parameter for positive updates.
AIToolbox::MDP::HystereticQLearning::getNegativeLearningRate
double getNegativeLearningRate() const
This function will return the currently set learning rate parameter for negative updates.
AIToolbox::MDP::HystereticQLearning::setDiscount
void setDiscount(double d)
This function sets the new discount parameter.
Types.hpp
TypeTraits.hpp
AIToolbox::MDP::HystereticQLearning::setPositiveLearningRate
void setPositiveLearningRate(double a)
This function sets the learning rate parameter for positive updates.
AIToolbox::MDP::HystereticQLearning::HystereticQLearning
HystereticQLearning(size_t S, size_t A, double discount=1.0, double alpha=0.1, double beta=0.01)
Basic constructor.