bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
acrobot_vec_env.h
Go to the documentation of this file.
1#ifndef ACROBOT_ENV_H
2#define ACROBOT_ENV_H
3
12#include "bitrl/bitrl_types.h"
16#include "bitrl/extern/nlohmann/json/json.hpp"
18
19#include <any>
20#include <string>
21#include <vector>
22
23namespace bitrl
24{
25
27template <typename StateTp> class VectorTimeStep;
28
29namespace envs::gymnasium
30{
31
32namespace detail_
33{
34
36{
37
39
41
46
48
52 typedef std::vector<typename action_space::space_item_type> action_type;
53
58};
59
60} // namespace detail_
61
65class AcrobotV final : public GymnasiumVecEnvBase<VectorTimeStep<detail_::AcrobotVEnv::state_type>,
66 detail_::AcrobotVEnv>
67{
68
69 public:
73 static const std::string name;
74
78 static const std::string URI;
79
85
91
95 typedef typename base_type::state_space_type state_space_type;
96
100 typedef typename base_type::action_space_type action_space_type;
101
105 typedef typename base_type::action_type action_type;
106
110 typedef typename base_type::state_type state_type;
111
116
120 AcrobotV(const AcrobotV &other);
121
125 ~AcrobotV() override = default;
126
130 virtual void
131 make(const std::string &version, const std::unordered_map<std::string, std::any> &,
132 const std::unordered_map<std::string, std::any> &reset_options) override final;
133
137 virtual time_step_type step(const action_type &action) override final;
138
142 uint_t n_actions() const noexcept { return action_space_type::size; }
143
144 protected:
148 virtual time_step_type
149 create_time_step_from_response_(const nlohmann::json &response) const override final;
150};
151
152} // namespace envs::gymnasium
153} // namespace bitrl
154
155#endif // PENDULUM_ENV_H
const std::unordered_map< std::string, std::any > & reset_options() const noexcept
Access the configuration options provided to make().
Definition env_base.h:104
TimeStepType time_step_type
Alias for the type returned when stepping the environment.
Definition env_base.h:41
std::string version() const noexcept
Get the environment version set during make().
Definition env_base.h:142
The CartPole class Interface for CartPole environment.
Definition acrobot_vec_env.h:67
GymnasiumVecEnvBase< VectorTimeStep< detail_::AcrobotVEnv::state_type >, detail_::AcrobotVEnv >::base_type base_type
Base class type.
Definition acrobot_vec_env.h:84
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition acrobot_vec_env.h:100
base_type::state_type state_type
The type of the state.
Definition acrobot_vec_env.h:110
~AcrobotV() override=default
~Acrobot. Destructor
virtual time_step_type create_time_step_from_response_(const nlohmann::json &response) const override final
Handle the reset response from the environment server.
Definition acrobot_vec_env.cpp:15
static const std::string name
name
Definition acrobot_vec_env.h:73
uint_t n_actions() const noexcept
n_actions. Returns the number of actions
Definition acrobot_vec_env.h:142
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition acrobot_vec_env.h:95
static const std::string URI
The URI for accessing the environment.
Definition acrobot_vec_env.h:78
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition acrobot_vec_env.h:105
virtual time_step_type step(const action_type &action) override final
step. Step in the environment following the given action
Definition acrobot_vec_env.cpp:62
base_type::time_step_type time_step_type
The time step type we return every time a step in the environment is performed.
Definition acrobot_vec_env.h:90
virtual void make(const std::string &version, const std::unordered_map< std::string, std::any > &, const std::unordered_map< std::string, std::any > &reset_options) override final
make. Build the environment
Definition acrobot_vec_env.cpp:41
Definition gymnasium_vector_env_base.h:33
Utility class to facilitate HTTP requests between the environments REST API and C++ drivers.
Definition rest_rl_env_client.h:29
Definition bitrl_consts.h:14
std::size_t uint_t
uint_t
Definition bitrl_types.h:43
Definition space_type.h:135
std::vector< T > space_item_type
item_t
Definition space_type.h:147
static constexpr uint_t size
The overall size of the space meaning how many elements can potentially the space have.
Definition space_type.h:142
A scalar discrete space can be used to denote a space that only has a single value at each time....
Definition space_type.h:22
static constexpr uint_t size
The overall size of the space meaning how many elements can potentially the space have.
Definition space_type.h:38
Definition acrobot_vec_env.h:36
ScalarDiscreteSpace< 0, 3 > action_space
Definition acrobot_vec_env.h:47
static constexpr uint_t ACTION_SPACE_SIZE
state space size
Definition acrobot_vec_env.h:57
std::vector< typename action_space::space_item_type > action_type
the Action type
Definition acrobot_vec_env.h:52
state_space::space_item_type state_type
Definition acrobot_vec_env.h:40
static constexpr uint_t STATE_SPACE_SIZE
state space size
Definition acrobot_vec_env.h:45
ContinuousVectorSpace< 6, real_t > state_space
Definition acrobot_vec_env.h:38