bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
pendulum_env.h
Go to the documentation of this file.
1#ifndef PENDULUM_ENV_H
2#define PENDULUM_ENV_H
3
82#include "bitrl/bitrl_types.h"
86#include "bitrl/extern/nlohmann/json/json.hpp"
88
89#include <any>
90#include <string>
91#include <tuple>
92#include <vector>
93
94namespace bitrl
95{
96namespace envs::gymnasium
97{
98
102class Pendulum final
103 : public GymnasiumEnvBase<TimeStep<std::vector<real_t>>,
104 ContinuousVectorStateContinuousScalarBoundedActionEnv<
105 3, 1, RealRange<-2.0, 2.0>, 0, real_t>>
106{
107
108 public:
112 static const std::string name;
113
117 static const std::string URI;
118
124 3, 1, RealRange<-2.0, 2.0>, 0, real_t>>::base_type base_type;
125
131
135 typedef typename base_type::state_space_type state_space_type;
136
140 typedef typename base_type::action_space_type action_space_type;
141
145 typedef typename base_type::action_type action_type;
146
150 typedef typename base_type::state_type state_type;
151
156
160 Pendulum(const Pendulum &other);
161
165 ~Pendulum() override = default;
166
170 virtual void
171 make(const std::string &version, const std::unordered_map<std::string, std::any> & /*options*/,
172 const std::unordered_map<std::string, std::any> &reset_options) override final;
173
177 virtual time_step_type step(const action_type &action) override final;
178
182 uint_t n_actions() const noexcept { return action_space_type::size; }
183
184 protected:
188 virtual time_step_type
189 create_time_step_from_response_(const nlohmann::json &response) const override final;
190};
191
192} // namespace envs::gymnasium
193} // namespace bitrl
194
195#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
Base class for all Gymnasium environment wrappers.
Definition gymnasium_env_base.h:41
The Pendulum class. Interface for Pendulum environment.
Definition pendulum_env.h:106
base_type::action_type action_type
The type of the action to be undertaken in the environment.
Definition pendulum_env.h:145
virtual time_step_type step(const action_type &action) override final
step. Step in the environment following the given action
Definition pendulum_env.cpp:65
uint_t n_actions() const noexcept
n_actions. Returns the number of actions
Definition pendulum_env.h:182
~Pendulum() override=default
~Pendulum. Destructor
base_type::state_space_type state_space_type
The type describing the state space for the environment.
Definition pendulum_env.h:135
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 pendulum_env.cpp:20
base_type::action_space_type action_space_type
The type of the action space for the environment.
Definition pendulum_env.h:140
base_type::time_step_type time_step_type
The time step type we return every time a step in the environment is performed.
Definition pendulum_env.h:130
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 pendulum_env.cpp:47
static const std::string URI
The URI for accessing the environment.
Definition pendulum_env.h:117
base_type::state_type state_type
The type of the state.
Definition pendulum_env.h:150
static const std::string name
name
Definition pendulum_env.h:112
GymnasiumEnvBase< TimeStep< std::vector< real_t > >, ContinuousVectorStateContinuousScalarBoundedActionEnv< 3, 1, RealRange<-2.0, 2.0 >, 0, real_t > >::base_type base_type
Base class type.
Definition pendulum_env.h:124
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
A range of double precision floating point values.
Definition bitrl_types.h:140