XCSF  1.4.7
XCSF learning classifier system
ea.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 #define EA_SELECT_INVALID (-1)
29 #define EA_SELECT_ROULETTE (0)
30 #define EA_SELECT_TOURNAMENT (1)
31 
32 #define EA_STRING_ROULETTE ("roulette\0")
33 #define EA_STRING_TOURNAMENT ("tournament\0")
34 
35 #define EA_SELECT_OPTIONS "roulette, tournament"
36 
40 struct ArgsEA {
41  bool subsumption;
42  double select_size;
43  double err_reduc;
44  double fit_reduc;
45  double p_crossover;
46  double theta;
47  int lambda;
49  bool pred_reset;
50 };
51 
52 void
53 ea(struct XCSF *xcsf, const struct Set *set);
54 
55 void
56 ea_param_defaults(struct XCSF *xcsf);
57 
58 void
59 ea_param_json_import(struct XCSF *xcsf, cJSON *json);
60 
61 char *
62 ea_param_json_export(const struct XCSF *xcsf);
63 
64 size_t
65 ea_param_save(const struct XCSF *xcsf, FILE *fp);
66 
67 size_t
68 ea_param_load(struct XCSF *xcsf, FILE *fp);
69 
70 const char *
71 ea_type_as_string(const int type);
72 
73 int
74 ea_type_as_int(const char *type);
75 
76 /* parameter setters */
77 
78 const char *
79 ea_param_set_select_size(struct XCSF *xcsf, const double a);
80 
81 const char *
82 ea_param_set_theta(struct XCSF *xcsf, const double a);
83 
84 const char *
85 ea_param_set_p_crossover(struct XCSF *xcsf, const double a);
86 
87 const char *
88 ea_param_set_lambda(struct XCSF *xcsf, const int a);
89 
90 const char *
91 ea_param_set_err_reduc(struct XCSF *xcsf, const double a);
92 
93 const char *
94 ea_param_set_fit_reduc(struct XCSF *xcsf, const double a);
95 
96 const char *
97 ea_param_set_subsumption(struct XCSF *xcsf, const bool a);
98 
99 const char *
100 ea_param_set_pred_reset(struct XCSF *xcsf, const bool a);
101 
102 int
103 ea_param_set_select_type(struct XCSF *xcsf, const int a);
104 
105 int
106 ea_param_set_type_string(struct XCSF *xcsf, const char *a);
const char * ea_param_set_subsumption(struct XCSF *xcsf, const bool a)
Definition: ea.c:468
void ea(struct XCSF *xcsf, const struct Set *set)
Executes the evolutionary algorithm (EA).
Definition: ea.c:199
void ea_param_defaults(struct XCSF *xcsf)
Initialises default evolutionary algorithm parameters.
Definition: ea.c:237
const char * ea_param_set_lambda(struct XCSF *xcsf, const int a)
Definition: ea.c:438
const char * ea_param_set_theta(struct XCSF *xcsf, const double a)
Definition: ea.c:418
const char * ea_type_as_string(const int type)
Returns a string representation of an EA select type from an integer.
Definition: ea.c:376
const char * ea_param_set_err_reduc(struct XCSF *xcsf, const double a)
Definition: ea.c:448
char * ea_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string representation of the EA parameters.
Definition: ea.c:256
const char * ea_param_set_fit_reduc(struct XCSF *xcsf, const double a)
Definition: ea.c:458
const char * ea_param_set_pred_reset(struct XCSF *xcsf, const bool a)
Definition: ea.c:475
size_t ea_param_load(struct XCSF *xcsf, FILE *fp)
Loads evolutionary algorithm parameters.
Definition: ea.c:355
int ea_type_as_int(const char *type)
Returns the integer representation of an EA selection type.
Definition: ea.c:394
const char * ea_param_set_p_crossover(struct XCSF *xcsf, const double a)
Definition: ea.c:428
int ea_param_set_type_string(struct XCSF *xcsf, const char *a)
Definition: ea.c:492
size_t ea_param_save(const struct XCSF *xcsf, FILE *fp)
Saves evolutionary algorithm parameters.
Definition: ea.c:333
int ea_param_set_select_type(struct XCSF *xcsf, const int a)
Definition: ea.c:482
void ea_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the EA parameters from a cJSON object.
Definition: ea.c:282
const char * ea_param_set_select_size(struct XCSF *xcsf, const double a)
Definition: ea.c:408
Definition: __init__.py:1
Parameters for operating the evolutionary algorithm.
Definition: ea.h:40
double theta
Average match set time between EA invocations.
Definition: ea.h:46
double p_crossover
Probability of applying crossover.
Definition: ea.h:45
double err_reduc
Amount to reduce an offspring's error.
Definition: ea.h:43
int select_type
Roulette or tournament for EA parental selection.
Definition: ea.h:48
int lambda
Number of offspring to create each EA invocation.
Definition: ea.h:47
double fit_reduc
Amount to reduce an offspring's fitness.
Definition: ea.h:44
double select_size
Fraction of set size for tournaments.
Definition: ea.h:42
bool subsumption
Whether to try and subsume offspring classifiers.
Definition: ea.h:41
bool pred_reset
Whether to reset or copy offspring predictions.
Definition: ea.h:49
Classifier set.
Definition: xcsf.h:76
XCSF data structure.
Definition: xcsf.h:85
XCSF data structures.