XCSF  1.4.7
XCSF learning classifier system
cond_ellipsoid.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 "xcsf.h"
28 
32 struct CondEllipsoid {
33  double *center;
34  double *spread;
35  double *mu;
36 };
37 
38 bool
39 cond_ellipsoid_crossover(const struct XCSF *xcsf, const struct Cl *c1,
40  const struct Cl *c2);
41 
42 bool
43 cond_ellipsoid_general(const struct XCSF *xcsf, const struct Cl *c1,
44  const struct Cl *c2);
45 
46 bool
47 cond_ellipsoid_match(const struct XCSF *xcsf, const struct Cl *c,
48  const double *x);
49 
50 bool
51 cond_ellipsoid_mutate(const struct XCSF *xcsf, const struct Cl *c);
52 
53 void
54 cond_ellipsoid_copy(const struct XCSF *xcsf, struct Cl *dest,
55  const struct Cl *src);
56 
57 void
58 cond_ellipsoid_cover(const struct XCSF *xcsf, const struct Cl *c,
59  const double *x);
60 
61 void
62 cond_ellipsoid_free(const struct XCSF *xcsf, const struct Cl *c);
63 
64 void
65 cond_ellipsoid_init(const struct XCSF *xcsf, struct Cl *c);
66 
67 void
68 cond_ellipsoid_print(const struct XCSF *xcsf, const struct Cl *c);
69 
70 void
71 cond_ellipsoid_update(const struct XCSF *xcsf, const struct Cl *c,
72  const double *x, const double *y);
73 
74 double
75 cond_ellipsoid_size(const struct XCSF *xcsf, const struct Cl *c);
76 
77 size_t
78 cond_ellipsoid_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
79 
80 size_t
81 cond_ellipsoid_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
82 
83 char *
84 cond_ellipsoid_json_export(const struct XCSF *xcsf, const struct Cl *c);
85 
86 void
87 cond_ellipsoid_json_import(const struct XCSF *xcsf, struct Cl *c,
88  const cJSON *json);
89 
93 static struct CondVtbl const cond_ellipsoid_vtbl = {
102 };
void cond_ellipsoid_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by a hyperellipsoid condition.
size_t cond_ellipsoid_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a hyperellipsoid condition from a file.
void cond_ellipsoid_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a hyperellipsoid condition.
size_t cond_ellipsoid_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a hyperellipsoid condition to a file.
bool cond_ellipsoid_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Calculates whether a hyperellipsoid condition matches an input.
void cond_ellipsoid_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a hyperellipsoid from a cJSON object.
double cond_ellipsoid_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a hyperellipsoid condition.
void cond_ellipsoid_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Updates a hyperellipsoid, sliding the centers towards the mean input.
char * cond_ellipsoid_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a hyperellipsoid.
bool cond_ellipsoid_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Performs uniform crossover with two hyperellipsoid conditions.
bool cond_ellipsoid_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates a hyperellipsoid condition with the self-adaptive rate.
bool cond_ellipsoid_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Returns whether classifier c1 has a condition more general than c2.
void cond_ellipsoid_init(const struct XCSF *xcsf, struct Cl *c)
Creates and initialises a hyperellipsoid condition.
void cond_ellipsoid_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies a hyperellipsoid condition from one classifier to another.
void cond_ellipsoid_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a hyperellipsoid that matches the current input.
static struct CondVtbl const cond_ellipsoid_vtbl
Hyperellipsoid condition implemented functions.
Interface for classifier conditions.
Definition: __init__.py:1
Classifier data structure.
Definition: xcsf.h:45
Hyperellipsoid condition data structure.
double * center
Centers.
double * spread
Spreads.
double * mu
Mutation rates.
Condition interface data structure.
Definition: condition.h:104
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.