XCSF 1.4.8
XCSF learning classifier system
Loading...
Searching...
No Matches
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
28bool
29cl_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2);
30
31bool
32cl_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2);
33
34bool
35cl_m(const struct XCSF *xcsf, const struct Cl *c);
36
37bool
38cl_match(const struct XCSF *xcsf, struct Cl *c, const double *x);
39
40bool
41cl_mutate(const struct XCSF *xcsf, const struct Cl *c);
42
43bool
44cl_subsumer(const struct XCSF *xcsf, const struct Cl *c);
45
46const double *
47cl_predict(const struct XCSF *xcsf, const struct Cl *c, const double *x);
48
49double
50cl_acc(const struct XCSF *xcsf, const struct Cl *c);
51
52double
53cl_del_vote(const struct XCSF *xcsf, const struct Cl *c, const double avg_fit);
54
55double
56cl_mfrac(const struct XCSF *xcsf, const struct Cl *c);
57
58int
59cl_action(const struct XCSF *xcsf, struct Cl *c, const double *x);
60
61double
62cl_cond_size(const struct XCSF *xcsf, const struct Cl *c);
63
64double
65cl_pred_size(const struct XCSF *xcsf, const struct Cl *c);
66
67size_t
68cl_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp);
69
70size_t
71cl_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp);
72
73void
74cl_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src);
75
76void
77cl_cover(const struct XCSF *xcsf, struct Cl *c, const double *x,
78 const int action);
79
80void
81cl_free(const struct XCSF *xcsf, struct Cl *c);
82
83void
84cl_init(const struct XCSF *xcsf, struct Cl *c, const double size,
85 const int time);
86
87void
88cl_init_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src);
89
90void
91cl_print(const struct XCSF *xcsf, const struct Cl *c, const bool print_cond,
92 const bool print_act, const bool print_pred);
93
94void
95cl_rand(const struct XCSF *xcsf, struct Cl *c);
96
97void
98cl_update(const struct XCSF *xcsf, struct Cl *c, const double *x,
99 const double *y, const int set_num, const bool cur);
100
101void
102cl_update_fit(const struct XCSF *xcsf, struct Cl *c, const double acc_sum,
103 const double acc);
104
105char *
106cl_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
110void
111cl_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
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
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
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
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
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
Classifier data structure.
Definition xcsf.h:45
XCSF data structure.
Definition xcsf.h:85
XCSF data structures.