XCSF  1.4.7
XCSF learning classifier system
cl.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 "xcsf.h"
27 
28 bool
29 cl_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2);
30 
31 bool
32 cl_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2);
33 
34 bool
35 cl_m(const struct XCSF *xcsf, const struct Cl *c);
36 
37 bool
38 cl_match(const struct XCSF *xcsf, struct Cl *c, const double *x);
39 
40 bool
41 cl_mutate(const struct XCSF *xcsf, const struct Cl *c);
42 
43 bool
44 cl_subsumer(const struct XCSF *xcsf, const struct Cl *c);
45 
46 const double *
47 cl_predict(const struct XCSF *xcsf, const struct Cl *c, const double *x);
48 
49 double
50 cl_acc(const struct XCSF *xcsf, const struct Cl *c);
51 
52 double
53 cl_del_vote(const struct XCSF *xcsf, const struct Cl *c, const double avg_fit);
54 
55 double
56 cl_mfrac(const struct XCSF *xcsf, const struct Cl *c);
57 
58 int
59 cl_action(const struct XCSF *xcsf, struct Cl *c, const double *x);
60 
61 double
62 cl_cond_size(const struct XCSF *xcsf, const struct Cl *c);
63 
64 double
65 cl_pred_size(const struct XCSF *xcsf, const struct Cl *c);
66 
67 size_t
68 cl_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
69 
70 size_t
71 cl_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
72 
73 void
74 cl_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src);
75 
76 void
77 cl_cover(const struct XCSF *xcsf, struct Cl *c, const double *x,
78  const int action);
79 
80 void
81 cl_free(const struct XCSF *xcsf, struct Cl *c);
82 
83 void
84 cl_init(const struct XCSF *xcsf, struct Cl *c, const double size,
85  const int time);
86 
87 void
88 cl_init_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src);
89 
90 void
91 cl_print(const struct XCSF *xcsf, const struct Cl *c, const bool print_cond,
92  const bool print_act, const bool print_pred);
93 
94 void
95 cl_rand(const struct XCSF *xcsf, struct Cl *c);
96 
97 void
98 cl_update(const struct XCSF *xcsf, struct Cl *c, const double *x,
99  const double *y, const int set_num, const bool cur);
100 
101 void
102 cl_update_fit(const struct XCSF *xcsf, struct Cl *c, const double acc_sum,
103  const double acc);
104 
105 char *
106 cl_json_export(const struct XCSF *xcsf, const struct Cl *c,
107  const bool return_cond, const bool return_act,
108  const bool return_pred);
109 
110 void
111 cl_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json);
double cl_pred_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a classifier's prediction.
Definition: cl.c:411
double cl_mfrac(const struct XCSF *xcsf, const struct Cl *c)
Returns the fraction of observed inputs matched by a classifier.
Definition: cl.c:274
void cl_init(const struct XCSF *xcsf, struct Cl *c, const double size, const int time)
Initialises a new classifier - but not condition, action, prediction.
Definition: cl.c:40
bool cl_m(const struct XCSF *xcsf, const struct Cl *c)
Returns whether a classifier matched the most recent input.
Definition: cl.c:290
double cl_cond_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a classifier's condition.
Definition: cl.c:399
void cl_rand(const struct XCSF *xcsf, struct Cl *c)
Initialises random actions, conditions and predictions.
Definition: cl.c:129
void cl_update(const struct XCSF *xcsf, struct Cl *c, const double *x, const double *y, const int set_num, const bool cur)
Updates a classifier's experience, error, and set size.
Definition: cl.c:183
void cl_update_fit(const struct XCSF *xcsf, struct Cl *c, const double acc_sum, const double acc)
Updates the fitness of a classifier.
Definition: cl.c:211
int cl_action(const struct XCSF *xcsf, struct Cl *c, const double *x)
Computes the current classifier action using the input.
Definition: cl.c:304
const double * cl_predict(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Computes the current classifier prediction using the input.
Definition: cl.c:318
char * cl_json_export(const struct XCSF *xcsf, const struct Cl *c, const bool return_cond, const bool return_act, const bool return_pred)
Returns a json formatted string representation of a classifier.
Definition: cl.c:486
bool cl_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Returns whether classifier c1 is more general than c2.
Definition: cl.c:347
void cl_init_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Initialises and creates a copy of one classifier from another.
Definition: cl.c:84
bool cl_match(const struct XCSF *xcsf, struct Cl *c, const double *x)
Calculates whether a classifier matches an input.
Definition: cl.c:257
bool cl_mutate(const struct XCSF *xcsf, const struct Cl *c)
Performs classifier mutation.
Definition: cl.c:362
size_t cl_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a classifier to a file.
Definition: cl.c:424
void cl_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies condition, action, and prediction structures.
Definition: cl.c:63
size_t cl_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a classifier from a file.
Definition: cl.c:452
bool cl_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Performs classifier crossover.
Definition: cl.c:381
void cl_cover(const struct XCSF *xcsf, struct Cl *c, const double *x, const int action)
Covers the condition and action for a classifier.
Definition: cl.c:113
void cl_free(const struct XCSF *xcsf, struct Cl *c)
Frees the memory used by a classifier.
Definition: cl.c:223
double cl_acc(const struct XCSF *xcsf, const struct Cl *c)
Returns the accuracy of a classifier.
Definition: cl.c:162
void cl_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a classifier from a cJSON object.
Definition: cl.c:608
double cl_del_vote(const struct XCSF *xcsf, const struct Cl *c, const double avg_fit)
Returns the deletion vote of a classifier.
Definition: cl.c:147
bool cl_subsumer(const struct XCSF *xcsf, const struct Cl *c)
Returns whether a classifier is a potential subsumer.
Definition: cl.c:331
void cl_print(const struct XCSF *xcsf, const struct Cl *c, const bool print_cond, const bool print_act, const bool print_pred)
Prints a classifier.
Definition: cl.c:241
Definition: __init__.py:1
Classifier data structure.
Definition: xcsf.h:45
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.