184 printf(
"%s\n", json_str);
245 cJSON *json = cJSON_CreateObject();
246 cJSON_AddStringToObject(json,
"type",
"tree_gp");
248 cJSON *tree = cJSON_Parse(tree_str);
250 cJSON_AddItemToObject(json,
"tree", tree);
251 char *
string = cJSON_Print(json);
297 xcsf->cond->targs = args;
309 const cJSON *item = cJSON_GetObjectItem(json,
"tree");
311 printf(
"Import error: missing tree\n");
void cond_gp_print(const struct XCSF *xcsf, const struct Cl *c)
Prints a tree-GP condition.
void cond_gp_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Generates a GP tree that matches the current input.
void cond_gp_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies a tree-GP condition from one classifier to another.
size_t cond_gp_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes a tree-GP condition to a file.
bool cond_gp_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy general function.
char * cond_gp_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of a tree-GP condition.
void cond_gp_param_defaults(struct XCSF *xcsf)
Initialises default tree GP condition parameters.
bool cond_gp_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Performs sub-tree crossover with two tree-GP conditions.
size_t cond_gp_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads a tree-GP condition from a file.
bool cond_gp_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates a tree-GP condition with the self-adaptive rate.
char * cond_gp_param_json_import(struct XCSF *xcsf, cJSON *json)
Sets the tree GP parameters from a cJSON object.
void cond_gp_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by a tree-GP condition.
bool cond_gp_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Calculates whether a GP tree condition matches an input.
double cond_gp_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of a tree-GP condition.
void cond_gp_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates a tree GP condition from a cJSON object.
void cond_gp_init(const struct XCSF *xcsf, struct Cl *c)
Creates and initialises a tree-GP condition.
void cond_gp_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Dummy update function.
char * cond_gp_param_json_export(const struct XCSF *xcsf)
Returns a json formatted string of the tree GP parameters.
Tree GP condition functions.
Evolutionary algorithm functions.
void tree_json_import(struct GPTree *gp, const struct ArgsGPTree *args, const cJSON *json)
Creates a GP tree from a cJSON object.
size_t tree_load(struct GPTree *gp, FILE *fp)
Reads a GP tree from a file.
void tree_param_set_max_len(struct ArgsGPTree *args, const int a)
void tree_crossover(struct GPTree *p1, struct GPTree *p2)
Performs sub-tree crossover.
size_t tree_save(const struct GPTree *gp, FILE *fp)
Writes the GP tree to a file.
void tree_param_set_max(struct ArgsGPTree *args, const double a)
void tree_param_set_n_inputs(struct ArgsGPTree *args, const int a)
char * tree_args_json_import(struct ArgsGPTree *args, cJSON *json)
Sets the GP tree parameters from a cJSON object.
double tree_eval(struct GPTree *gp, const struct ArgsGPTree *args, const double *x)
Evaluates a GP tree.
void tree_param_set_n_constants(struct ArgsGPTree *args, const int a)
void tree_args_init_constants(struct ArgsGPTree *args)
Builds global constants used by GP trees.
void tree_param_set_init_depth(struct ArgsGPTree *args, const int a)
bool tree_mutate(struct GPTree *gp, const struct ArgsGPTree *args)
Performs point mutation on a GP tree.
void tree_args_init(struct ArgsGPTree *args)
Sets tree GP parameters to default values.
void tree_param_set_min(struct ArgsGPTree *args, const double a)
char * tree_args_json_export(const struct ArgsGPTree *args)
Returns a json formatted string of the GP tree parameters.
char * tree_json_export(const struct GPTree *gp, const struct ArgsGPTree *args)
Returns a json formatted string representation of a GP tree.
void tree_copy(struct GPTree *dest, const struct GPTree *src)
Copies a GP tree.
void tree_free(const struct GPTree *gp)
Frees a GP tree.
void tree_rand(struct GPTree *gp, const struct ArgsGPTree *args)
Creates a random GP tree.
Self-adaptive mutation functions.
Parameters for initialising GP trees.
Classifier data structure.
void * cond
Condition structure.
Tree GP condition data structure.
int pos
Current position in the tree.
double rand_uniform(const double min, const double max)
Returns a uniform random float [min,max].
Utility functions for random number handling, etc.