XCSF 1.4.8
XCSF learning classifier system
Loading...
Searching...
No Matches
cond_gp.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 "gp.h"
28#include "xcsf.h"
29
33struct CondGP {
34 struct GPTree gp;
35};
36
37void
39
40char *
42
43char *
44cond_gp_param_json_import(struct XCSF *xcsf, cJSON *json);
45
46bool
47cond_gp_crossover(const struct XCSF *xcsf, const struct Cl *c1,
48 const struct Cl *c2);
49
50bool
51cond_gp_general(const struct XCSF *xcsf, const struct Cl *c1,
52 const struct Cl *c2);
53
54bool
55cond_gp_match(const struct XCSF *xcsf, const struct Cl *c, const double *x);
56
57bool
58cond_gp_mutate(const struct XCSF *xcsf, const struct Cl *c);
59
60void
61cond_gp_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src);
62
63void
64cond_gp_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x);
65
66void
67cond_gp_free(const struct XCSF *xcsf, const struct Cl *c);
68
69void
70cond_gp_init(const struct XCSF *xcsf, struct Cl *c);
71
72void
73cond_gp_print(const struct XCSF *xcsf, const struct Cl *c);
74
75void
76cond_gp_update(const struct XCSF *xcsf, const struct Cl *c, const double *x,
77 const double *y);
78
79double
80cond_gp_size(const struct XCSF *xcsf, const struct Cl *c);
81
82size_t
83cond_gp_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
84
85size_t
86cond_gp_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
87
88char *
89cond_gp_json_export(const struct XCSF *xcsf, const struct Cl *c);
90
91void
92cond_gp_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json);
93
void cond_gp_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a tree-GP condition.
Definition cond_gp.c:181
char * cond_gp_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a tree-GP condition.
Definition cond_gp.c:242
void cond_gp_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a GP tree that matches the current input.
Definition cond_gp.c:79
static struct CondVtbl const cond_gp_vtbl
Tree GP condition implemented functions.
Definition cond_gp.h:97
void cond_gp_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies a tree-GP condition from one classifier to another.
Definition cond_gp.c:63
size_t cond_gp_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a tree-GP condition to a file.
Definition cond_gp.c:210
bool cond_gp_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy general function.
Definition cond_gp.c:166
void cond_gp_param_defaults(struct XCSF *xcsf)
Initialises default tree GP condition parameters.
Definition cond_gp.c:286
bool cond_gp_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Performs sub-tree crossover with two tree-GP conditions.
Definition cond_gp.c:145
size_t cond_gp_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a tree-GP condition from a file.
Definition cond_gp.c:226
bool cond_gp_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates a tree-GP condition with the self-adaptive rate.
Definition cond_gp.c:130
void cond_gp_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by a tree-GP condition.
Definition cond_gp.c:48
bool cond_gp_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Calculates whether a GP tree condition matches an input.
Definition cond_gp.c:113
double cond_gp_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a tree-GP condition.
Definition cond_gp.c:195
void cond_gp_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a tree GP condition from a cJSON object.
Definition cond_gp.c:307
void cond_gp_init(const struct XCSF *xcsf, struct Cl *c)
Creates and initialises a tree-GP condition.
Definition cond_gp.c:35
void cond_gp_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Dummy update function.
Definition cond_gp.c:96
char * cond_gp_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string of the tree GP parameters.
Definition cond_gp.c:262
char * cond_gp_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the tree GP parameters from a cJSON object.
Definition cond_gp.c:274
Interface for classifier conditions.
An implementation of GP trees based upon TinyGP.
Classifier data structure.
Definition xcsf.h:45
Tree GP condition data structure.
Definition cond_gp.h:33
struct GPTree gp
GP tree.
Definition cond_gp.h:34
Condition interface data structure.
Definition condition.h:104
GP tree data structure.
Definition gp.h:44
XCSF data structure.
Definition xcsf.h:85
XCSF data structures.