XCSF  1.4.7
XCSF learning classifier system
env.h
Go to the documentation of this file.
1 /*
2  * This program is free software: you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
24 #pragma once
25 
26 #include "xcsf.h"
27 
28 void
29 env_init(struct XCSF *xcsf, char **argv);
30 
35 struct EnvVtbl {
36  bool (*env_impl_is_done)(const struct XCSF *xcsf);
37  bool (*env_impl_multistep)(const struct XCSF *xcsf);
38  double (*env_impl_execute)(const struct XCSF *xcsf, const int action);
39  double (*env_impl_max_payoff)(const struct XCSF *xcsf);
40  const double *(*env_impl_get_state)(const struct XCSF *xcsf);
41  void (*env_impl_free)(const struct XCSF *xcsf);
42  void (*env_impl_reset)(const struct XCSF *xcsf);
43 };
44 
50 static inline bool
51 env_is_done(const struct XCSF *xcsf)
52 {
53  return (*xcsf->env_vptr->env_impl_is_done)(xcsf);
54 }
55 
61 static inline bool
62 env_multistep(const struct XCSF *xcsf)
63 {
64  return (*xcsf->env_vptr->env_impl_multistep)(xcsf);
65 }
66 
73 static inline double
74 env_execute(const struct XCSF *xcsf, const int action)
75 {
76  return (*xcsf->env_vptr->env_impl_execute)(xcsf, action);
77 }
78 
84 static inline double
85 env_max_payoff(const struct XCSF *xcsf)
86 {
87  return (*xcsf->env_vptr->env_impl_max_payoff)(xcsf);
88 }
89 
95 static inline const double *
96 env_get_state(const struct XCSF *xcsf)
97 {
98  return (*xcsf->env_vptr->env_impl_get_state)(xcsf);
99 }
100 
105 static inline void
106 env_free(const struct XCSF *xcsf)
107 {
108  (*xcsf->env_vptr->env_impl_free)(xcsf);
109 }
110 
115 static inline void
116 env_reset(const struct XCSF *xcsf)
117 {
118  (*xcsf->env_vptr->env_impl_reset)(xcsf);
119 }
static void env_reset(const struct XCSF *xcsf)
Resets the environment.
Definition: env.h:116
void env_init(struct XCSF *xcsf, char **argv)
Initialises a built-in problem environment.
Definition: env.c:34
static bool env_multistep(const struct XCSF *xcsf)
Returns whether the environment is a multistep problem.
Definition: env.h:62
static const double * env_get_state(const struct XCSF *xcsf)
Returns the current environment perceptions.
Definition: env.h:96
static double env_max_payoff(const struct XCSF *xcsf)
Returns the maximum payoff value possible in the environment.
Definition: env.h:85
static bool env_is_done(const struct XCSF *xcsf)
Returns whether the environment is in a terminal state.
Definition: env.h:51
static double env_execute(const struct XCSF *xcsf, const int action)
Executes the specified action and returns the payoff.
Definition: env.h:74
static void env_free(const struct XCSF *xcsf)
Frees the environment.
Definition: env.h:106
Definition: __init__.py:1
Built-in problem environment interface data structure.
Definition: env.h:35
bool(* env_impl_multistep)(const struct XCSF *xcsf)
Definition: env.h:37
double(* env_impl_max_payoff)(const struct XCSF *xcsf)
Definition: env.h:39
bool(* env_impl_is_done)(const struct XCSF *xcsf)
Definition: env.h:36
void(* env_impl_free)(const struct XCSF *xcsf)
Definition: env.h:41
void(* env_impl_reset)(const struct XCSF *xcsf)
Definition: env.h:42
double(* env_impl_execute)(const struct XCSF *xcsf, const int action)
Definition: env.h:38
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.