XCSF  1.4.7
XCSF learning classifier system
rule_neural.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 "neural.h"
29 #include "xcsf.h"
30 
34 struct RuleNeural {
35  struct Net net;
36 };
37 
38 bool
39 rule_neural_cond_crossover(const struct XCSF *xcsf, const struct Cl *c1,
40  const struct Cl *c2);
41 
42 bool
43 rule_neural_cond_general(const struct XCSF *xcsf, const struct Cl *c1,
44  const struct Cl *c2);
45 
46 bool
47 rule_neural_cond_match(const struct XCSF *xcsf, const struct Cl *c,
48  const double *x);
49 
50 bool
51 rule_neural_cond_mutate(const struct XCSF *xcsf, const struct Cl *c);
52 
53 void
54 rule_neural_cond_copy(const struct XCSF *xcsf, struct Cl *dest,
55  const struct Cl *src);
56 
57 void
58 rule_neural_cond_cover(const struct XCSF *xcsf, const struct Cl *c,
59  const double *x);
60 
61 void
62 rule_neural_cond_free(const struct XCSF *xcsf, const struct Cl *c);
63 
64 void
65 rule_neural_cond_init(const struct XCSF *xcsf, struct Cl *c);
66 
67 void
68 rule_neural_cond_print(const struct XCSF *xcsf, const struct Cl *c);
69 
70 void
71 rule_neural_cond_update(const struct XCSF *xcsf, const struct Cl *c,
72  const double *x, const double *y);
73 
74 double
75 rule_neural_cond_size(const struct XCSF *xcsf, const struct Cl *c);
76 
77 size_t
78 rule_neural_cond_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
79 
80 size_t
81 rule_neural_cond_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
82 
83 char *
84 rule_neural_cond_json_export(const struct XCSF *xcsf, const struct Cl *c);
85 
86 void
87 rule_neural_cond_json_import(const struct XCSF *xcsf, struct Cl *c,
88  const cJSON *json);
89 
93 static struct CondVtbl const rule_neural_cond_vtbl = {
102 };
103 
104 bool
105 rule_neural_act_crossover(const struct XCSF *xcsf, const struct Cl *c1,
106  const struct Cl *c2);
107 
108 bool
109 rule_neural_act_general(const struct XCSF *xcsf, const struct Cl *c1,
110  const struct Cl *c2);
111 
112 bool
113 rule_neural_act_mutate(const struct XCSF *xcsf, const struct Cl *c);
114 
115 int
116 rule_neural_act_compute(const struct XCSF *xcsf, const struct Cl *c,
117  const double *x);
118 
119 void
120 rule_neural_act_copy(const struct XCSF *xcsf, struct Cl *dest,
121  const struct Cl *src);
122 
123 void
124 rule_neural_act_cover(const struct XCSF *xcsf, const struct Cl *c,
125  const double *x, const int action);
126 
127 void
128 rule_neural_act_free(const struct XCSF *xcsf, const struct Cl *c);
129 
130 void
131 rule_neural_act_init(const struct XCSF *xcsf, struct Cl *c);
132 
133 void
134 rule_neural_act_print(const struct XCSF *xcsf, const struct Cl *c);
135 
136 void
137 rule_neural_act_update(const struct XCSF *xcsf, const struct Cl *c,
138  const double *x, const double *y);
139 
140 size_t
141 rule_neural_act_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
142 
143 size_t
144 rule_neural_act_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
145 
146 char *
147 rule_neural_act_json_export(const struct XCSF *xcsf, const struct Cl *c);
148 
149 void
150 rule_neural_act_json_import(const struct XCSF *xcsf, struct Cl *c,
151  const cJSON *json);
152 
156 static struct ActVtbl const rule_neural_act_vtbl = {
164 };
Interface for classifier actions.
Interface for classifier conditions.
Definition: __init__.py:1
An implementation of a multi-layer perceptron neural network.
bool rule_neural_cond_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Definition: rule_neural.c:89
size_t rule_neural_cond_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Definition: rule_neural.c:154
bool rule_neural_act_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Definition: rule_neural.c:265
size_t rule_neural_cond_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Definition: rule_neural.c:145
char * rule_neural_act_json_export(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_neural.c:311
size_t rule_neural_act_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Definition: rule_neural.c:293
static struct ActVtbl const rule_neural_act_vtbl
Neural network rule action implemented functions.
Definition: rule_neural.h:156
void rule_neural_act_init(const struct XCSF *xcsf, struct Cl *c)
Definition: rule_neural.c:196
void rule_neural_act_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Definition: rule_neural.c:255
bool rule_neural_cond_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Definition: rule_neural.c:109
static struct CondVtbl const rule_neural_cond_vtbl
Neural network rule condition implemented functions.
Definition: rule_neural.h:93
void rule_neural_cond_print(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_neural.c:129
bool rule_neural_cond_mutate(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_neural.c:101
void rule_neural_cond_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Definition: rule_neural.c:181
void rule_neural_act_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Definition: rule_neural.c:323
void rule_neural_cond_free(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_neural.c:50
void rule_neural_act_free(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_neural.c:203
size_t rule_neural_act_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Definition: rule_neural.c:302
bool rule_neural_act_mutate(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_neural.c:285
void rule_neural_cond_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Definition: rule_neural.c:79
void rule_neural_act_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Definition: rule_neural.c:210
bool rule_neural_act_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Definition: rule_neural.c:275
char * rule_neural_cond_json_export(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_neural.c:164
bool rule_neural_cond_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Definition: rule_neural.c:119
void rule_neural_cond_init(const struct XCSF *xcsf, struct Cl *c)
Definition: rule_neural.c:35
int rule_neural_act_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Definition: rule_neural.c:238
void rule_neural_cond_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Definition: rule_neural.c:59
double rule_neural_cond_size(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_neural.c:137
void rule_neural_cond_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Definition: rule_neural.c:70
void rule_neural_act_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x, const int action)
Definition: rule_neural.c:227
void rule_neural_act_print(const struct XCSF *xcsf, const struct Cl *c)
Definition: rule_neural.c:219
Action interface data structure.
Definition: action.h:76
Classifier data structure.
Definition: xcsf.h:45
Condition interface data structure.
Definition: condition.h:104
Neural network data structure.
Definition: neural.h:48
Neural network rule data structure.
Definition: rule_neural.h:34
struct Net net
Neural network.
Definition: rule_neural.h:35
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.