8#ifndef GYMNASIUM_VECTOR_ENV_BASE_H
9#define GYMNASIUM_VECTOR_ENV_BASE_H
11#include "bitrl/base/bitrl_config.h"
16#include "bitsim/extern/nlohmann/json/json.hpp"
31template <
typename VectorTimeStepType,
typename SpaceType>
68 const std::unordered_map<std::string, std::any> &options,
69 const std::unordered_map<std::string, std::any> &
reset_options) = 0;
101 bool reset_if_any_done_{
false};
104template <
typename VectorTimeStepType,
typename SpaceType>
111template <
typename VectorTimeStepType,
typename SpaceType>
114 :
GymnasiumEnvBase<VectorTimeStepType, SpaceType>(other), n_envs_(other.n_envs_),
115 reset_if_any_done_(other.reset_if_any_done_)
119template <
typename VectorTimeStepType,
typename SpaceType>
121 const std::string &
version,
const std::unordered_map<std::string, std::any> &options,
122 const std::unordered_map<std::string, std::any> &
reset_options)
125 auto reset_if_any_done_itr = options.find(
"reset_if_any_done");
127 if (reset_if_any_done_itr != options.end())
129 reset_if_any_done_ = std::any_cast<bool>(reset_if_any_done_itr->second);
132 auto n_envs_itr = options.find(
"num_envs");
134 if (n_envs_itr != options.end())
136 n_envs_ = std::any_cast<uint_t>(n_envs_itr->second);
140 throw std::logic_error(
"num_envs variable is not provided");
SpaceType::state_space state_space_type
Type describing the environment state space.
Definition env_base.h:45
SpaceType::state_type state_type
Type describing an individual state.
Definition env_base.h:48
const std::unordered_map< std::string, std::any > & reset_options() const noexcept
Definition env_base.h:105
SpaceType::action_space action_space_type
Type describing the environment action space.
Definition env_base.h:51
TimeStepType time_step_type
Alias for the type returned when stepping the environment.
Definition env_base.h:42
SpaceType::action_type action_type
Type representing an individual action.
Definition env_base.h:54
std::string version() const noexcept
Definition env_base.h:143
GymnasiumEnvBase(network::RESTRLEnvClient &api_server, const std::string &name)
Definition gymnasium_env_base.h:139
EnvBase< TimeStepType, SpaceType > base_type
Base environment type alias.
Definition gymnasium_env_base.h:44
uint_t get_n_envs() const noexcept
Returns the number of environments.
Definition gymnasium_vector_env_base.h:74
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)=0
Construct the environment instance.
Definition gymnasium_vector_env_base.h:120
GymnasiumVecEnvBase(const GymnasiumVecEnvBase &other)
Definition gymnasium_vector_env_base.h:112
base_type::time_step_type time_step_type
Definition gymnasium_vector_env_base.h:45
void reset_if_any_done(bool flag) noexcept
Definition gymnasium_vector_env_base.h:79
base_type::state_type state_type
Definition gymnasium_vector_env_base.h:65
GymnasiumEnvBase< VectorTimeStep< detail_::AcrobotVEnv::state_type >, detail_::AcrobotVEnv >::base_type base_type
Definition gymnasium_vector_env_base.h:39
base_type::action_type action_type
Definition gymnasium_vector_env_base.h:60
bool get_reset_if_any_done() const noexcept
Definition gymnasium_vector_env_base.h:84
GymnasiumVecEnvBase(network::RESTRLEnvClient &api_server, const std::string &name)
Constructor.
Definition gymnasium_vector_env_base.h:105
base_type::action_space_type action_space_type
Definition gymnasium_vector_env_base.h:55
base_type::state_space_type state_space_type
Definition gymnasium_vector_env_base.h:50
Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.
Definition rest_rl_env_client.h:28
Definition lunar_lander_env.h:18
Definition cart_pole.h:18
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
std::size_t uint_t
uint_t
Definition bitsim_types.h:40