XCSF 1.4.8
XCSF learning classifier system
Loading...
Searching...
No Matches
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
40struct ArgsEA {
42 double select_size;
43 double err_reduc;
44 double fit_reduc;
45 double p_crossover;
46 double theta;
47 int lambda;
50};
51
52void
53ea(struct XCSF *xcsf, const struct Set *set);
54
55void
57
58void
59ea_param_json_import(struct XCSF *xcsf, cJSON *json);
60
61char *
62ea_param_json_export(const struct XCSF *xcsf);
63
64size_t
65ea_param_save(const struct XCSF *xcsf, FILE *fp);
66
67size_t
68ea_param_load(struct XCSF *xcsf, FILE *fp);
69
70const char *
71ea_type_as_string(const int type);
72
73int
74ea_type_as_int(const char *type);
75
76/* parameter setters */
77
78const char *
79ea_param_set_select_size(struct XCSF *xcsf, const double a);
80
81const char *
82ea_param_set_theta(struct XCSF *xcsf, const double a);
83
84const char *
85ea_param_set_p_crossover(struct XCSF *xcsf, const double a);
86
87const char *
88ea_param_set_lambda(struct XCSF *xcsf, const int a);
89
90const char *
91ea_param_set_err_reduc(struct XCSF *xcsf, const double a);
92
93const char *
94ea_param_set_fit_reduc(struct XCSF *xcsf, const double a);
95
96const char *
97ea_param_set_subsumption(struct XCSF *xcsf, const bool a);
98
99const char *
100ea_param_set_pred_reset(struct XCSF *xcsf, const bool a);
101
102int
103ea_param_set_select_type(struct XCSF *xcsf, const int a);
104
105int
106ea_param_set_type_string(struct XCSF *xcsf, const char *a);
char * ea_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string representation of the EA parameters.
Definition ea.c:256
void ea(struct XCSF *xcsf, const struct Set *set)
Executes the evolutionary algorithm (EA).
Definition ea.c:199
const char * ea_param_set_fit_reduc(struct XCSF *xcsf, const double a)
Definition ea.c:458
void ea_param_defaults(struct XCSF *xcsf)
Initialises default evolutionary algorithm parameters.
Definition ea.c:237
const char * ea_param_set_subsumption(struct XCSF *xcsf, const bool a)
Definition ea.c:468
const char * ea_param_set_p_crossover(struct XCSF *xcsf, const double a)
Definition ea.c:428
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
const char * ea_param_set_theta(struct XCSF *xcsf, const double a)
Definition ea.c:418
int ea_type_as_int(const char *type)
Returns the integer representation of an EA selection type.
Definition ea.c:394
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
const char * ea_param_set_select_size(struct XCSF *xcsf, const double a)
Definition ea.c:408
const char * ea_param_set_err_reduc(struct XCSF *xcsf, const double a)
Definition ea.c:448
int ea_param_set_select_type(struct XCSF *xcsf, const int a)
Definition ea.c:482
const char * ea_param_set_lambda(struct XCSF *xcsf, const int a)
Definition ea.c:438
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_type_as_string(const int type)
Returns a string representation of an EA select type from an integer.
Definition ea.c:376
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.