|
bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
|
Base class interface for Reinforcement Learning environments. More...
#include <env_base.h>


Public Types | |
| typedef TimeStepType | 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 | |
| virtual | ~EnvBase ()=default |
| Virtual destructor. | |
| virtual void | 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)=0 |
| Construct the environment instance. | |
| virtual void | close ()=0 |
| Close and release any acquired environment resources. | |
| virtual time_step_type | reset ()=0 |
| Reset the environment to an initial state using the reset options specified during make. | |
| 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(). | |
| template<typename T > | |
| T | 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 uint_t | DEFAULT_ENV_SEED = 42 |
| Default seed used in reset() if none provided. | |
Protected Member Functions | |
| 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_type & | get_current_time_step_ () noexcept |
| Mutable access to the current time step. | |
| const time_step_type & | get_current_time_step_ () const noexcept |
| Read-only access to the current time step. | |
Base class interface for Reinforcement Learning environments.
This class defines the minimum API contract that any RL environment must implement. It exposes functionality for creating, resetting, and stepping through an environment, while tracking configuration such as version, options, and current state.
| TimeStepType | Type returned after each environment step |
| SpaceType | Environment's space interface type providing state and action space definitions |
| typedef SpaceType::action_space bitrl::envs::EnvBase< TimeStepType, SpaceType >::action_space_type |
Type describing the environment action space.
| typedef SpaceType::action_type bitrl::envs::EnvBase< TimeStepType, SpaceType >::action_type |
Type representing an individual action.
| typedef SpaceType::state_space bitrl::envs::EnvBase< TimeStepType, SpaceType >::state_space_type |
Type describing the environment state space.
| typedef SpaceType::state_type bitrl::envs::EnvBase< TimeStepType, SpaceType >::state_type |
Type describing an individual state.
| typedef TimeStepType bitrl::envs::EnvBase< TimeStepType, SpaceType >::time_step_type |
Alias for the type returned when stepping the environment.
|
virtualdefault |
Virtual destructor.
|
explicitprotected |
Constructor (protected — for subclassing only).
| cidx | Copy index used in multi-environment simulations |
| name | Name of the environment instance |
|
protected |
Copy constructor.
|
pure virtual |
Close and release any acquired environment resources.
Implemented in bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStepType, SpaceType >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousVectorActionEnv< 8, 2, real_t, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 3, 2, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 4, 2, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 6, 2, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 8, 4, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< uint_t > >, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStepType, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, bitrl::envs::gymnasium::GymnasiumEnvBase< VectorTimeStep< detail_::AcrobotVEnv::state_type >, detail_::AcrobotVEnv >, bitrl::envs::gymnasium::GymnasiumEnvBase< VectorTimeStepType, SpaceType >, bitrl::envs::connect2::Connect2, bitrl::envs::gdrl::GymWalk< state_size >, bitrl::envs::grid_world::Gridworld< side_size_ >, and bitrl::envs::bandits::MultiArmedBandits.
|
inlinenoexcept |
Get the name of this environment instance.
|
inlineprotectednoexcept |
Read-only access to the current time step.
|
inlineprotectednoexcept |
Mutable access to the current time step.
|
inlinenoexcept |
Get the id identifying this environment within a simulation batch. The id is valid only if make has been called.
|
inlineprotectednoexcept |
Mark environment as not created.
|
inlinenoexcept |
Check if make() has successfully initialized the environment.
|
pure virtual |
Construct the environment instance.
| version | Version string used to control environment variant |
| make_options | Key-value configuration options for environment creation. |
| reset_options | Key-value configuration how the environment should be reset |
Implemented in bitrl::envs::gymnasium::Taxi, bitrl::envs::gymnasium::Pendulum, bitrl::envs::gymnasium::AcrobotV, bitrl::envs::connect2::Connect2, bitrl::envs::gdrl::GymWalk< state_size >, bitrl::envs::grid_world::Gridworld< side_size_ >, bitrl::envs::gymnasium::lunar_lander_detail::_LunarLanderEnv< TimeStepType, SpaceType >, bitrl::envs::gymnasium::lunar_lander_detail::_LunarLanderEnv< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousVectorActionEnv< 8, 2, real_t, real_t > >, bitrl::envs::gymnasium::lunar_lander_detail::_LunarLanderEnv< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 8, 4, 0, real_t > >, bitrl::envs::gymnasium::Acrobot, bitrl::envs::gymnasium::CartPole, bitrl::envs::gymnasium::MountainCar, bitrl::envs::gymnasium::BlackJack, bitrl::envs::gymnasium::CliffWorld, bitrl::envs::gymnasium::FrozenLake< side_size >, bitrl::envs::bandits::MultiArmedBandits, bitrl::envs::gymnasium::GymnasiumVecEnvBase< VectorTimeStepType, SpaceType >, and bitrl::envs::gymnasium::GymnasiumVecEnvBase< VectorTimeStep< detail_::AcrobotVEnv::state_type >, detail_::AcrobotVEnv >.
|
inlineprotectednoexcept |
Mark environment creation as successful.
|
inlinenoexcept |
Access the configuration options provided to make().
| T EnvBase::read_option | ( | const std::string & | op_name | ) | const |
Read a specific make() option and cast it to the requested type.
| T | Expected data type |
| op_name | Key of the option to read |
| std::bad_any_cast | If stored type does not match T |
|
pure virtual |
Reset the environment to an initial state using the reset options specified during make.
Implemented in bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStepType, SpaceType >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousVectorActionEnv< 8, 2, real_t, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 3, 2, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 4, 2, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 6, 2, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 8, 4, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< uint_t > >, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStepType, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, bitrl::envs::gymnasium::GymnasiumEnvBase< VectorTimeStep< detail_::AcrobotVEnv::state_type >, detail_::AcrobotVEnv >, bitrl::envs::gymnasium::GymnasiumEnvBase< VectorTimeStepType, SpaceType >, bitrl::envs::connect2::Connect2, bitrl::envs::gdrl::GymWalk< state_size >, bitrl::envs::grid_world::Gridworld< side_size_ >, bitrl::envs::bandits::MultiArmedBandits, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStepType, SpaceType >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousVectorActionEnv< 8, 2, real_t, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 3, 2, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 4, 2, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 6, 2, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 8, 4, 0, real_t > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< std::vector< uint_t > >, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStep< uint_t >, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, bitrl::envs::gymnasium::GymnasiumEnvBase< TimeStepType, ScalarDiscreteEnv< state_end, action_end, 0, 0 > >, bitrl::envs::gymnasium::GymnasiumEnvBase< VectorTimeStep< detail_::AcrobotVEnv::state_type >, detail_::AcrobotVEnv >, and bitrl::envs::gymnasium::GymnasiumEnvBase< VectorTimeStepType, SpaceType >.
|
inlinenoexcept |
Access the configuration options provided to make().
|
inlineprotectednoexcept |
Set the id of the environment.
| idx |
|
inlineprotectednoexcept |
Store options for future access.
|
inlineprotectednoexcept |
Store reset options for future access.
|
inlineprotectednoexcept |
Set internal version string.
|
pure virtual |
Perform one step in the environment using an action.
| action | Action applied to the environment |
Implemented in bitrl::envs::gymnasium::lunar_lander_detail::_LunarLanderEnv< TimeStepType, SpaceType >, bitrl::envs::gymnasium::lunar_lander_detail::_LunarLanderEnv< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousVectorActionEnv< 8, 2, real_t, real_t > >, bitrl::envs::gymnasium::lunar_lander_detail::_LunarLanderEnv< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 8, 4, 0, real_t > >, and bitrl::envs::gymnasium::FrozenLake< side_size >.
|
inlinenoexcept |
Get the environment version set during make().
|
static |
Default seed used in reset() if none provided.