28 #define COND_TYPE_INVALID (-1)
29 #define COND_TYPE_DUMMY (0)
30 #define COND_TYPE_HYPERRECTANGLE_CSR (1)
31 #define COND_TYPE_HYPERRECTANGLE_UBR (2)
32 #define COND_TYPE_HYPERELLIPSOID (3)
33 #define COND_TYPE_NEURAL (4)
34 #define COND_TYPE_GP (5)
35 #define COND_TYPE_DGP (6)
36 #define COND_TYPE_TERNARY (7)
37 #define RULE_TYPE_DGP (11)
38 #define RULE_TYPE_NEURAL (12)
39 #define RULE_TYPE_NETWORK (13)
41 #define COND_STRING_DUMMY ("dummy\0")
42 #define COND_STRING_HYPERRECTANGLE_CSR ("hyperrectangle_csr\0")
43 #define COND_STRING_HYPERRECTANGLE_UBR ("hyperrectangle_ubr\0")
44 #define COND_STRING_HYPERELLIPSOID ("hyperellipsoid\0")
45 #define COND_STRING_NEURAL ("neural\0")
46 #define COND_STRING_GP ("tree_gp\0")
47 #define COND_STRING_DGP ("dgp\0")
48 #define COND_STRING_TERNARY ("ternary\0")
49 #define COND_STRING_RULE_DGP ("rule_dgp\0")
50 #define COND_STRING_RULE_NEURAL ("rule_neural\0")
51 #define COND_STRING_RULE_NETWORK ("rule_network\0")
53 #define COND_TYPE_OPTIONS \
54 "dummy, hyperrectangle_csr, hyperrectangle_ubr, hyperellipsoid, neural, " \
55 "tree_gp, dgp, ternary, rule_dgp, rule_neural, rule_network"
106 const struct Cl *c2);
108 const struct Cl *c2);
113 const struct Cl *src);
120 const double *x,
const double *y);
125 char *(*cond_impl_json_export)(
const struct XCSF *
xcsf,
const struct Cl *c);
312 const cJSON *item = cJSON_GetObjectItem(json,
"type");
313 if (item == NULL || !cJSON_IsString(item)) {
314 printf(
"cond_json_import(): missing type\n");
317 const char *type = item->valuestring;
319 printf(
"cond_json_import(): mismatched type\n");
320 printf(
"XCSF type = %s, but imported type = %s\n",
char * cond_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the condition parameters from a cJSON object.
void condition_set(const struct XCSF *xcsf, struct Cl *c)
Sets a classifier's condition functions to the implementations.
void cond_param_set_type(struct XCSF *xcsf, const int a)
static void cond_print(const struct XCSF *xcsf, const struct Cl *c)
Prints the classifier condition.
static void cond_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by the classifier condition.
static bool cond_mutate(const struct XCSF *xcsf, const struct Cl *c)
Performs classifier condition mutation.
void cond_param_set_spread_min(struct XCSF *xcsf, const double a)
static bool cond_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Performs classifier condition crossover.
size_t cond_param_load(struct XCSF *xcsf, FILE *fp)
Loads condition parameters.
int condition_type_as_int(const char *type)
Returns the integer representation of a condition type given a name.
static bool cond_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Returns whether classifier c1 has a condition more general than c2.
void cond_param_set_bits(struct XCSF *xcsf, const int a)
static size_t cond_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes the condition to a file.
void cond_param_set_min(struct XCSF *xcsf, const double a)
static void cond_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a condition from a cJSON object.
size_t cond_param_save(const struct XCSF *xcsf, FILE *fp)
Saves condition parameters.
void cond_param_set_p_dontcare(struct XCSF *xcsf, const double a)
void cond_param_set_max(struct XCSF *xcsf, const double a)
static void cond_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies the condition from one classifier to another.
int cond_param_set_type_string(struct XCSF *xcsf, const char *a)
static double cond_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of the classifier condition.
static void cond_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a condition that matches the current input.
char * cond_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string of the condition parameters.
void cond_param_defaults(struct XCSF *xcsf)
Initialises default condition parameters.
static void cond_init(const struct XCSF *xcsf, struct Cl *c)
Initialises a classifier's condition.
static bool cond_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Calculates whether the condition matches the input.
static size_t cond_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads the condition from a file.
static char * cond_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a condition.
void cond_param_free(struct XCSF *xcsf)
Frees condition parameters.
const char * condition_type_as_string(const int type)
Returns a string representation of a condition type from an integer.
static void cond_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Updates the classifier's condition.
void cond_param_set_eta(struct XCSF *xcsf, const double a)
Parameters for initialising and operating conditions.
double min
Minimum value expected from inputs.
double eta
Gradient descent rate.
double p_dontcare
Don't care probability.
struct ArgsDGP * dargs
DGP parameters.
struct ArgsGPTree * targs
Tree GP parameters.
int type
Classifier condition type: hyperrectangles, etc.
int bits
Bits per float to binarise inputs.
double spread_min
Minimum initial spread.
struct ArgsLayer * largs
Linked-list of layer parameters.
double max
Maximum value expected from inputs.
Parameters for initialising DGP graphs.
Parameters for initialising GP trees.
Parameters for initialising a neural network layer.
Classifier data structure.
struct CondVtbl const * cond_vptr
Functions acting on conditions.
Condition interface data structure.
void(* cond_impl_copy)(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
void(* cond_impl_init)(const struct XCSF *xcsf, struct Cl *c)
void(* cond_impl_print)(const struct XCSF *xcsf, const struct Cl *c)
void(* cond_impl_json_import)(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
double(* cond_impl_size)(const struct XCSF *xcsf, const struct Cl *c)
void(* cond_impl_free)(const struct XCSF *xcsf, const struct Cl *c)
void(* cond_impl_update)(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
bool(* cond_impl_crossover)(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
bool(* cond_impl_general)(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
bool(* cond_impl_mutate)(const struct XCSF *xcsf, const struct Cl *c)
size_t(* cond_impl_load)(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
void(* cond_impl_cover)(const struct XCSF *xcsf, const struct Cl *c, const double *x)
size_t(* cond_impl_save)(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
bool(* cond_impl_match)(const struct XCSF *xcsf, const struct Cl *c, const double *x)
char *(* cond_impl_json_export)(const struct XCSF *xcsf, const struct Cl *c)