|
| | DoubleQLearning (const DoubleQLearningConfig config, const ActionSelector &selector) |
| | Constructor.
|
| virtual void | actions_before_training_begins (env_type &) |
| | Sets both tables to zero.
|
| virtual void | actions_after_training_ends (env_type &) |
| | Saves the tables if the configuration gives a path.
|
| virtual void | actions_before_episode_begins (env_type &, uint_t) |
| virtual void | actions_after_episode_ends (env_type &, uint_t episode_idx, const EpisodeInfo &) |
| | Lets the action selector adjust itself, for example decay its epsilon.
|
| virtual EpisodeInfo | on_training_episode (env_type &, uint_t episode_idx) |
| | Plays one episode and updates the tables after every step.
|
| void | save (std::string filename) const |
| | Writes the two tables to a CSV file, one row per state and table.
|
| const DynMat< real_t > & | q_table_1 () const noexcept |
| const DynMat< real_t > & | q_table_2 () const noexcept |
| virtual | ~TDAlgoBase ()=default |
| | Destructor.
|
| virtual | ~RLSolverBase ()=default |
| | Destructor.
|
| virtual void | actions_before_training_begins (env_type &)=0 |
| | actions_before_training_begins. Execute any actions the algorithm needs before starting the iterations
|
| virtual void | actions_after_training_ends (env_type &)=0 |
| | actions_after_training_ends. Actions to execute after the training iterations have finisehd
|
| virtual void | actions_before_episode_begins (env_type &, uint_t) |
| | actions_before_training_episode
|
| virtual void | actions_after_episode_ends (env_type &, uint_t, const EpisodeInfo &) |
| | actions_after_training_episode
|
| virtual EpisodeInfo | on_training_episode (env_type &, uint_t)=0 |
| | on_episode Do one on_episode of the algorithm
|
|
| typedef uint_t | index_type |
| typedef uint_t | state_type |
| typedef uint_t | action_type |
| typedef real_t | value_type |
| | TDAlgoBase ()=default |
| | DPAlgoBase.
|
| | RLSolverBase ()=default |
| | Constructor.
|
| void | initialize (const std::vector< index_type > &indices, action_type n_actions, real_t init_value) |
| | initialize
|
| void | initialize (state_type n_states, action_type n_actions, real_t init_value) |
| | initialize. Sizes both tables to n_states x n_actions and sets every entry to init_value
|
| template<int index> |
| value_type | get (const state_type &state, const action_type action) const |
| template<int index> |
| void | set (const state_type &state, const action_type action, const value_type value) |
| template<> |
| with_double_q_table_mixin< DynMat< real_t > >::value_type | get (const state_type &state, const action_type action) const |
| template<> |
| with_double_q_table_mixin< DynMat< real_t > >::value_type | get (const state_type &state, const action_type action) const |
| template<> |
| void | set (const state_type &state, const action_type action, const value_type value) |
| template<> |
| void | set (const state_type &state, const action_type action, const value_type value) |
| template<typename TableTp, typename StateTp> |
| static uint_t | max_action (const TableTp &q1_table, const TableTp &q2_table, const StateTp &state, uint_t n_actions) |
| | Returns the max action by averaging the state values from the two tables.
|
| template<typename TableTp, typename StateTp> |
| static uint_t | max_action (const TableTp &q1_table, const StateTp &state, uint_t n_actions) |
| | Returns the max action by averaging the state values from the two tables.
|
| DynMat< value_type > | q_table_1 |
| | q_table_1
|
| DynMat< value_type > | q_table_2 |
| | q_table_2
|
template<envs::discrete_world_concept EnvTp, typename ActionSelector>
class bitrl::rl::algos::td::DoubleQLearning< EnvTp, ActionSelector >
The class DoubleQLearning. Tabular double Q-learning, see van Hasselt, Double Q-learning, NIPS 2010.
Q-learning takes the value of the next state as the largest value in the same table it updates, which overestimates it. Double Q-learning keeps two tables. Every step a coin picks one of them to update; the action that is best in that table is valued with the other one. Actions are chosen with the sum of the two tables.
ActionSelector is called as selector(q_table_1, q_table_2, state) and returns an action, for example EpsilonDoubleQTableGreedyPolicy. It must also have adjust_on_episode(episode_idx).