bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
bitrl::envs::gdrl::GymWalk< state_size > Class Template Referencefinal

#include <gym_walk.h>

Inheritance diagram for bitrl::envs::gdrl::GymWalk< state_size >:
Collaboration diagram for bitrl::envs::gdrl::GymWalk< state_size >:

Public Types

typedef EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 1, 0, 0 > > base_type
 
typedef base_type::time_step_type time_step_type
 
typedef base_type::state_space_type state_space_type
 
typedef base_type::action_space_type action_space_type
 
typedef base_type::action_type action_type
 
typedef base_type::state_type state_type
 
typedef std::vector< std::tuple< real_t, uint_t, real_t, bool > > dynamics_t
 
- Public Types inherited from bitrl::envs::EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 1, 0, 0 > >
typedef TimeStep< uint_ttime_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 Types inherited from bitrl::envs::ScalarDiscreteEnv< state_size, 1, 0, 0 >
typedef ScalarDiscreteSpace< state_start, state_end > state_space
 item_t
 
typedef state_space::space_item_type state_type
 the State type
 
typedef ScalarDiscreteSpace< action_start, action_end > action_space
 the action space type
 
typedef action_space::space_item_type action_type
 the Action type
 

Public Member Functions

 GymWalk (network::RESTRLEnvClient &api_server)
 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
 Construct the environment instance.
 
bool is_alive () const
 
virtual void close () override final
 Close and release any acquired environment resources.
 
virtual time_step_type step (const action_type &action) override final
 
virtual time_step_type reset () override final
 Reset the environment to an initial state using the reset options specified during make.
 
uint_t n_states () const noexcept
 
uint_t n_actions () const noexcept
 
dynamics_t p (uint_t sidx, uint_t aidx) const
 
std::string get_url () const
 Get the full URL for this environment endpoint on the server.
 
uint_t n_copies () const
 
- Public Member Functions inherited from bitrl::envs::EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 1, 0, 0 > >
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 Attributes

static const std::string name = "GymWalk"
 
static const std::string URI = "/gdrl/gym-walk-env"
 
- Static Public Attributes inherited from bitrl::envs::EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 1, 0, 0 > >
static const uint_t DEFAULT_ENV_SEED
 Default seed used in reset() if none provided.
 
- Static Public Attributes inherited from bitrl::envs::ScalarDiscreteEnv< state_size, 1, 0, 0 >
static constexpr uint_t STATE_SPACE_SIZE
 state space size
 
static constexpr uint_t ACTION_SPACE_SIZE
 action space size
 

Additional Inherited Members

- Static Public Member Functions inherited from bitrl::envs::ScalarDiscreteEnv< state_size, 1, 0, 0 >
static action_type sample_action ()
 sample
 
static action_type sample_action (uint_t seed)
 sample
 
static std::vector< action_typesample_action (uint_t seed, uint_t size)
 
- Protected Member Functions inherited from bitrl::envs::EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 1, 0, 0 > >
 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

template<uint_t state_size>
class bitrl::envs::gdrl::GymWalk< state_size >

GymWalk. Interface for the GymWalk environment

Member Typedef Documentation

◆ action_space_type

template<uint_t state_size>
typedef base_type::action_space_type bitrl::envs::gdrl::GymWalk< state_size >::action_space_type

◆ action_type

template<uint_t state_size>
typedef base_type::action_type bitrl::envs::gdrl::GymWalk< state_size >::action_type

◆ base_type

template<uint_t state_size>
typedef EnvBase<TimeStep<uint_t>, ScalarDiscreteEnv<state_size, 1, 0, 0> > bitrl::envs::gdrl::GymWalk< state_size >::base_type

◆ dynamics_t

template<uint_t state_size>
typedef std::vector<std::tuple<real_t, uint_t, real_t, bool> > bitrl::envs::gdrl::GymWalk< state_size >::dynamics_t

◆ state_space_type

template<uint_t state_size>
typedef base_type::state_space_type bitrl::envs::gdrl::GymWalk< state_size >::state_space_type

◆ state_type

template<uint_t state_size>
typedef base_type::state_type bitrl::envs::gdrl::GymWalk< state_size >::state_type

◆ time_step_type

template<uint_t state_size>
typedef base_type::time_step_type bitrl::envs::gdrl::GymWalk< state_size >::time_step_type

Constructor & Destructor Documentation

◆ GymWalk()

template<uint_t state_size>
bitrl::envs::gdrl::GymWalk< state_size >::GymWalk ( network::RESTRLEnvClient api_server)

Constructor.

Member Function Documentation

◆ close()

template<uint_t state_size>
void bitrl::envs::gdrl::GymWalk< state_size >::close ( )
finaloverridevirtual

Close and release any acquired environment resources.

Implements bitrl::envs::EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 1, 0, 0 > >.

◆ get_url()

template<uint_t state_size>
std::string bitrl::envs::gdrl::GymWalk< state_size >::get_url ( ) const
inline

Get the full URL for this environment endpoint on the server.

Returns
Environment URL string.

◆ is_alive()

template<uint_t state_size>
bool bitrl::envs::gdrl::GymWalk< state_size >::is_alive ( ) const

◆ make()

template<uint_t state_size>
void bitrl::envs::gdrl::GymWalk< state_size >::make ( const std::string &  version,
const std::unordered_map< std::string, std::any > &  make_options,
const std::unordered_map< std::string, std::any > &  reset_options 
)
finaloverridevirtual

Construct the environment instance.

Parameters
versionVersion string used to control environment variant
make_optionsKey-value configuration options for environment creation.
reset_optionsKey-value configuration how the environment should be reset
Note
Derived classes should use set_version_() and set_make_options_() internally. They may store selected options for later use.

Implements bitrl::envs::EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 1, 0, 0 > >.

◆ n_actions()

template<uint_t state_size>
uint_t bitrl::envs::gdrl::GymWalk< state_size >::n_actions ( ) const
inlinenoexcept

◆ n_copies()

template<uint_t state_size>
uint_t bitrl::envs::gdrl::GymWalk< state_size >::n_copies ( ) const

Get the number of copies on the server for this environment

Returns

◆ n_states()

template<uint_t state_size>
uint_t bitrl::envs::gdrl::GymWalk< state_size >::n_states ( ) const
inlinenoexcept

◆ p()

template<uint_t state_size>
GymWalk< state_size >::dynamics_t bitrl::envs::gdrl::GymWalk< state_size >::p ( uint_t  sidx,
uint_t  aidx 
) const

◆ reset()

template<uint_t state_size>
GymWalk< state_size >::time_step_type bitrl::envs::gdrl::GymWalk< state_size >::reset ( )
finaloverridevirtual

Reset the environment to an initial state using the reset options specified during make.

Returns
Initial time step after reset

Implements bitrl::envs::EnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_size, 1, 0, 0 > >.

◆ step()

template<uint_t state_size>
GymWalk< state_size >::time_step_type bitrl::envs::gdrl::GymWalk< state_size >::step ( const action_type action)
finaloverridevirtual

Member Data Documentation

◆ name

template<uint_t state_size>
const std::string bitrl::envs::gdrl::GymWalk< state_size >::name = "GymWalk"
static

◆ URI

template<uint_t state_size>
const std::string bitrl::envs::gdrl::GymWalk< state_size >::URI = "/gdrl/gym-walk-env"
static

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