bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
softmax_policy.h
Go to the documentation of this file.
1#ifndef SOFTMAX_POLICY_H
2#define SOFTMAX_POLICY_H
3
7
8namespace bitrl
9{
10namespace rl
11{
12namespace policies
13{
14
19{
20 public:
25
30
34 template <typename MatType>
35 output_type operator()(const MatType &q_map, uint_t state_idx) const;
36
42 template <typename VecTp> output_type operator()(const VecTp &q_map) const;
43
48 void on_episode(uint_t) noexcept {}
49
53 void reset() noexcept {}
54
55 private:
59 real_t tau_;
60
61 MaxTabularPolicy max_policy_;
62};
63
65
66template <typename VecTp>
68{
69
70 auto softmax_vec = maths::softmax_vec(q_map.begin(), q_map.end(), tau_);
71 return max_policy_.get_action(softmax_vec);
72}
73
74} // namespace policies
75} // namespace rl
76} // namespace bitrl
77
78#endif // SOFTMAX_POLICY_H
class MaxTabularPolicy
Definition max_tabular_policy.h:33
output_type operator()(const MatType &q_map, uint_t state_idx) const
operator(). Given a
uint_t output_type
The output type of operator().
Definition softmax_policy.h:24
MaxTabularSoftmaxPolicy(real_t tau=1.0)
Constructor.
Definition softmax_policy.h:64
void reset() noexcept
Reset the policy.
Definition softmax_policy.h:53
void on_episode(uint_t) noexcept
any actions the policy should perform on the given episode index
Definition softmax_policy.h:48
std::vector< T > softmax_vec(const std::vector< T > &vec, real_t tau=1.0)
applies softmax operation to the elements of the vector and returns a vector with the result
Definition vector_math.h:313
Definition policy_stochastic_adaptor.h:21
Definition dummy_agent.h:9
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20