XCSF
1.4.7
XCSF learning classifier system
|
Hyperrectangle condition functions. More...
Go to the source code of this file.
Macros | |
#define | N_MU (1) |
Number of hyperrectangle mutation rates. More... | |
Functions | |
void | cond_rectangle_init (const struct XCSF *xcsf, struct Cl *c) |
Creates and initialises a hyperrectangle condition. More... | |
void | cond_rectangle_free (const struct XCSF *xcsf, const struct Cl *c) |
Frees the memory used by a hyperrectangle condition. More... | |
void | cond_rectangle_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src) |
Copies a hyperrectangle condition from one classifier to another. More... | |
void | cond_rectangle_cover (const struct XCSF *xcsf, const struct Cl *c, const double *x) |
Generates a hyperrectangle that matches the current input. More... | |
void | cond_rectangle_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y) |
Updates a hyperrectangle, sliding the centers towards the mean input. More... | |
bool | cond_rectangle_match (const struct XCSF *xcsf, const struct Cl *c, const double *x) |
Calculates whether a hyperrectangle condition matches an input. More... | |
bool | cond_rectangle_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2) |
Performs uniform crossover with two hyperrectangle conditions. More... | |
bool | cond_rectangle_mutate (const struct XCSF *xcsf, const struct Cl *c) |
Mutates a hyperrectangle condition with the self-adaptive rate. More... | |
bool | cond_rectangle_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_rectangle_print (const struct XCSF *xcsf, const struct Cl *c) |
Prints a hyperrectangle condition. More... | |
double | cond_rectangle_size (const struct XCSF *xcsf, const struct Cl *c) |
Returns the size of a hyperrectangle condition. More... | |
size_t | cond_rectangle_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp) |
Writes a hyperrectangle condition to a file. More... | |
size_t | cond_rectangle_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp) |
Reads a hyperrectangle condition from a file. More... | |
char * | cond_rectangle_json_export (const struct XCSF *xcsf, const struct Cl *c) |
Returns a json formatted string representation of a hyperrectangle. More... | |
void | cond_rectangle_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json) |
Creates a hyperrectangle from a cJSON object. More... | |
Variables | |
static const int | MU_TYPE [(1)] = { (0) } |
Self-adaptation method for mutating hyperrectangles. More... | |
Hyperrectangle condition functions.
Definition in file cond_rectangle.c.
#define N_MU (1) |
Number of hyperrectangle mutation rates.
Definition at line 29 of file cond_rectangle.c.
Copies a hyperrectangle condition from one classifier to another.
[in] | xcsf | XCSF data structure. |
[in] | dest | Destination classifier. |
[in] | src | Source classifier. |
Definition at line 86 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, Cl::cond, CondRectangle::mu, and N_MU.
Generates a hyperrectangle that matches the current input.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is being covered. |
[in] | x | Input state to cover. |
Definition at line 107 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, Cl::cond, COND_TYPE_HYPERRECTANGLE_CSR, and rand_uniform().
bool cond_rectangle_crossover | ( | const struct XCSF * | xcsf, |
const struct Cl * | c1, | ||
const struct Cl * | c2 | ||
) |
Performs uniform crossover with two hyperrectangle conditions.
[in] | xcsf | XCSF data structure. |
[in] | c1 | First classifier whose condition is being crossed. |
[in] | c2 | Second classifier whose condition is being crossed. |
Definition at line 188 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, Cl::cond, and rand_uniform().
Frees the memory used by a hyperrectangle condition.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is to be freed. |
Definition at line 69 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, Cl::cond, and CondRectangle::mu.
bool cond_rectangle_general | ( | const struct XCSF * | xcsf, |
const struct Cl * | c1, | ||
const struct Cl * | c2 | ||
) |
Returns whether classifier c1 has a condition more general than c2.
[in] | xcsf | XCSF data structure. |
[in] | c1 | Classifier whose condition is tested to be more general. |
[in] | c2 | Classifier whose condition is tested to be more specific. |
Definition at line 256 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, Cl::cond, and COND_TYPE_HYPERRECTANGLE_CSR.
Creates and initialises a hyperrectangle condition.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is to be initialised. |
Definition at line 42 of file cond_rectangle.c.
References Cl::cond, COND_TYPE_HYPERRECTANGLE_CSR, MU_TYPE, N_MU, rand_uniform(), and sam_init().
Returns a json formatted string representation of a hyperrectangle.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is to be returned. |
Definition at line 358 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, Cl::cond, COND_TYPE_HYPERRECTANGLE_CSR, CondRectangle::mu, and N_MU.
Referenced by cond_rectangle_print().
Creates a hyperrectangle from a cJSON object.
[in] | xcsf | The XCSF data structure. |
[in,out] | c | The classifier to initialise. |
[in] | json | cJSON object. |
Definition at line 387 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, Cl::cond, COND_TYPE_HYPERRECTANGLE_CSR, CondRectangle::mu, N_MU, and sam_json_import().
Reads a hyperrectangle condition from a file.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is to be read. |
[in] | fp | Pointer to the file to be read. |
Definition at line 337 of file cond_rectangle.c.
Calculates whether a hyperrectangle condition matches an input.
Definition at line 156 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, Cl::cond, and COND_TYPE_HYPERRECTANGLE_CSR.
Mutates a hyperrectangle condition with the self-adaptive rate.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is being mutated. |
Definition at line 220 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, clamp(), Cl::cond, COND_TYPE_HYPERRECTANGLE_CSR, CondRectangle::mu, MU_TYPE, N_MU, rand_normal(), and sam_adapt().
Prints a hyperrectangle condition.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is to be printed. |
Definition at line 291 of file cond_rectangle.c.
References cond_rectangle_json_export().
Writes a hyperrectangle condition to a file.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is to be written. |
[in] | fp | Pointer to the file to be written. |
Definition at line 319 of file cond_rectangle.c.
References CondRectangle::b1, CondRectangle::b2, Cl::cond, CondRectangle::mu, and N_MU.
Returns the size of a hyperrectangle condition.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition size to return. |
Definition at line 305 of file cond_rectangle.c.
void cond_rectangle_update | ( | const struct XCSF * | xcsf, |
const struct Cl * | c, | ||
const double * | x, | ||
const double * | y | ||
) |
Updates a hyperrectangle, sliding the centers towards the mean input.
[in] | xcsf | XCSF data structure. |
[in] | c | Classifier whose condition is to be updated. |
[in] | x | Input state. |
[in] | y | Truth/payoff value. |
Definition at line 135 of file cond_rectangle.c.
References CondRectangle::b1, Cl::cond, and COND_TYPE_HYPERRECTANGLE_CSR.
|
static |
Self-adaptation method for mutating hyperrectangles.
Definition at line 34 of file cond_rectangle.c.
Referenced by cond_rectangle_init(), and cond_rectangle_mutate().