AIToolbox
A library that offers tools for AI problem solving.
QSoftmaxPolicy.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_MDP_Q_SOFTMAX_POLICY_HEADER_FILE
2 #define AI_TOOLBOX_MDP_Q_SOFTMAX_POLICY_HEADER_FILE
3 
6 
7 namespace AIToolbox::MDP {
22  public:
32  QSoftmaxPolicy(const QFunction & q, double temperature = 1.0);
33 
52  virtual size_t sampleAction(const size_t & s) const override;
53 
64  virtual double getActionProbability(const size_t & s, const size_t & a) const override;
65 
77  virtual Matrix2D getPolicy() const override;
78 
95  void setTemperature(double t);
96 
102  double getTemperature() const;
103 
104  private:
105  double temperature_;
106  // To avoid reallocating a vector every time for sampling.
107  mutable std::vector<size_t> bestActions_;
108  mutable Vector vbuffer_;
109  };
110 }
111 
112 #endif
QPolicyInterface.hpp
AIToolbox::MDP::QSoftmaxPolicy::QSoftmaxPolicy
QSoftmaxPolicy(const QFunction &q, double temperature=1.0)
Basic constructor.
AIToolbox::MDP::QPolicyInterface
This class is an interface to specify a policy through a QFunction.
Definition: QPolicyInterface.hpp:20
AIToolbox::MDP::QFunction
Matrix2D QFunction
Definition: Types.hpp:52
AIToolbox::Matrix2D
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor|Eigen::AutoAlign > Matrix2D
Definition: Types.hpp:18
AIToolbox::Vector
Eigen::Matrix< double, Eigen::Dynamic, 1 > Vector
Definition: Types.hpp:16
AIToolbox::MDP::QSoftmaxPolicy::setTemperature
void setTemperature(double t)
This function sets the temperature parameter.
AIToolbox::MDP
Definition: DoubleQLearning.hpp:10
AIToolbox::MDP::QSoftmaxPolicy::getActionProbability
virtual double getActionProbability(const size_t &s, const size_t &a) const override
This function returns the probability of taking the specified action in the specified state.
AIToolbox::MDP::QSoftmaxPolicy
This class implements a softmax policy through a QFunction.
Definition: QSoftmaxPolicy.hpp:21
AIToolbox::MDP::QSoftmaxPolicy::sampleAction
virtual size_t sampleAction(const size_t &s) const override
This function chooses an action for state s with probability dependent on value.
AIToolbox::MDP::QSoftmaxPolicy::getPolicy
virtual Matrix2D getPolicy() const override
This function returns a matrix containing all probabilities of the policy.
QGreedyPolicy.hpp
AIToolbox::MDP::QSoftmaxPolicy::getTemperature
double getTemperature() const
This function will return the currently set temperature parameter.