env_type.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_RL_ENVIRONMENT_ENV_TYPE_HPP
13 #define MLPACK_METHODS_RL_ENVIRONMENT_ENV_TYPE_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace rl {
19 
33 {
34  public:
38  class State
39  {
40  public:
44  State() : data(dimension)
45  { /* Nothing to do here. */ }
46 
52  State(const arma::colvec& data) : data(data)
53  { /* Nothing to do here */ }
54 
56  arma::colvec& Data() { return data; }
57 
59  const arma::colvec& Encode() const { return data; }
60 
62  static size_t dimension;
63 
64  private:
66  arma::colvec data;
67  };
68 
72  class Action
73  {
74  public:
75  // To store the action.
76  size_t action = 0;
77  // Track the size of the action space.
78  static size_t size;
79  };
80 
89  double Sample(const State& /* state */,
90  const Action& /* action */,
91  State& /* nextState*/)
92  { return 0; }
93 
99  State InitialSample() { return State(); }
106  bool IsTerminal(const State& /* state */) const { return false; }
107 };
108 
122 {
123  public:
127  class State
128  {
129  public:
133  State() : data(dimension)
134  { /* Nothing to do here. */ }
135 
141  State(const arma::colvec& data) : data(data)
142  { /* Nothing to do here */ }
143 
145  arma::colvec& Data() { return data; }
146 
148  const arma::colvec& Encode() const { return data; }
149 
151  static size_t dimension;
152 
153  private:
155  arma::colvec data;
156  };
157 
161  class Action
162  {
163  public:
164  std::vector<double> action;
165  // Storing degree of freedom.
166  static size_t size;
167 
171  Action() : action(ContinuousActionEnv::Action::size)
172  { /* Nothing to do here */ }
173  };
174 
183  double Sample(const State& /* state */,
184  const Action& /* action */,
185  State& /* nextState*/)
186  { return 0; }
187 
193  State InitialSample() { return State(); }
200  bool IsTerminal(const State& /* state */) const { return false; }
201 };
202 
203 } // namespace rl
204 } // namespace mlpack
205 
206 #endif
Implementation of continuous action.
Definition: env_type.hpp:161
Implementation of state of the dummy environment.
Definition: env_type.hpp:38
To use the dummy environment, one may start by specifying the state and action dimensions.
Definition: env_type.hpp:32
double Sample(const State &, const Action &, State &)
Dummy function to mimic sampling in an environment.
Definition: env_type.hpp:89
Linear algebra utility functions, generally performed on matrices or vectors.
double Sample(const State &, const Action &, State &)
Dummy function to mimic sampling in an environment.
Definition: env_type.hpp:183
State()
Construct a state instance.
Definition: env_type.hpp:44
State(const arma::colvec &data)
Construct a state instance from given data.
Definition: env_type.hpp:52
Implementation of state of the dummy environment.
Definition: env_type.hpp:127
The core includes that mlpack expects; standard C++ includes and Armadillo.
State(const arma::colvec &data)
Construct a state instance from given data.
Definition: env_type.hpp:141
arma::colvec & Data()
Modify the internal representation of the state.
Definition: env_type.hpp:145
static size_t dimension
Dimension of the encoded state.
Definition: env_type.hpp:62
State InitialSample()
Dummy function to mimic initial sampling in an environment.
Definition: env_type.hpp:99
Action()
Construct an action instance.
Definition: env_type.hpp:171
To use the dummy environment, one may start by specifying the state and action dimensions.
Definition: env_type.hpp:121
bool IsTerminal(const State &) const
Dummy function to find terminal state.
Definition: env_type.hpp:106
const arma::colvec & Encode() const
Encode the state to a column vector.
Definition: env_type.hpp:59
Implementation of discrete action.
Definition: env_type.hpp:72
bool IsTerminal(const State &) const
Dummy function to find terminal state.
Definition: env_type.hpp:200
arma::colvec & Data()
Modify the internal representation of the state.
Definition: env_type.hpp:56
const arma::colvec & Encode() const
Encode the state to a column vector.
Definition: env_type.hpp:148
State InitialSample()
Dummy function to mimic initial sampling in an environment.
Definition: env_type.hpp:193
State()
Construct a state instance.
Definition: env_type.hpp:133
static size_t dimension
Dimension of the encoded state.
Definition: env_type.hpp:151