bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitrl::rl::policies::MaxTabularPolicy Class Reference

class MaxTabularPolicy More...

#include <max_tabular_policy.h>

Public Types

typedef uint_t output_type
 The output type of operator().
typedef uint_t state_type
typedef uint_t action_type

Public Member Functions

 MaxTabularPolicy ()=default
 Constructor.
void on_episode (uint_t) noexcept
 any actions the policy should perform on the given episode index
void reset () noexcept
 Reset the policy.
action_type on_state (state_type s) const
 Get the action from the given state.
void save (const std::string &filename) const
 Save the state -> action map in a CSV file;.
void load (const std::string &filename)
 Load the state -> action map from a CSV file that save() wrote: a state and its action per row, and lines that start with # ignored. The states must be 0, 1, 2, ... in order.
uint_t n_states () const noexcept
 The number of states the policy has an action for.
template<typename VecTp>
MaxTabularPolicy::action_type get_action (const VecTp &vec)

Static Public Member Functions

template<typename MatType>
static output_type get_action (const MatType &q_map, uint_t state_idx)
 get_action. Given a
template<typename VecTp>
static output_type get_action (const VecTp &q_map)
 get_action. Given a vector always returns the position of the maximum occuring element. If the given vector is empty returns CubeAIConsts::invalid_size_type
static output_type get_action (const torch_tensor_t &vec)
 get_action. Given a vector always returns the position of the maximum occuring element. If the given vector is empty returns CubeAIConsts::invalid_size_type

Friends

struct MaxTabularPolicyBuilder
 Make friends so the builder access private members.

Detailed Description

Member Typedef Documentation

◆ action_type

◆ output_type

The output type of operator().

◆ state_type

Constructor & Destructor Documentation

◆ MaxTabularPolicy()

bitrl::rl::policies::MaxTabularPolicy::MaxTabularPolicy ( )
default

Constructor.

Member Function Documentation

◆ get_action() [1/4]

template<typename MatType>
output_type bitrl::rl::policies::MaxTabularPolicy::get_action ( const MatType & q_map,
uint_t state_idx )
static

get_action. Given a

◆ get_action() [2/4]

uint_t bitrl::rl::policies::MaxTabularPolicy::get_action ( const torch_tensor_t & vec)
inlinestatic

get_action. Given a vector always returns the position of the maximum occuring element. If the given vector is empty returns CubeAIConsts::invalid_size_type

◆ get_action() [3/4]

template<typename VecTp>
output_type bitrl::rl::policies::MaxTabularPolicy::get_action ( const VecTp & q_map)
static

get_action. Given a vector always returns the position of the maximum occuring element. If the given vector is empty returns CubeAIConsts::invalid_size_type

◆ get_action() [4/4]

template<typename VecTp>
MaxTabularPolicy::action_type bitrl::rl::policies::MaxTabularPolicy::get_action ( const VecTp & vec)

◆ load()

void bitrl::rl::policies::MaxTabularPolicy::load ( const std::string & filename)

Load the state -> action map from a CSV file that save() wrote: a state and its action per row, and lines that start with # ignored. The states must be 0, 1, 2, ... in order.

Exceptions
std::runtime_errorif the file cannot be read or is not like that

◆ n_states()

uint_t bitrl::rl::policies::MaxTabularPolicy::n_states ( ) const
inlinenoexcept

The number of states the policy has an action for.

◆ on_episode()

void bitrl::rl::policies::MaxTabularPolicy::on_episode ( uint_t )
inlinenoexcept

any actions the policy should perform on the given episode index

◆ on_state()

action_type bitrl::rl::policies::MaxTabularPolicy::on_state ( state_type s) const
inline

Get the action from the given state.

◆ reset()

void bitrl::rl::policies::MaxTabularPolicy::reset ( )
inlinenoexcept

Reset the policy.

◆ save()

void bitrl::rl::policies::MaxTabularPolicy::save ( const std::string & filename) const

Save the state -> action map in a CSV file;.

◆ MaxTabularPolicyBuilder

friend struct MaxTabularPolicyBuilder
friend

Make friends so the builder access private members.


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