XCSF
1.4.7
XCSF learning classifier system
|
Interface for classifier actions. More...
#include "xcsf.h"
Go to the source code of this file.
Data Structures | |
struct | ArgsAct |
Parameters for initialising and operating actions. More... | |
struct | ActVtbl |
Action interface data structure. More... | |
Macros | |
#define | ACT_TYPE_INVALID (-1) |
Error code for invalid actions. More... | |
#define | ACT_TYPE_INTEGER (0) |
Action type integer. More... | |
#define | ACT_TYPE_NEURAL (1) |
Action type neural network. More... | |
#define | ACT_STRING_INTEGER ("integer\0") |
Integer. More... | |
#define | ACT_STRING_NEURAL ("neural\0") |
Neural. More... | |
#define | ACT_TYPE_OPTIONS "integer, neural" |
Functions | |
void | action_set (const struct XCSF *xcsf, struct Cl *c) |
Sets a classifier's action functions to the implementations. More... | |
const char * | action_type_as_string (const int type) |
Returns a string representation of an action type from an integer. More... | |
int | action_type_as_int (const char *type) |
Returns the integer representation of an action type given a name. More... | |
void | action_param_defaults (struct XCSF *xcsf) |
Initialises default action parameters. More... | |
void | action_param_free (struct XCSF *xcsf) |
Frees action parameters. More... | |
char * | action_param_json_import (struct XCSF *xcsf, cJSON *json) |
Sets the action parameters from a cJSON object. More... | |
char * | action_param_json_export (const struct XCSF *xcsf) |
Returns a json formatted string of the action parameters. More... | |
size_t | action_param_save (const struct XCSF *xcsf, FILE *fp) |
Saves action parameters. More... | |
size_t | action_param_load (struct XCSF *xcsf, FILE *fp) |
Loads action parameters. More... | |
static size_t | act_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp) |
Writes the action to a file. More... | |
static size_t | act_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp) |
Reads the action from a file. More... | |
static bool | act_general (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2) |
Returns whether the action of classifier c1 is more general than c2. More... | |
static bool | act_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2) |
Performs classifier action crossover. More... | |
static bool | act_mutate (const struct XCSF *xcsf, const struct Cl *c) |
Performs classifier action mutation. More... | |
static int | act_compute (const struct XCSF *xcsf, const struct Cl *c, const double *x) |
Computes the current classifier action using the input. More... | |
static void | act_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src) |
Copies the action from one classifier to another. More... | |
static void | act_cover (const struct XCSF *xcsf, const struct Cl *c, const double *x, const int action) |
Generates an action that matches the specified value. More... | |
static void | act_free (const struct XCSF *xcsf, const struct Cl *c) |
Frees the memory used by the classifier action. More... | |
static void | act_init (const struct XCSF *xcsf, struct Cl *c) |
Initialises a classifier's action. More... | |
static void | act_print (const struct XCSF *xcsf, const struct Cl *c) |
Prints the classifier action. More... | |
static void | act_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y) |
Updates the classifier's action. More... | |
static char * | act_json_export (const struct XCSF *xcsf, const struct Cl *c) |
Returns a json formatted string representation of an action . More... | |
static void | act_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json) |
Creates an action from a cJSON object. More... | |
int | action_param_set_type_string (struct XCSF *xcsf, const char *a) |
void | action_param_set_type (struct XCSF *xcsf, const int a) |
#define ACT_TYPE_INVALID (-1) |
Computes the current classifier action using the input.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier calculating the action. |
[in] | x | The input state. |
Definition at line 173 of file action.h.
References ActVtbl::act_impl_compute, and Cl::act_vptr.
Referenced by cl_action().
Copies the action from one classifier to another.
[in] | xcsf | The XCSF data structure. |
[in] | dest | The destination classifier. |
[in] | src | The source classifier. |
Definition at line 185 of file action.h.
References ActVtbl::act_impl_copy, and Cl::act_vptr.
Referenced by cl_copy(), and cl_init_copy().
|
static |
Generates an action that matches the specified value.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose action is being covered. |
[in] | x | The input state to cover. |
[in] | action | The action to cover. |
Definition at line 198 of file action.h.
References ActVtbl::act_impl_cover, Cl::act_vptr, and Cl::action.
Referenced by cl_cover().
|
static |
Performs classifier action crossover.
[in] | xcsf | The XCSF data structure. |
[in] | c1 | The first classifier whose action is being crossed. |
[in] | c2 | The second classifier whose action is being crossed. |
Definition at line 148 of file action.h.
References ActVtbl::act_impl_crossover, and Cl::act_vptr.
Referenced by cl_crossover().
Frees the memory used by the classifier action.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose action is to be freed. |
Definition at line 210 of file action.h.
References ActVtbl::act_impl_free, and Cl::act_vptr.
Referenced by cl_free().
|
static |
Returns whether the action of classifier c1 is more general than c2.
[in] | xcsf | The XCSF data structure. |
[in] | c1 | The classifier whose action is tested to be more general. |
[in] | c2 | The classifier whose action is tested to be more specific. |
Definition at line 135 of file action.h.
References ActVtbl::act_impl_general, and Cl::act_vptr.
Referenced by cl_general().
Initialises a classifier's action.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose action is to be initialised. |
Definition at line 221 of file action.h.
References ActVtbl::act_impl_init, and Cl::act_vptr.
Referenced by cl_rand().
Returns a json formatted string representation of an action .
[in] | xcsf | The XCSF data structure. |
[in] | c | Classifier whose action is to be returned. |
Definition at line 258 of file action.h.
References ActVtbl::act_impl_json_export, and Cl::act_vptr.
Referenced by cl_json_export().
Creates an action from a cJSON object.
[in] | xcsf | The XCSF data structure. |
[in,out] | c | The classifier whose action is to be initialised. |
[in] | json | cJSON object. |
Definition at line 270 of file action.h.
References ActVtbl::act_impl_json_import, Cl::act_vptr, action_type_as_int(), and action_type_as_string().
Referenced by cl_json_import().
Reads the action from a file.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose action is to be read. |
[in] | fp | Pointer to the file to be read. |
Definition at line 122 of file action.h.
References ActVtbl::act_impl_load, and Cl::act_vptr.
Referenced by cl_load().
Performs classifier action mutation.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose action is being mutated. |
Definition at line 160 of file action.h.
References ActVtbl::act_impl_mutate, and Cl::act_vptr.
Referenced by cl_mutate().
Prints the classifier action.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose action is to be printed. |
Definition at line 232 of file action.h.
References ActVtbl::act_impl_print, and Cl::act_vptr.
Writes the action to a file.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose action is to be written. |
[in] | fp | Pointer to the file to be written. |
Definition at line 109 of file action.h.
References ActVtbl::act_impl_save, and Cl::act_vptr.
Referenced by cl_save().
|
static |
Updates the classifier's action.
[in] | xcsf | The XCSF data structure. |
[in] | c | Classifier whose action is to be updated. |
[in] | x | Input state. |
[in] | y | Truth/payoff value. |
Definition at line 245 of file action.h.
References ActVtbl::act_impl_update, and Cl::act_vptr.
Referenced by cl_update().
void action_param_defaults | ( | struct XCSF * | xcsf | ) |
Initialises default action parameters.
[in] | xcsf | The XCSF data structure. |
Definition at line 91 of file action.c.
References act_neural_param_defaults(), ACT_TYPE_INTEGER, and action_param_set_type().
Referenced by param_init().
void action_param_free | ( | struct XCSF * | xcsf | ) |
Frees action parameters.
[in] | xcsf | The XCSF data structure. |
Definition at line 184 of file action.c.
References layer_args_free().
Referenced by param_free().
char* action_param_json_export | ( | const struct XCSF * | xcsf | ) |
Returns a json formatted string of the action parameters.
[in] | xcsf | XCSF data structure. |
Definition at line 103 of file action.c.
References ACT_TYPE_NEURAL, action_type_as_string(), layer_args_json_export(), and ArgsAct::type.
Referenced by param_json_export().
char* action_param_json_import | ( | struct XCSF * | xcsf, |
cJSON * | json | ||
) |
Sets the action parameters from a cJSON object.
[in,out] | xcsf | XCSF data structure. |
[in] | json | cJSON object. |
Definition at line 131 of file action.c.
References act_neural_param_json_import(), ACT_TYPE_INTEGER, and ACT_TYPE_NEURAL.
Referenced by param_json_import_action().
size_t action_param_load | ( | struct XCSF * | xcsf, |
FILE * | fp | ||
) |
Loads action parameters.
[in] | xcsf | The XCSF data structure. |
[in] | fp | Pointer to the output file. |
Definition at line 170 of file action.c.
References ArgsAct::largs, layer_args_load(), and ArgsAct::type.
Referenced by param_load().
size_t action_param_save | ( | const struct XCSF * | xcsf, |
FILE * | fp | ||
) |
Saves action parameters.
[in] | xcsf | The XCSF data structure. |
[in] | fp | Pointer to the output file. |
Definition at line 154 of file action.c.
References ArgsAct::largs, layer_args_save(), and ArgsAct::type.
Referenced by param_save().
void action_param_set_type | ( | struct XCSF * | xcsf, |
const int | a | ||
) |
Definition at line 202 of file action.c.
Referenced by action_param_defaults().
int action_param_set_type_string | ( | struct XCSF * | xcsf, |
const char * | a | ||
) |
Definition at line 192 of file action.c.
References ACT_TYPE_INVALID, action_type_as_int(), and ArgsAct::type.
Referenced by param_json_import_action().
Sets a classifier's action functions to the implementations.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier to set. |
Definition at line 35 of file action.c.
References act_integer_vtbl, act_neural_vtbl, ACT_TYPE_INTEGER, ACT_TYPE_NEURAL, and Cl::act_vptr.
Referenced by cl_load(), and cl_rand().
int action_type_as_int | ( | const char * | type | ) |
Returns the integer representation of an action type given a name.
[in] | type | String representation of a condition type. |
Definition at line 75 of file action.c.
References ACT_STRING_INTEGER, ACT_STRING_NEURAL, ACT_TYPE_INTEGER, ACT_TYPE_INVALID, and ACT_TYPE_NEURAL.
Referenced by act_json_import(), and action_param_set_type_string().
const char* action_type_as_string | ( | const int | type | ) |
Returns a string representation of an action type from an integer.
[in] | type | Integer representation of an action type. |
Definition at line 56 of file action.c.
References ACT_STRING_INTEGER, ACT_STRING_NEURAL, ACT_TYPE_INTEGER, and ACT_TYPE_NEURAL.
Referenced by act_json_import(), and action_param_json_export().