XCSF  1.4.7
XCSF learning classifier system
rule_dgp.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 "action.h"
27 #include "condition.h"
28 #include "dgp.h"
29 #include "xcsf.h"
30 
34 struct RuleDGP {
35  struct Graph dgp;
36  int n_outputs;
37 };
38 
39 bool
40 rule_dgp_cond_crossover(const struct XCSF *xcsf, const struct Cl *c1,
41  const struct Cl *c2);
42 
43 bool
44 rule_dgp_cond_general(const struct XCSF *xcsf, const struct Cl *c1,
45  const struct Cl *c2);
46 
47 bool
48 rule_dgp_cond_match(const struct XCSF *xcsf, const struct Cl *c,
49  const double *x);
50 
51 bool
52 rule_dgp_cond_mutate(const struct XCSF *xcsf, const struct Cl *c);
53 
54 void
55 rule_dgp_cond_copy(const struct XCSF *xcsf, struct Cl *dest,
56  const struct Cl *src);
57 
58 void
59 rule_dgp_cond_cover(const struct XCSF *xcsf, const struct Cl *c,
60  const double *x);
61 
62 void
63 rule_dgp_cond_free(const struct XCSF *xcsf, const struct Cl *c);
64 
65 void
66 rule_dgp_cond_init(const struct XCSF *xcsf, struct Cl *c);
67 
68 void
69 rule_dgp_cond_print(const struct XCSF *xcsf, const struct Cl *c);
70 
71 void
72 rule_dgp_cond_update(const struct XCSF *xcsf, const struct Cl *c,
73  const double *x, const double *y);
74 
75 double
76 rule_dgp_cond_size(const struct XCSF *xcsf, const struct Cl *c);
77 
78 size_t
79 rule_dgp_cond_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
80 
81 size_t
82 rule_dgp_cond_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
83 
84 char *
85 rule_dgp_cond_json_export(const struct XCSF *xcsf, const struct Cl *c);
86 
87 void
88 rule_dgp_cond_json_import(const struct XCSF *xcsf, struct Cl *c,
89  const cJSON *json);
90 
94 static struct CondVtbl const rule_dgp_cond_vtbl = {
103 };
104 
105 bool
106 rule_dgp_act_crossover(const struct XCSF *xcsf, const struct Cl *c1,
107  const struct Cl *c2);
108 
109 bool
110 rule_dgp_act_general(const struct XCSF *xcsf, const struct Cl *c1,
111  const struct Cl *c2);
112 
113 bool
114 rule_dgp_act_mutate(const struct XCSF *xcsf, const struct Cl *c);
115 
116 int
117 rule_dgp_act_compute(const struct XCSF *xcsf, const struct Cl *c,
118  const double *x);
119 
120 void
121 rule_dgp_act_copy(const struct XCSF *xcsf, struct Cl *dest,
122  const struct Cl *src);
123 
124 void
125 rule_dgp_act_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x,
126  const int action);
127 
128 void
129 rule_dgp_act_free(const struct XCSF *xcsf, const struct Cl *c);
130 
131 void
132 rule_dgp_act_init(const struct XCSF *xcsf, struct Cl *c);
133 
134 void
135 rule_dgp_act_print(const struct XCSF *xcsf, const struct Cl *c);
136 
137 void
138 rule_dgp_act_update(const struct XCSF *xcsf, const struct Cl *c,
139  const double *x, const double *y);
140 
141 size_t
142 rule_dgp_act_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
143 
144 size_t
145 rule_dgp_act_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
146 
147 char *
148 rule_dgp_act_json_export(const struct XCSF *xcsf, const struct Cl *c);
149 
150 void
151 rule_dgp_act_json_import(const struct XCSF *xcsf, struct Cl *c,
152  const cJSON *json);
153 
157 static struct ActVtbl const rule_dgp_act_vtbl = {
163 };
Interface for classifier actions.
Interface for classifier conditions.
An implementation of dynamical GP graphs with fuzzy activations.
Definition: __init__.py:1
bool rule_dgp_act_mutate(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_dgp.c:276
char * rule_dgp_act_json_export(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_dgp.c:302
void rule_dgp_cond_init(const struct XCSF *xcsf, struct Cl *c)
Definition: rule_dgp.c:30
char * rule_dgp_cond_json_export(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_dgp.c:155
bool rule_dgp_cond_mutate(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_dgp.c:92
void rule_dgp_cond_free(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_dgp.c:40
bool rule_dgp_cond_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Definition: rule_dgp.c:110
size_t rule_dgp_act_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Definition: rule_dgp.c:284
void rule_dgp_act_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Definition: rule_dgp.c:201
size_t rule_dgp_act_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Definition: rule_dgp.c:293
bool rule_dgp_act_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Definition: rule_dgp.c:266
static struct ActVtbl const rule_dgp_act_vtbl
Dynamical GP rule action implemented functions.
Definition: rule_dgp.h:157
void rule_dgp_cond_print(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_dgp.c:120
void rule_dgp_cond_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Definition: rule_dgp.c:49
bool rule_dgp_cond_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Definition: rule_dgp.c:100
void rule_dgp_act_init(const struct XCSF *xcsf, struct Cl *c)
Definition: rule_dgp.c:187
void rule_dgp_cond_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Definition: rule_dgp.c:70
void rule_dgp_act_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Definition: rule_dgp.c:246
bool rule_dgp_cond_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Definition: rule_dgp.c:80
void rule_dgp_act_print(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_dgp.c:210
void rule_dgp_act_free(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_dgp.c:194
bool rule_dgp_act_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Definition: rule_dgp.c:256
void rule_dgp_cond_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Definition: rule_dgp.c:61
void rule_dgp_act_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x, const int action)
Definition: rule_dgp.c:218
size_t rule_dgp_cond_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Definition: rule_dgp.c:136
int rule_dgp_act_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Definition: rule_dgp.c:229
void rule_dgp_act_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Definition: rule_dgp.c:314
double rule_dgp_cond_size(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_dgp.c:128
static struct CondVtbl const rule_dgp_cond_vtbl
Dynamical GP rule condition implemented functions.
Definition: rule_dgp.h:94
size_t rule_dgp_cond_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Definition: rule_dgp.c:145
void rule_dgp_cond_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Definition: rule_dgp.c:171
Action interface data structure.
Definition: action.h:76
Classifier data structure.
Definition: xcsf.h:45
Condition interface data structure.
Definition: condition.h:104
Dynamical GP graph data structure.
Definition: dgp.h:42
Dynamical GP graph rule data structure.
Definition: rule_dgp.h:34
struct Graph dgp
DGP graph.
Definition: rule_dgp.h:35
int n_outputs
Number of action nodes (binarised)
Definition: rule_dgp.h:36
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.