bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy > Class Template Reference

Monte Carlo tree search, with UCB to pick the children (UCT). More...

#include <mc_tree_search_solver.h>

Public Types

typedef EnvTp env_type
typedef env_type::action_type action_type
typedef env_type::state_type state_type
typedef MCTSNodeBase< action_type, state_type > node_type

Public Member Functions

 MCTSSolver (const MCTSConfig &config, RolloutPolicy rollout_policy=RolloutPolicy())
action_type plan (const env_type &env)
 plan. Runs config().n_simulations simulations from copies of env and returns the action that is best from the state env is in. env is not changed
std::shared_ptr< const node_type > root () const noexcept
 The root of the tree of the last plan(), or null before the first.
const MCTSConfig & config () const noexcept

Detailed Description

template<mcts_env_concept EnvTp, typename RolloutPolicy = UniformRolloutPolicy>
class bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy >

Monte Carlo tree search, with UCB to pick the children (UCT).

MCTS plans from the state the environment is in. plan(env) grows a tree of action sequences from that state. Every simulation copies the environment and

  • walks down the tree, always to the child with the largest upper confidence bound, until it reaches a node with a child it has not tried;
  • adds that child, by taking its action;
  • goes on with the actions of the rollout policy until the episode ends or the simulation is max_depth steps deep;
  • adds to the score of every node on its path the reward of the step into the node and the discounted return that followed it. plan() then returns the action of the child of the root that was visited most. The environment the simulations run in can be a model of the world the agent acts in, as long as it is fast to copy and to step.

The rollout policy is called as policy(env, generator), with the environment of the simulation and the solver's random generator, and returns an action. Random actions, the default, need no knowledge of the problem; a policy that plays sensibly gives returns that say much more about the node the rollout starts from.

Member Typedef Documentation

◆ action_type

template<mcts_env_concept EnvTp, typename RolloutPolicy = UniformRolloutPolicy>
typedef env_type::action_type bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy >::action_type

◆ env_type

template<mcts_env_concept EnvTp, typename RolloutPolicy = UniformRolloutPolicy>
typedef EnvTp bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy >::env_type

◆ node_type

template<mcts_env_concept EnvTp, typename RolloutPolicy = UniformRolloutPolicy>
typedef MCTSNodeBase<action_type, state_type> bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy >::node_type

◆ state_type

template<mcts_env_concept EnvTp, typename RolloutPolicy = UniformRolloutPolicy>
typedef env_type::state_type bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy >::state_type

Constructor & Destructor Documentation

◆ MCTSSolver()

template<mcts_env_concept EnvTp, typename RolloutPolicy = UniformRolloutPolicy>
bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy >::MCTSSolver ( const MCTSConfig & config,
RolloutPolicy rollout_policy = RolloutPolicy() )
inlineexplicit

Member Function Documentation

◆ config()

template<mcts_env_concept EnvTp, typename RolloutPolicy = UniformRolloutPolicy>
const MCTSConfig & bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy >::config ( ) const
inlinenoexcept

◆ plan()

template<mcts_env_concept EnvTp, typename RolloutPolicy>
MCTSSolver< EnvTp, RolloutPolicy >::action_type bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy >::plan ( const env_type & env)

plan. Runs config().n_simulations simulations from copies of env and returns the action that is best from the state env is in. env is not changed

◆ root()

template<mcts_env_concept EnvTp, typename RolloutPolicy = UniformRolloutPolicy>
std::shared_ptr< const node_type > bitrl::rl::algos::mc::MCTSSolver< EnvTp, RolloutPolicy >::root ( ) const
inlinenoexcept

The root of the tree of the last plan(), or null before the first.


The documentation for this class was generated from the following file: