|
bitsim
Model, simulate, estimate and control robots in C++
|
Tabular expected SARSA, see Sutton and Barto, Reinforcement Learning: An Introduction, section 6.6. More...
#include <expected_sarsa.h>


Public Types | |
| typedef TDAlgoBase< EnvType >::env_type | env_type |
| typedef TDAlgoBase< EnvType >::action_type | action_type |
| typedef TDAlgoBase< EnvType >::state_type | state_type |
| typedef PolicyType | policy_type |
| Public Types inherited from bitrl::rl::algos::td::TDAlgoBase< EnvType > | |
| typedef EnvType | env_type |
| env_t | |
| typedef env_type::action_type | action_type |
| action_t | |
| typedef env_type::state_type | state_type |
| state_t | |
| Public Types inherited from bitrl::rl::algos::RLSolverBase< EnvType > | |
| typedef EnvType | env_type |
Public Member Functions | |
| ExpectedSarsaSolver (const ExpectedSarsaConfig &config, const PolicyType &policy) | |
| Constructor. | |
| virtual void | actions_before_training_begins (env_type &) |
| Sets every entry of the table to zero. | |
| virtual void | actions_after_training_ends (env_type &) |
| Saves the table if the configuration gives a path. | |
| virtual void | actions_before_episode_begins (env_type &, uint_t) |
| actions_before_training_episode | |
| virtual void | actions_after_episode_ends (env_type &, uint_t episode_idx, const EpisodeInfo &) |
| Lets the policy adjust itself, for example decay its epsilon. | |
| virtual EpisodeInfo | on_training_episode (env_type &, uint_t episode_idx) |
| Plays one episode and updates the table after every step. | |
| void | save (const std::string &filename) const |
| Writes the table to a CSV file, one row per state. | |
| bitrl::rl::policies::MaxTabularPolicy | build_policy () const |
| The greedy policy of the table. | |
| const DynMat< real_t > & | q_table () const noexcept |
| The value of every state and action. | |
| real_t | expected_value (const state_type &state) const |
| The value the policy expects at the given state: every action weighed with the probability the policy takes it. | |
| Public Member Functions inherited from bitrl::rl::algos::td::TDAlgoBase< EnvType > | |
| virtual | ~TDAlgoBase ()=default |
| Destructor. | |
| Public Member Functions inherited from bitrl::rl::algos::RLSolverBase< EnvType > | |
| virtual | ~RLSolverBase ()=default |
| Destructor. | |
Additional Inherited Members | |
| Protected Member Functions inherited from bitrl::rl::algos::td::TDAlgoBase< EnvType > | |
| TDAlgoBase ()=default | |
| DPAlgoBase. | |
| Protected Member Functions inherited from bitrl::rl::algos::RLSolverBase< EnvType > | |
| RLSolverBase ()=default | |
| Constructor. | |
Tabular expected SARSA, see Sutton and Barto, Reinforcement Learning: An Introduction, section 6.6.
SARSA moves Q(s, a) towards r + gamma Q(s', a'), with a' the action its policy takes next. Expected SARSA uses the value the policy expects at s' instead,
r + gamma sum_a pi(a | s') Q(s', a),
which does not depend on which action it happens to take, so its updates vary less. For an epsilon-greedy policy over n actions, pi(a | s') is epsilon / n for every action, plus 1 - epsilon for the greedy one. After a step that ends the episode the target is the reward alone.
| typedef TDAlgoBase<EnvType>::action_type bitrl::rl::algos::td::ExpectedSarsaSolver< EnvType, PolicyType >::action_type |
| typedef TDAlgoBase<EnvType>::env_type bitrl::rl::algos::td::ExpectedSarsaSolver< EnvType, PolicyType >::env_type |
| typedef PolicyType bitrl::rl::algos::td::ExpectedSarsaSolver< EnvType, PolicyType >::policy_type |
| typedef TDAlgoBase<EnvType>::state_type bitrl::rl::algos::td::ExpectedSarsaSolver< EnvType, PolicyType >::state_type |
| bitrl::rl::algos::td::ExpectedSarsaSolver< EnvType, PolicyType >::ExpectedSarsaSolver | ( | const ExpectedSarsaConfig & | config, |
| const PolicyType & | policy ) |
Constructor.
|
inlinevirtual |
Lets the policy adjust itself, for example decay its epsilon.
Reimplemented from bitrl::rl::algos::RLSolverBase< EnvType >.
|
virtual |
Saves the table if the configuration gives a path.
Implements bitrl::rl::algos::RLSolverBase< EnvType >.
|
inlinevirtual |
actions_before_training_episode
Reimplemented from bitrl::rl::algos::RLSolverBase< EnvType >.
|
virtual |
Sets every entry of the table to zero.
Implements bitrl::rl::algos::RLSolverBase< EnvType >.
| bitrl::rl::policies::MaxTabularPolicy bitrl::rl::algos::td::ExpectedSarsaSolver< EnvType, PolicyType >::build_policy | ( | ) | const |
The greedy policy of the table.
| real_t bitrl::rl::algos::td::ExpectedSarsaSolver< EnvType, PolicyType >::expected_value | ( | const state_type & | state | ) | const |
The value the policy expects at the given state: every action weighed with the probability the policy takes it.
|
virtual |
Plays one episode and updates the table after every step.
Implements bitrl::rl::algos::RLSolverBase< EnvType >.
|
inlinenoexcept |
The value of every state and action.
| void bitrl::rl::algos::td::ExpectedSarsaSolver< EnvType, PolicyType >::save | ( | const std::string & | filename | ) | const |
Writes the table to a CSV file, one row per state.