mlpack  3.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 };
110 
124 {
125  public:
129  class State
130  {
131  public:
135  State() : data(dimension)
136  { /* Nothing to do here. */ }
137 
143  State(const arma::colvec& data) : data(data)
144  { /* Nothing to do here */ }
145 
147  arma::colvec& Data() { return data; }
148 
150  const arma::colvec& Encode() const { return data; }
151 
153  static size_t dimension;
154 
155  private:
157  arma::colvec data;
158  };
159 
163  class Action
164  {
165  public:
166  std::vector<double> action;
167  // Storing degree of freedom.
168  static size_t size;
169 
174  { /* Nothing to do here */ }
175  };
176 
185  double Sample(const State& /* state */,
186  const Action& /* action */,
187  State& /* nextState*/)
188  { return 0; }
189 
195  State InitialSample() { return State(); }
202  bool IsTerminal(const State& /* state */) const { return false; }
203 };
206 
207 } // namespace rl
208 } // namespace mlpack
209 
210 #endif
Implementation of continuous action.
Definition: env_type.hpp:163
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
double Sample(const State &, const Action &, State &)
Dummy function to mimic sampling in an environment.
Definition: env_type.hpp:185
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:129
The core includes that mlpack expects; standard C++ includes and Armadillo.
bool IsTerminal(const State &) const
Dummy function to find terminal state.
Definition: env_type.hpp:106
bool IsTerminal(const State &) const
Dummy function to find terminal state.
Definition: env_type.hpp:202
State(const arma::colvec &data)
Construct a state instance from given data.
Definition: env_type.hpp:143
arma::colvec & Data()
Modify the internal representation of the state.
Definition: env_type.hpp:147
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:173
To use the dummy environment, one may start by specifying the state and action dimensions.
Definition: env_type.hpp:123
Implementation of discrete action.
Definition: env_type.hpp:72
const arma::colvec & Encode() const
Encode the state to a column vector.
Definition: env_type.hpp:150
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:59
State InitialSample()
Dummy function to mimic initial sampling in an environment.
Definition: env_type.hpp:195
State()
Construct a state instance.
Definition: env_type.hpp:135
static size_t dimension
Dimension of the encoded state.
Definition: env_type.hpp:153