XCSF  1.4.7
XCSF learning classifier system
cond_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 "condition.h"
27 #include "neural.h"
28 #include "neural_activations.h"
29 #include "neural_layer.h"
30 #include "xcsf.h"
31 
35 struct CondNeural {
36  struct Net net;
37 };
38 
39 char *
40 cond_neural_param_json_import(struct XCSF *xcsf, cJSON *json);
41 
42 void
44 
45 bool
46 cond_neural_crossover(const struct XCSF *xcsf, const struct Cl *c1,
47  const struct Cl *c2);
48 
49 bool
50 cond_neural_general(const struct XCSF *xcsf, const struct Cl *c1,
51  const struct Cl *c2);
52 
53 bool
54 cond_neural_match(const struct XCSF *xcsf, const struct Cl *c, const double *x);
55 
56 bool
57 cond_neural_mutate(const struct XCSF *xcsf, const struct Cl *c);
58 
59 void
60 cond_neural_copy(const struct XCSF *xcsf, struct Cl *dest,
61  const struct Cl *src);
62 
63 void
64 cond_neural_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x);
65 
66 void
67 cond_neural_free(const struct XCSF *xcsf, const struct Cl *c);
68 
69 void
70 cond_neural_init(const struct XCSF *xcsf, struct Cl *c);
71 
72 void
73 cond_neural_print(const struct XCSF *xcsf, const struct Cl *c);
74 
75 void
76 cond_neural_update(const struct XCSF *xcsf, const struct Cl *c, const double *x,
77  const double *y);
78 
79 double
80 cond_neural_size(const struct XCSF *xcsf, const struct Cl *c);
81 
82 size_t
83 cond_neural_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
84 
85 size_t
86 cond_neural_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
87 
88 int
89 cond_neural_neurons(const struct XCSF *xcsf, const struct Cl *c, int layer);
90 
91 int
92 cond_neural_layers(const struct XCSF *xcsf, const struct Cl *c);
93 
94 int
95 cond_neural_connections(const struct XCSF *xcsf, const struct Cl *c, int layer);
96 
97 char *
98 cond_neural_json_export(const struct XCSF *xcsf, const struct Cl *c);
99 
100 void
101 cond_neural_json_import(const struct XCSF *xcsf, struct Cl *c,
102  const cJSON *json);
103 
107 static struct CondVtbl const cond_neural_vtbl = {
113 };
bool cond_neural_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy general function.
Definition: cond_neural.c:167
bool cond_neural_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy crossover function.
Definition: cond_neural.c:150
void cond_neural_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a neural condition from a cJSON object.
Definition: cond_neural.c:334
int cond_neural_neurons(const struct XCSF *xcsf, const struct Cl *c, int layer)
Returns the number of neurons in a neural condition layer.
Definition: cond_neural.c:245
void cond_neural_init(const struct XCSF *xcsf, struct Cl *c)
Creates and initialises a neural network condition.
Definition: cond_neural.c:42
int cond_neural_layers(const struct XCSF *xcsf, const struct Cl *c)
Returns the number of layers within a neural network condition.
Definition: cond_neural.c:297
void cond_neural_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by a neural network condition.
Definition: cond_neural.c:55
size_t cond_neural_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a neural network condition to a file.
Definition: cond_neural.c:212
char * cond_neural_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a neural condition.
Definition: cond_neural.c:312
bool cond_neural_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a neural network that matches the current input.
Definition: cond_neural.c:118
double cond_neural_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a neural network condition.
Definition: cond_neural.c:197
size_t cond_neural_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a neural network condition from a file.
Definition: cond_neural.c:228
char * cond_neural_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the neural network parameters from a cJSON object.
Definition: cond_neural.c:353
void cond_neural_param_defaults(struct XCSF *xcsf)
Initialises default neural condition parameters.
Definition: cond_neural.c:383
void cond_neural_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Dummy update function.
Definition: cond_neural.c:102
static struct CondVtbl const cond_neural_vtbl
Multi-layer perceptron neural network condition implemented functions.
Definition: cond_neural.h:107
int cond_neural_connections(const struct XCSF *xcsf, const struct Cl *c, int layer)
Returns the number of active connections in a neural condition layer.
Definition: cond_neural.c:273
bool cond_neural_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates a neural network condition with the self-adaptive rates.
Definition: cond_neural.c:135
void cond_neural_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a neural network that matches the current input.
Definition: cond_neural.c:86
void cond_neural_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a neural network condition.
Definition: cond_neural.c:182
void cond_neural_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies a neural network condition from one classifier to another.
Definition: cond_neural.c:70
Interface for classifier conditions.
Definition: __init__.py:1
An implementation of a multi-layer perceptron neural network.
Neural network activation functions.
Interface for neural network layers.
Classifier data structure.
Definition: xcsf.h:45
Multi-layer perceptron neural network condition data structure.
Definition: cond_neural.h:35
struct Net net
Neural network.
Definition: cond_neural.h:36
Condition interface data structure.
Definition: condition.h:104
Neural network data structure.
Definition: neural.h:48
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.