XCSF  1.4.7
XCSF learning classifier system
ea.h File Reference

Evolutionary algorithm functions. More...

#include "xcsf.h"
Include dependency graph for ea.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ArgsEA
 Parameters for operating the evolutionary algorithm. More...
 

Macros

#define EA_SELECT_INVALID   (-1)
 Error code for invalid selection. More...
 
#define EA_SELECT_ROULETTE   (0)
 Roulette wheel parental selection. More...
 
#define EA_SELECT_TOURNAMENT   (1)
 Tournament parental selection. More...
 
#define EA_STRING_ROULETTE   ("roulette\0")
 Roulette. More...
 
#define EA_STRING_TOURNAMENT   ("tournament\0")
 Tournament. More...
 
#define EA_SELECT_OPTIONS   "roulette, tournament"
 Valid EA types. More...
 

Functions

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...
 
void ea_param_json_import (struct XCSF *xcsf, cJSON *json)
 Sets the EA parameters from a cJSON object. More...
 
char * ea_param_json_export (const struct XCSF *xcsf)
 Returns a json formatted string representation of the EA parameters. 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)
 

Detailed Description

Evolutionary algorithm functions.

Author
Richard Preen rpree.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om
Date
2015–2022.

Definition in file ea.h.

Macro Definition Documentation

◆ EA_SELECT_INVALID

#define EA_SELECT_INVALID   (-1)

Error code for invalid selection.

Definition at line 28 of file ea.h.

◆ EA_SELECT_OPTIONS

#define EA_SELECT_OPTIONS   "roulette, tournament"

Valid EA types.

Definition at line 35 of file ea.h.

◆ EA_SELECT_ROULETTE

#define EA_SELECT_ROULETTE   (0)

Roulette wheel parental selection.

Definition at line 29 of file ea.h.

◆ EA_SELECT_TOURNAMENT

#define EA_SELECT_TOURNAMENT   (1)

Tournament parental selection.

Definition at line 30 of file ea.h.

◆ EA_STRING_ROULETTE

#define EA_STRING_ROULETTE   ("roulette\0")

Roulette.

Definition at line 32 of file ea.h.

◆ EA_STRING_TOURNAMENT

#define EA_STRING_TOURNAMENT   ("tournament\0")

Tournament.

Definition at line 33 of file ea.h.

Function Documentation

◆ ea()

void ea ( struct XCSF xcsf,
const struct Set set 
)

Executes the evolutionary algorithm (EA).

Parameters
[in]xcsfThe XCSF data structure.
[in]setThe 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ea_param_defaults()

void ea_param_defaults ( struct XCSF xcsf)

Initialises default evolutionary algorithm parameters.

Parameters
[in]xcsfThe 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ea_param_json_export()

char* ea_param_json_export ( const struct XCSF xcsf)

Returns a json formatted string representation of the EA parameters.

Parameters
[in]xcsfXCSF data structure.
Returns
String encoded in json format.

Definition at line 256 of file ea.c.

References EA_SELECT_TOURNAMENT, and ea_type_as_string().

Referenced by param_json_export().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ea_param_json_import()

void ea_param_json_import ( struct XCSF xcsf,
cJSON *  json 
)

Sets the EA parameters from a cJSON object.

Parameters
[in,out]xcsfThe XCSF data structure.
[in]jsoncJSON 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ea_param_load()

size_t ea_param_load ( struct XCSF xcsf,
FILE *  fp 
)

Loads evolutionary algorithm parameters.

Parameters
[in]xcsfThe XCSF data structure.
[in]fpPointer to the output file.
Returns
The total number of elements written.

Definition at line 355 of file ea.c.

Referenced by param_load().

Here is the caller graph for this function:

◆ ea_param_save()

size_t ea_param_save ( const struct XCSF xcsf,
FILE *  fp 
)

Saves evolutionary algorithm parameters.

Parameters
[in]xcsfThe XCSF data structure.
[in]fpPointer to the output file.
Returns
The total number of elements written.

Definition at line 333 of file ea.c.

Referenced by param_save().

Here is the caller graph for this function:

◆ ea_param_set_err_reduc()

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().

Here is the caller graph for this function:

◆ ea_param_set_fit_reduc()

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().

Here is the caller graph for this function:

◆ ea_param_set_lambda()

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().

Here is the caller graph for this function:

◆ ea_param_set_p_crossover()

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().

Here is the caller graph for this function:

◆ ea_param_set_pred_reset()

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().

Here is the caller graph for this function:

◆ ea_param_set_select_size()

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().

Here is the caller graph for this function:

◆ ea_param_set_select_type()

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().

Here is the caller graph for this function:

◆ ea_param_set_subsumption()

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().

Here is the caller graph for this function:

◆ ea_param_set_theta()

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().

Here is the caller graph for this function:

◆ ea_param_set_type_string()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ea_type_as_int()

int ea_type_as_int ( const char *  type)

Returns the integer representation of an EA selection type.

Parameters
[in]typeString representation of an EA type.
Returns
Integer representing the 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().

Here is the caller graph for this function:

◆ ea_type_as_string()

const char* ea_type_as_string ( const int  type)

Returns a string representation of an EA select type from an integer.

Parameters
[in]typeInteger representation of an EA select type.
Returns
String representing the name of the 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().

Here is the caller graph for this function: