XCSF  1.4.7
XCSF learning classifier system
cond_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 "condition.h"
27 #include "dgp.h"
28 #include "xcsf.h"
29 
33 struct CondDGP {
34  struct Graph dgp;
35 };
36 
37 char *
38 cond_dgp_param_json_export(const struct XCSF *xcsf);
39 
40 char *
41 cond_dgp_param_json_import(struct XCSF *xcsf, cJSON *json);
42 
43 void
45 
46 bool
47 cond_dgp_crossover(const struct XCSF *xcsf, const struct Cl *c1,
48  const struct Cl *c2);
49 
50 bool
51 cond_dgp_general(const struct XCSF *xcsf, const struct Cl *c1,
52  const struct Cl *c2);
53 
54 bool
55 cond_dgp_match(const struct XCSF *xcsf, const struct Cl *c, const double *x);
56 
57 bool
58 cond_dgp_mutate(const struct XCSF *xcsf, const struct Cl *c);
59 
60 void
61 cond_dgp_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src);
62 
63 void
64 cond_dgp_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x);
65 
66 void
67 cond_dgp_free(const struct XCSF *xcsf, const struct Cl *c);
68 
69 void
70 cond_dgp_init(const struct XCSF *xcsf, struct Cl *c);
71 
72 void
73 cond_dgp_print(const struct XCSF *xcsf, const struct Cl *c);
74 
75 void
76 cond_dgp_update(const struct XCSF *xcsf, const struct Cl *c, const double *x,
77  const double *y);
78 
79 double
80 cond_dgp_size(const struct XCSF *xcsf, const struct Cl *c);
81 
82 size_t
83 cond_dgp_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
84 
85 size_t
86 cond_dgp_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
87 
88 char *
89 cond_dgp_json_export(const struct XCSF *xcsf, const struct Cl *c);
90 
91 void
92 cond_dgp_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json);
93 
97 static struct CondVtbl const cond_dgp_vtbl = {
103 };
void cond_dgp_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a dynamical GP graph condition.
Definition: cond_dgp.c:177
size_t cond_dgp_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a dynamical GP graph condition from a file.
Definition: cond_dgp.c:222
void cond_dgp_init(const struct XCSF *xcsf, struct Cl *c)
Creates and initialises a dynamical GP graph condition.
Definition: cond_dgp.c:34
bool cond_dgp_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy general function.
Definition: cond_dgp.c:162
void cond_dgp_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Dummy update function.
Definition: cond_dgp.c:96
void cond_dgp_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a dynamical GP graph that matches the current input.
Definition: cond_dgp.c:79
static struct CondVtbl const cond_dgp_vtbl
Dynamical GP graph condition implemented functions.
Definition: cond_dgp.h:97
bool cond_dgp_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Calculates whether a dynamical GP graph condition matches an input.
Definition: cond_dgp.c:113
bool cond_dgp_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates a dynamical GP graph condition with the self-adaptive rates.
Definition: cond_dgp.c:130
char * cond_dgp_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string of the DGP parameters.
Definition: cond_dgp.c:278
void cond_dgp_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by a dynamical GP graph condition.
Definition: cond_dgp.c:48
double cond_dgp_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a dynamical GP graph condition.
Definition: cond_dgp.c:191
void cond_dgp_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies a dynamical GP graph condition from one classifier to another.
Definition: cond_dgp.c:63
size_t cond_dgp_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a dynamical GP graph condition to a file.
Definition: cond_dgp.c:206
void cond_dgp_param_defaults(struct XCSF *xcsf)
Initialises default DGP condition parameters.
Definition: cond_dgp.c:300
bool cond_dgp_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy crossover function.
Definition: cond_dgp.c:145
void cond_dgp_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a DGP condition from a cJSON object.
Definition: cond_dgp.c:260
char * cond_dgp_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the DGP parameters from a cJSON object.
Definition: cond_dgp.c:290
char * cond_dgp_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a DGP condition.
Definition: cond_dgp.c:238
Interface for classifier conditions.
An implementation of dynamical GP graphs with fuzzy activations.
Definition: __init__.py:1
Classifier data structure.
Definition: xcsf.h:45
Dynamical GP graph condition data structure.
Definition: cond_dgp.h:33
struct Graph dgp
DGP graph.
Definition: cond_dgp.h:34
Condition interface data structure.
Definition: condition.h:104
Dynamical GP graph data structure.
Definition: dgp.h:42
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.