XCSF
1.4.7
XCSF learning classifier system
|
Ternary condition functions. More...
Go to the source code of this file.
Macros | |
#define | DONT_CARE ('#') |
Don't care symbol. More... | |
#define | N_MU (1) |
Number of ternary mutation rates. More... | |
Functions | |
static void | cond_ternary_rand (const struct XCSF *xcsf, const struct Cl *c) |
Randomises a ternary condition. More... | |
void | cond_ternary_init (const struct XCSF *xcsf, struct Cl *c) |
Creates and initialises a ternary bitstring condition. More... | |
void | cond_ternary_free (const struct XCSF *xcsf, const struct Cl *c) |
Frees the memory used by a ternary condition. More... | |
void | cond_ternary_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src) |
Copies a ternary condition from one classifier to another. More... | |
void | cond_ternary_cover (const struct XCSF *xcsf, const struct Cl *c, const double *x) |
Generates a ternary condition that matches the current input. More... | |
void | cond_ternary_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y) |
Dummy update function. More... | |
bool | cond_ternary_match (const struct XCSF *xcsf, const struct Cl *c, const double *x) |
Calculates whether a ternary condition matches an input. More... | |
bool | cond_ternary_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2) |
Performs uniform crossover with two ternary conditions. More... | |
bool | cond_ternary_mutate (const struct XCSF *xcsf, const struct Cl *c) |
Mutates a ternary condition. More... | |
bool | cond_ternary_general (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2) |
Returns whether classifier c1 has a condition more general than c2. More... | |
void | cond_ternary_print (const struct XCSF *xcsf, const struct Cl *c) |
Prints a ternary condition. More... | |
double | cond_ternary_size (const struct XCSF *xcsf, const struct Cl *c) |
Returns the size of a ternary condition. More... | |
size_t | cond_ternary_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp) |
Writes a ternary condition to a file. More... | |
size_t | cond_ternary_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp) |
Reads a ternary condition from a file. More... | |
char * | cond_ternary_json_export (const struct XCSF *xcsf, const struct Cl *c) |
Returns a json formatted string representation of a ternary condition. More... | |
void | cond_ternary_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json) |
Creates a ternary condition from a cJSON object. More... | |
char * | cond_ternary_param_json_export (const struct XCSF *xcsf) |
Returns a json formatted string of the ternary parameters. More... | |
char * | cond_ternary_param_json_import (struct XCSF *xcsf, cJSON *json) |
Sets the ternary parameters from a cJSON object. More... | |
void | cond_ternary_param_defaults (struct XCSF *xcsf) |
Initialises default ternary condition parameters. More... | |
Variables | |
static const int | MU_TYPE [(1)] = { (0) } |
Self-adaptation method for mutating ternary conditions. More... | |
Ternary condition functions.
Binarises inputs.
Definition in file cond_ternary.c.
#define DONT_CARE ('#') |
Don't care symbol.
Definition at line 30 of file cond_ternary.c.
#define N_MU (1) |
Number of ternary mutation rates.
Definition at line 31 of file cond_ternary.c.
Copies a ternary condition from one classifier to another.
[in] | xcsf | The XCSF data structure. |
[in] | dest | The destination classifier. |
[in] | src | The source classifier. |
Definition at line 99 of file cond_ternary.c.
References Cl::cond, CondTernary::length, CondTernary::mu, N_MU, and CondTernary::string.
Generates a ternary condition that matches the current input.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition is being covered. |
[in] | x | The input state to cover. |
Definition at line 120 of file cond_ternary.c.
References Cl::cond, DONT_CARE, float_to_binary(), rand_uniform(), CondTernary::string, and CondTernary::tmp_input.
bool cond_ternary_crossover | ( | const struct XCSF * | xcsf, |
const struct Cl * | c1, | ||
const struct Cl * | c2 | ||
) |
Performs uniform crossover with two ternary conditions.
[in] | xcsf | The XCSF data structure. |
[in] | c1 | The first classifier whose condition is being crossed. |
[in] | c2 | The second classifier whose condition is being crossed. |
Definition at line 185 of file cond_ternary.c.
References Cl::cond, CondTernary::length, rand_uniform(), and CondTernary::string.
Frees the memory used by a ternary condition.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition is to be freed. |
Definition at line 82 of file cond_ternary.c.
References Cl::cond, CondTernary::mu, CondTernary::string, and CondTernary::tmp_input.
Returns whether classifier c1 has a condition more general than c2.
[in] | xcsf | The XCSF data structure. |
[in] | c1 | The classifier whose condition is tested to be more general. |
[in] | c2 | The classifier whose condition is tested to be more specific. |
Definition at line 238 of file cond_ternary.c.
References Cl::cond, DONT_CARE, CondTernary::length, and CondTernary::string.
Creates and initialises a ternary bitstring condition.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition is to be initialised. |
Definition at line 64 of file cond_ternary.c.
References Cl::cond, cond_ternary_rand(), MU_TYPE, N_MU, and sam_init().
Returns a json formatted string representation of a ternary condition.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is to be returned. |
Definition at line 338 of file cond_ternary.c.
References Cl::cond, CondTernary::length, CondTernary::mu, N_MU, and CondTernary::string.
Referenced by cond_ternary_print().
Creates a ternary condition from a cJSON object.
[in] | xcsf | The XCSF data structure. |
[in,out] | c | The classifier to initialise. |
[in] | json | cJSON object. |
Definition at line 362 of file cond_ternary.c.
References Cl::cond, CondTernary::length, CondTernary::mu, N_MU, sam_json_import(), and CondTernary::string.
Reads a ternary condition from a file.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition is to be read. |
[in] | fp | Pointer to the file to be read. |
Definition at line 311 of file cond_ternary.c.
Calculates whether a ternary condition matches an input.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition to match. |
[in] | x | The input state. |
Definition at line 161 of file cond_ternary.c.
References Cl::cond, DONT_CARE, float_to_binary(), CondTernary::string, and CondTernary::tmp_input.
Mutates a ternary condition.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition is being mutated. |
Definition at line 211 of file cond_ternary.c.
References Cl::cond, DONT_CARE, CondTernary::length, CondTernary::mu, MU_TYPE, N_MU, rand_uniform(), sam_adapt(), and CondTernary::string.
void cond_ternary_param_defaults | ( | struct XCSF * | xcsf | ) |
Initialises default ternary condition parameters.
[in] | xcsf | The XCSF data structure. |
Definition at line 426 of file cond_ternary.c.
References cond_param_set_bits(), and cond_param_set_p_dontcare().
Referenced by cond_param_defaults().
char* cond_ternary_param_json_export | ( | const struct XCSF * | xcsf | ) |
Returns a json formatted string of the ternary parameters.
[in] | xcsf | The XCSF data structure. |
Definition at line 387 of file cond_ternary.c.
References ArgsCond::bits, and ArgsCond::p_dontcare.
Referenced by cond_param_json_export().
char* cond_ternary_param_json_import | ( | struct XCSF * | xcsf, |
cJSON * | json | ||
) |
Sets the ternary parameters from a cJSON object.
[in,out] | xcsf | The XCSF data structure. |
[in] | json | cJSON object. |
Definition at line 405 of file cond_ternary.c.
References cond_param_set_bits(), and cond_param_set_p_dontcare().
Referenced by cond_param_json_import().
Prints a ternary condition.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition is to be printed. |
Definition at line 263 of file cond_ternary.c.
References cond_ternary_json_export().
Randomises a ternary condition.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition is to be initialised. |
Definition at line 44 of file cond_ternary.c.
References Cl::cond, DONT_CARE, CondTernary::length, rand_uniform(), and CondTernary::string.
Referenced by cond_ternary_init().
Writes a ternary condition to a file.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition is to be written. |
[in] | fp | Pointer to the file to be written. |
Definition at line 292 of file cond_ternary.c.
References Cl::cond, CondTernary::length, CondTernary::mu, N_MU, and CondTernary::string.
Returns the size of a ternary condition.
[in] | xcsf | The XCSF data structure. |
[in] | c | The classifier whose condition size to return. |
Definition at line 277 of file cond_ternary.c.
References Cl::cond, and CondTernary::length.
void cond_ternary_update | ( | const struct XCSF * | xcsf, |
const struct Cl * | c, | ||
const double * | x, | ||
const double * | y | ||
) |
Dummy update function.
[in] | xcsf | The XCSF data structure. |
[in] | c | Classifier whose condition is to be updated. |
[in] | x | Input state. |
[in] | y | Truth/payoff value. |
Definition at line 144 of file cond_ternary.c.
|
static |
Self-adaptation method for mutating ternary conditions.
Definition at line 36 of file cond_ternary.c.
Referenced by cond_ternary_init(), and cond_ternary_mutate().