bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
acrobot_env.h
Go to the documentation of this file.
1#ifndef ACROBOT_ENV_H
2#define ACROBOT_ENV_H
3
7
130
131#include "bitrl/bitrl_types.h"
132#include "bitrl/envs/env_types.h"
134#include "bitrl/envs/time_step.h"
135#include "bitrl/extern/nlohmann/json/json.hpp"
137
138#include <any>
139#include <string>
140#include <tuple>
141#include <vector>
142
143namespace bitrl
144{
145namespace envs::gymnasium
146{
147
151class Acrobot final
152 : public GymnasiumEnvBase<TimeStep<std::vector<real_t>>,
153 ContinuousVectorStateDiscreteActionEnv<6, 2, 0, real_t>>
154{
155
156 public:
160 static const std::string name;
161
165 static const std::string URI;
166
171 ContinuousVectorStateDiscreteActionEnv<6, // size of state space
172 2, // end of action space
173 0, // start of action space
174 real_t> // type of state
181
185 typedef typename base_type::state_space_type state_space_type;
186
190 typedef typename base_type::action_space_type action_space_type;
191
195 typedef typename base_type::action_type action_type;
196
200 typedef typename base_type::state_type state_type;
201
203
204 Acrobot(const Acrobot &other);
205
206 ~Acrobot() override = default;
207
213 virtual void
214 make(const std::string &version, const std::unordered_map<std::string, std::any> &options,
215 const std::unordered_map<std::string, std::any> &reset_options) override final;
216
221 virtual time_step_type step(const action_type &action) override final;
222
226 uint_t n_actions() const noexcept { return action_space_type::size; }
227
228 protected:
232 virtual time_step_type
233 create_time_step_from_response_(const nlohmann::json &response) const override final;
234};
235
236} // namespace envs::gymnasium
237} // namespace bitrl
238
239#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
class Acrobot. The Acrobot class. Interface for Gymnasium::Acrobot environment.
Definition acrobot_env.h:154
GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateDiscreteActionEnv< 6, 2, 0, real_t > >::base_type base_type
Base class type.
Definition acrobot_env.h:175
base_type::state_type state_type
The type of the state.
Definition acrobot_env.h:200
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition acrobot_env.h:185
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition acrobot_env.h:195
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition acrobot_env.h:190
static const std::string URI
The URI for accessing the environment.
Definition acrobot_env.h:165
static const std::string name
The name of the environment.
Definition acrobot_env.h:160
virtual time_step_type step(const action_type &action) override final
step. Step in the environment following the given action.
Definition acrobot_env.cpp:61
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_env.cpp:17
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. Build the environment
Definition acrobot_env.cpp:43
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_env.h:180
uint_t n_actions() const noexcept
n_actions. Returns the number of actions
Definition acrobot_env.h:226
Base class for all Gymnasium environment wrappers.
Definition gymnasium_env_base.h:41
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
double real_t
real_t
Definition bitrl_types.h:23
std::size_t uint_t
uint_t
Definition bitrl_types.h:43