XCSF
1.4.7
XCSF learning classifier system
|
Evolutionary algorithm functions. More...
Go to the source code of this file.
Functions | |
static void | ea_init_offspring (const struct XCSF *xcsf, const struct Cl *c1p, const struct Cl *c2p, struct Cl *c1, struct Cl *c2, const bool cmod) |
Initialises offspring error and fitness. More... | |
static void | ea_subsume (struct XCSF *xcsf, struct Cl *c, struct Cl *c1p, struct Cl *c2p, const struct Set *set) |
Performs evolutionary algorithm subsumption. More... | |
static void | ea_add (struct XCSF *xcsf, const struct Set *set, struct Cl *c1p, struct Cl *c2p, struct Cl *c1, const bool cmod, const bool mmod) |
Adds offspring to the population. More... | |
static struct Cl * | ea_select_rw (const struct XCSF *xcsf, const struct Set *set, const double fit_sum) |
Selects a classifier from the set via roulette wheel. More... | |
static struct Cl * | ea_select_tournament (const struct XCSF *xcsf, const struct Set *set) |
Selects a classifier from the set via tournament. More... | |
static void | ea_select (const struct XCSF *xcsf, const struct Set *set, struct Cl **c1p, struct Cl **c2p) |
Selects two parents. More... | |
void | ea (struct XCSF *xcsf, const struct Set *set) |
Executes the evolutionary algorithm (EA). More... | |
void | ea_param_defaults (struct XCSF *xcsf) |
Initialises default evolutionary algorithm parameters. More... | |
char * | ea_param_json_export (const struct XCSF *xcsf) |
Returns a json formatted string representation of the EA parameters. More... | |
void | ea_param_json_import (struct XCSF *xcsf, cJSON *json) |
Sets the EA parameters from a cJSON object. More... | |
size_t | ea_param_save (const struct XCSF *xcsf, FILE *fp) |
Saves evolutionary algorithm parameters. More... | |
size_t | ea_param_load (struct XCSF *xcsf, FILE *fp) |
Loads evolutionary algorithm parameters. More... | |
const char * | ea_type_as_string (const int type) |
Returns a string representation of an EA select type from an integer. More... | |
int | ea_type_as_int (const char *type) |
Returns the integer representation of an EA selection type. More... | |
const char * | ea_param_set_select_size (struct XCSF *xcsf, const double a) |
const char * | ea_param_set_theta (struct XCSF *xcsf, const double a) |
const char * | ea_param_set_p_crossover (struct XCSF *xcsf, const double a) |
const char * | ea_param_set_lambda (struct XCSF *xcsf, const int a) |
const char * | ea_param_set_err_reduc (struct XCSF *xcsf, const double a) |
const char * | ea_param_set_fit_reduc (struct XCSF *xcsf, const double a) |
const char * | ea_param_set_subsumption (struct XCSF *xcsf, const bool a) |
const char * | ea_param_set_pred_reset (struct XCSF *xcsf, const bool a) |
int | ea_param_set_select_type (struct XCSF *xcsf, const int a) |
int | ea_param_set_type_string (struct XCSF *xcsf, const char *a) |
Executes the evolutionary algorithm (EA).
[in] | xcsf | The XCSF data structure. |
[in] | set | The set in which to run the EA. |
Definition at line 199 of file ea.c.
References cl_copy(), cl_crossover(), cl_init(), cl_mutate(), clset_mean_time(), clset_pset_enforce_limit(), clset_set_times(), ea_add(), ea_init_offspring(), ea_select(), Cl::size, Set::size, and Cl::time.
Referenced by xcs_rl_update(), and xcs_supervised_trial().
|
static |
Adds offspring to the population.
[in] | xcsf | The XCSF data structure. |
[in] | set | The set in which the EA is being run. |
[in] | c1p | First parent classifier. |
[in] | c2p | Second parent classifier. |
[in] | c1 | The offspring classifier to add. |
[in] | cmod | Whether crossover modified the offspring. |
[in] | mmod | Whether mutation modified the offspring. |
Definition at line 113 of file ea.c.
References cl_free(), clset_add(), ea_subsume(), and Cl::num.
Referenced by ea().
|
static |
Initialises offspring error and fitness.
[in] | xcsf | The XCSF data structure. |
[in] | c1p | First parent classifier. |
[in] | c2p | Second parent classifier. |
[in] | c1 | The first offspring classifier to initialise. |
[in] | c2 | The second offspring classifier to initialise. |
[in] | cmod | Whether crossover modified the offspring. |
Definition at line 39 of file ea.c.
References Cl::err, Cl::fit, and Cl::num.
Referenced by ea().
void ea_param_defaults | ( | struct XCSF * | xcsf | ) |
Initialises default evolutionary algorithm parameters.
[in] | xcsf | The XCSF data structure. |
Definition at line 237 of file ea.c.
References ea_param_set_err_reduc(), ea_param_set_fit_reduc(), ea_param_set_lambda(), ea_param_set_p_crossover(), ea_param_set_pred_reset(), ea_param_set_select_size(), ea_param_set_select_type(), ea_param_set_subsumption(), ea_param_set_theta(), and EA_SELECT_ROULETTE.
Referenced by param_init().
char* ea_param_json_export | ( | const struct XCSF * | xcsf | ) |
Returns a json formatted string representation of the EA parameters.
[in] | xcsf | XCSF data structure. |
Definition at line 256 of file ea.c.
References EA_SELECT_TOURNAMENT, and ea_type_as_string().
Referenced by param_json_export().
void ea_param_json_import | ( | struct XCSF * | xcsf, |
cJSON * | json | ||
) |
Sets the EA parameters from a cJSON object.
[in,out] | xcsf | The XCSF data structure. |
[in] | json | cJSON object. |
Definition at line 282 of file ea.c.
References catch_error(), ea_param_set_err_reduc(), ea_param_set_fit_reduc(), ea_param_set_lambda(), ea_param_set_p_crossover(), ea_param_set_pred_reset(), ea_param_set_select_size(), ea_param_set_subsumption(), ea_param_set_theta(), ea_param_set_type_string(), EA_SELECT_INVALID, and EA_SELECT_OPTIONS.
Referenced by param_json_import().
size_t ea_param_load | ( | struct XCSF * | xcsf, |
FILE * | fp | ||
) |
Loads evolutionary algorithm parameters.
[in] | xcsf | The XCSF data structure. |
[in] | fp | Pointer to the output file. |
Definition at line 355 of file ea.c.
Referenced by param_load().
size_t ea_param_save | ( | const struct XCSF * | xcsf, |
FILE * | fp | ||
) |
Saves evolutionary algorithm parameters.
[in] | xcsf | The XCSF data structure. |
[in] | fp | Pointer to the output file. |
Definition at line 333 of file ea.c.
Referenced by param_save().
const char* ea_param_set_err_reduc | ( | struct XCSF * | xcsf, |
const double | a | ||
) |
Definition at line 448 of file ea.c.
Referenced by ea_param_defaults(), and ea_param_json_import().
const char* ea_param_set_fit_reduc | ( | struct XCSF * | xcsf, |
const double | a | ||
) |
Definition at line 458 of file ea.c.
Referenced by ea_param_defaults(), and ea_param_json_import().
const char* ea_param_set_lambda | ( | struct XCSF * | xcsf, |
const int | a | ||
) |
Definition at line 438 of file ea.c.
Referenced by ea_param_defaults(), and ea_param_json_import().
const char* ea_param_set_p_crossover | ( | struct XCSF * | xcsf, |
const double | a | ||
) |
Definition at line 428 of file ea.c.
Referenced by ea_param_defaults(), and ea_param_json_import().
const char* ea_param_set_pred_reset | ( | struct XCSF * | xcsf, |
const bool | a | ||
) |
Definition at line 475 of file ea.c.
Referenced by ea_param_defaults(), and ea_param_json_import().
const char* ea_param_set_select_size | ( | struct XCSF * | xcsf, |
const double | a | ||
) |
Definition at line 408 of file ea.c.
Referenced by ea_param_defaults(), and ea_param_json_import().
int ea_param_set_select_type | ( | struct XCSF * | xcsf, |
const int | a | ||
) |
Definition at line 482 of file ea.c.
References EA_SELECT_INVALID, EA_SELECT_ROULETTE, and EA_SELECT_TOURNAMENT.
Referenced by ea_param_defaults().
const char* ea_param_set_subsumption | ( | struct XCSF * | xcsf, |
const bool | a | ||
) |
Definition at line 468 of file ea.c.
Referenced by ea_param_defaults(), and ea_param_json_import().
const char* ea_param_set_theta | ( | struct XCSF * | xcsf, |
const double | a | ||
) |
Definition at line 418 of file ea.c.
Referenced by ea_param_defaults(), and ea_param_json_import().
int ea_param_set_type_string | ( | struct XCSF * | xcsf, |
const char * | a | ||
) |
Definition at line 492 of file ea.c.
References EA_SELECT_INVALID, and ea_type_as_int().
Referenced by ea_param_json_import().
|
static |
Selects two parents.
[in] | xcsf | The XCSF data structure. |
[in] | set | The set in which the EA is being run. |
[out] | c1p | First selected parent classifier. |
[out] | c2p | Second selected parent classifier. |
Definition at line 180 of file ea.c.
References clset_total_fit(), EA_SELECT_ROULETTE, ea_select_rw(), and ea_select_tournament().
Referenced by ea().
|
static |
Selects a classifier from the set via roulette wheel.
[in] | xcsf | The XCSF data structure. |
[in] | set | The set to select from. |
[in] | fit_sum | The sum of all the fitnesses in the set. |
Definition at line 135 of file ea.c.
References Clist::cl, Cl::fit, Set::list, Clist::next, and rand_uniform().
Referenced by ea_select().
Selects a classifier from the set via tournament.
[in] | xcsf | The XCSF data structure. |
[in] | set | The set to select from. |
Definition at line 156 of file ea.c.
References Clist::cl, Cl::fit, Set::list, Clist::next, and rand_uniform().
Referenced by ea_select().
|
static |
Performs evolutionary algorithm subsumption.
[in] | xcsf | The XCSF data structure. |
[in] | c | The offspring classifier to attempt to subsume. |
[in] | c1p | First parent classifier. |
[in] | c2p | Second parent classifier. |
[in] | set | The set in which the EA is being run. |
Definition at line 67 of file ea.c.
References Clist::cl, cl_free(), cl_general(), cl_subsumer(), clset_add(), Set::list, Clist::next, Cl::num, rand_uniform_int(), and Set::size.
Referenced by ea_add().
int ea_type_as_int | ( | const char * | type | ) |
Returns the integer representation of an EA selection type.
[in] | type | String representation of an EA type. |
Definition at line 394 of file ea.c.
References EA_SELECT_INVALID, EA_SELECT_ROULETTE, EA_SELECT_TOURNAMENT, EA_STRING_ROULETTE, and EA_STRING_TOURNAMENT.
Referenced by ea_param_set_type_string().
const char* ea_type_as_string | ( | const int | type | ) |
Returns a string representation of an EA select type from an integer.
[in] | type | Integer representation of an EA select type. |
Definition at line 376 of file ea.c.
References EA_SELECT_ROULETTE, EA_SELECT_TOURNAMENT, EA_STRING_ROULETTE, and EA_STRING_TOURNAMENT.
Referenced by ea_param_json_export().