XCSF  1.4.7
XCSF learning classifier system
act_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 "neural.h"
28 #include "neural_activations.h"
29 #include "neural_layer.h"
30 #include "xcsf.h"
31 
35 struct ActNeural {
36  struct Net net;
37 };
38 
39 void
41 
42 char *
43 act_neural_param_json_import(struct XCSF *xcsf, cJSON *json);
44 
45 bool
46 act_neural_crossover(const struct XCSF *xcsf, const struct Cl *c1,
47  const struct Cl *c2);
48 
49 bool
50 act_neural_general(const struct XCSF *xcsf, const struct Cl *c1,
51  const struct Cl *c2);
52 
53 bool
54 act_neural_mutate(const struct XCSF *xcsf, const struct Cl *c);
55 
56 int
57 act_neural_compute(const struct XCSF *xcsf, const struct Cl *c,
58  const double *x);
59 
60 void
61 act_neural_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src);
62 
63 void
64 act_neural_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x,
65  const int action);
66 
67 void
68 act_neural_free(const struct XCSF *xcsf, const struct Cl *c);
69 
70 void
71 act_neural_init(const struct XCSF *xcsf, struct Cl *c);
72 
73 void
74 act_neural_print(const struct XCSF *xcsf, const struct Cl *c);
75 
76 void
77 act_neural_update(const struct XCSF *xcsf, const struct Cl *c, const double *x,
78  const double *y);
79 
80 size_t
81 act_neural_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
82 
83 size_t
84 act_neural_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
85 
86 char *
87 act_neural_json_export(const struct XCSF *xcsf, const struct Cl *c);
88 
89 void
90 act_neural_json_import(const struct XCSF *xcsf, struct Cl *c,
91  const cJSON *json);
92 
96 static struct ActVtbl const act_neural_vtbl = {
102 };
size_t act_neural_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a neural network action from a file.
Definition: act_neural.c:216
bool act_neural_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy function since neural actions do not generalise another.
Definition: act_neural.c:76
void act_neural_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a neural action from a cJSON object.
Definition: act_neural.c:254
void act_neural_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by a neural network action.
Definition: act_neural.c:167
static struct ActVtbl const act_neural_vtbl
neural action implemented functions.
Definition: act_neural.h:96
void act_neural_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a neural network action.
Definition: act_neural.c:137
void act_neural_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies a neural network action from one classifier to another.
Definition: act_neural.c:122
void act_neural_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Dummy function since neural network actions are not updated.
Definition: act_neural.c:183
int act_neural_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Computes the current neural network action using the input.
Definition: act_neural.c:107
void act_neural_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x, const int action)
Generates a neural network that covers the specified input:action.
Definition: act_neural.c:152
bool act_neural_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy function since crossover is not performed on neural actions.
Definition: act_neural.c:59
void act_neural_init(const struct XCSF *xcsf, struct Cl *c)
Creates and initialises an action neural network.
Definition: act_neural.c:44
void act_neural_param_defaults(struct XCSF *xcsf)
Initialises default neural action parameters.
Definition: act_neural.c:270
char * act_neural_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the neural network parameters from a cJSON object.
Definition: act_neural.c:305
bool act_neural_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates a neural network action.
Definition: act_neural.c:92
char * act_neural_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a neural action.
Definition: act_neural.c:232
size_t act_neural_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a neural network action to a file.
Definition: act_neural.c:200
Interface for classifier actions.
Definition: __init__.py:1
An implementation of a multi-layer perceptron neural network.
Neural network activation functions.
Interface for neural network layers.
Neural network action data structure.
Definition: act_neural.h:35
struct Net net
Neural network.
Definition: act_neural.h:36
Action interface data structure.
Definition: action.h:76
Classifier data structure.
Definition: xcsf.h:45
Neural network data structure.
Definition: neural.h:48
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.