bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
bitrl::envs::bandits::MultiArmedBandits Class Referencefinal

#include <multi_armed_bandits.h>

Inheritance diagram for bitrl::envs::bandits::MultiArmedBandits:
Collaboration diagram for bitrl::envs::bandits::MultiArmedBandits:

Public Types

typedef EnvBase< TimeStep< bool >, MultiArmedBanditsSpacebase_type
 The base type.
 
typedef base_type::time_step_type time_step_type
 The time step type we return every time a step in the environment is performed.
 
typedef base_type::state_space_type state_space_type
 The type describing the state space for the environment.
 
typedef base_type::action_space_type action_space_type
 The type of the action space for the environment.
 
typedef base_type::action_type action_type
 The type of the action to be undertaken in the environment.
 
typedef base_type::state_type state_type
 The type of the action to be undertaken in the environment.
 
- Public Types inherited from bitrl::envs::EnvBase< TimeStep< bool >, MultiArmedBanditsSpace >
typedef TimeStep< bool > time_step_type
 Alias for the type returned when stepping the environment.
 
typedef SpaceType::state_space state_space_type
 Type describing the environment state space.
 
typedef SpaceType::state_type state_type
 Type describing an individual state.
 
typedef SpaceType::action_space action_space_type
 Type describing the environment action space.
 
typedef SpaceType::action_type action_type
 Type representing an individual action.
 

Public Member Functions

 MultiArmedBandits ()
 MultiArmedBandits Constructor.
 
virtual void make (const std::string &version, const std::unordered_map< std::string, std::any > &options, const std::unordered_map< std::string, std::any > &reset_options) override final
 make. Builds the environment.
 
virtual void close () override final
 close the environment
 
virtual time_step_type reset () override final
 Reset the environment.
 
virtual time_step_type step (const action_type &action) override final
 step in the environment by performing the given action
 
uint_t n_actions () const noexcept
 Return the number of actions.
 
real_t success_reward () const noexcept
 Returns the sucees reward.
 
real_t fail_reward () const noexcept
 Returns the fail reward.
 
- Public Member Functions inherited from bitrl::envs::EnvBase< TimeStep< bool >, MultiArmedBanditsSpace >
virtual ~EnvBase ()=default
 Virtual destructor.
 
virtual time_step_type step (const action_type &action)=0
 Perform one step in the environment using an action.
 
const std::unordered_map< std::string, std::any > & make_options () const noexcept
 Access the configuration options provided to make().
 
const std::unordered_map< std::string, std::any > & reset_options () const noexcept
 Access the configuration options provided to make().
 
read_option (const std::string &op_name) const
 Read a specific make() option and cast it to the requested type.
 
std::string idx () const noexcept
 Get the id identifying this environment within a simulation batch. The id is valid only if make has been called.
 
bool is_created () const noexcept
 Check if make() has successfully initialized the environment.
 
std::string env_name () const noexcept
 Get the name of this environment instance.
 
std::string version () const noexcept
 Get the environment version set during make().
 

Static Public Member Functions

static uint_t n_copies ()
 

Static Public Attributes

static const std::string name = "MultiArmedBandits"
 name
 
- Static Public Attributes inherited from bitrl::envs::EnvBase< TimeStep< bool >, MultiArmedBanditsSpace >
static const uint_t DEFAULT_ENV_SEED
 Default seed used in reset() if none provided.
 

Additional Inherited Members

- Protected Member Functions inherited from bitrl::envs::EnvBase< TimeStep< bool >, MultiArmedBanditsSpace >
 EnvBase (const std::string &idx=bitrl::consts::INVALID_STR, const std::string &name=bitrl::consts::INVALID_STR)
 Constructor (protected — for subclassing only).
 
 EnvBase (const EnvBase &)
 Copy constructor.
 
void set_version_ (const std::string &version) noexcept
 Set internal version string.
 
void set_idx_ (const std::string &idx) noexcept
 Set the id of the environment.
 
void set_make_options_ (const std::unordered_map< std::string, std::any > &options) noexcept
 Store options for future access.
 
void set_reset_options_ (const std::unordered_map< std::string, std::any > &options) noexcept
 Store reset options for future access.
 
void invalidate_is_created_flag_ () noexcept
 Mark environment as not created.
 
void make_created_ () noexcept
 Mark environment creation as successful.
 
time_step_typeget_current_time_step_ () noexcept
 Mutable access to the current time step.
 
const time_step_typeget_current_time_step_ () const noexcept
 Read-only access to the current time step.
 

Detailed Description

class MultiArmedBandits. Environment for simulating armed-bandits The bandits are represented as Bernoulli distribution. At each step only one bandit can be executed

Member Typedef Documentation

◆ action_space_type

The type of the action space for the environment.

◆ action_type

The type of the action to be undertaken in the environment.

◆ base_type

◆ state_space_type

The type describing the state space for the environment.

◆ state_type

The type of the action to be undertaken in the environment.

◆ time_step_type

The time step type we return every time a step in the environment is performed.

Constructor & Destructor Documentation

◆ MultiArmedBandits()

bitrl::envs::bandits::MultiArmedBandits::MultiArmedBandits ( )

MultiArmedBandits Constructor.

Member Function Documentation

◆ close()

void bitrl::envs::bandits::MultiArmedBandits::close ( )
finaloverridevirtual

◆ fail_reward()

real_t bitrl::envs::bandits::MultiArmedBandits::fail_reward ( ) const
inlinenoexcept

Returns the fail reward.

◆ make()

void bitrl::envs::bandits::MultiArmedBandits::make ( const std::string &  version,
const std::unordered_map< std::string, std::any > &  options,
const std::unordered_map< std::string, std::any > &  reset_options 
)
finaloverridevirtual

make. Builds the environment.

Parameters
version.the version of the environment to build
options.Options to use for building the environment. Concrete classes may choose to hold a copy

Implements bitrl::envs::EnvBase< TimeStep< bool >, MultiArmedBanditsSpace >.

◆ n_actions()

uint_t bitrl::envs::bandits::MultiArmedBandits::n_actions ( ) const
inlinenoexcept

Return the number of actions.

◆ n_copies()

static uint_t bitrl::envs::bandits::MultiArmedBandits::n_copies ( )
inlinestatic

Get the number of copies of this class

Returns

◆ reset()

MultiArmedBandits::time_step_type bitrl::envs::bandits::MultiArmedBandits::reset ( )
finaloverridevirtual

Reset the environment.

Parameters
seed.The seed to use for resetting the environment
options.Options to use for resetting the environment.

Implements bitrl::envs::EnvBase< TimeStep< bool >, MultiArmedBanditsSpace >.

◆ step()

MultiArmedBandits::time_step_type bitrl::envs::bandits::MultiArmedBandits::step ( const action_type action)
finaloverridevirtual

step in the environment by performing the given action

Parameters
action.The action to execute in the environment
Returns
An instance of time_step_type

◆ success_reward()

real_t bitrl::envs::bandits::MultiArmedBandits::success_reward ( ) const
inlinenoexcept

Returns the sucees reward.

Member Data Documentation

◆ name

const std::string bitrl::envs::bandits::MultiArmedBandits::name = "MultiArmedBandits"
static

name


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