33 new->n_outputs = (int) fmax(1, ceil(log2(
xcsf->n_actions)));
71 const double *x,
const double *y)
123 printf(
"%s\n", json_str);
149 new->n_outputs = (int) fmax(1, ceil(log2(
xcsf->n_actions)));
159 cJSON *json = cJSON_CreateObject();
160 cJSON_AddStringToObject(json,
"type",
"rule_dgp");
162 cJSON *graph = cJSON_Parse(graph_str);
164 cJSON_AddItemToObject(json,
"graph", graph);
165 char *
string = cJSON_Print(json);
174 const cJSON *item = cJSON_GetObjectItem(json,
"graph");
176 printf(
"Import error: missing graph\n");
202 const struct Cl *src)
213 printf(
"%s\n", json_str);
236 for (
int i = 0; i < cond->
n_outputs; ++i) {
238 action += (int) pow(2, i);
247 const double *x,
const double *y)
306 cJSON *json = cJSON_CreateObject();
307 cJSON_AddStringToObject(json,
"type",
"rule_dgp");
308 char *
string = cJSON_Print(json);
void graph_copy(struct Graph *dest, const struct Graph *src)
Copies a DGP graph.
void graph_free(const struct Graph *dgp)
Frees a DGP graph.
void graph_rand(struct Graph *dgp)
Randomises a specified DGP graph.
size_t graph_save(const struct Graph *dgp, FILE *fp)
Writes DGP graph to a file.
void graph_json_import(struct Graph *dgp, const struct ArgsDGP *args, const cJSON *json)
Creates a DGP graph from a cJSON object.
void graph_update(const struct Graph *dgp, const double *inputs, const bool reset)
Updates a DGP graph T cycles.
void graph_init(struct Graph *dgp, const struct ArgsDGP *args)
Initialises a new DGP graph.
double graph_output(const struct Graph *dgp, const int IDX)
Returns the current state of a specified node in the graph.
char * graph_json_export(const struct Graph *dgp)
Returns a json formatted string representation of a DGP graph.
size_t graph_load(struct Graph *dgp, FILE *fp)
Reads DGP graph from a file.
bool graph_mutate(struct Graph *dgp)
Mutates a specified DGP graph.
bool rule_dgp_act_mutate(const struct XCSF *xcsf, const struct Cl *c)
char * rule_dgp_act_json_export(const struct XCSF *xcsf, const struct Cl *c)
void rule_dgp_cond_init(const struct XCSF *xcsf, struct Cl *c)
char * rule_dgp_cond_json_export(const struct XCSF *xcsf, const struct Cl *c)
bool rule_dgp_cond_mutate(const struct XCSF *xcsf, const struct Cl *c)
void rule_dgp_cond_free(const struct XCSF *xcsf, const struct Cl *c)
bool rule_dgp_cond_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
size_t rule_dgp_act_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
void rule_dgp_act_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
size_t rule_dgp_act_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
bool rule_dgp_act_general(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
void rule_dgp_cond_print(const struct XCSF *xcsf, const struct Cl *c)
void rule_dgp_cond_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
bool rule_dgp_cond_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
void rule_dgp_act_init(const struct XCSF *xcsf, struct Cl *c)
void rule_dgp_cond_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
void rule_dgp_act_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
bool rule_dgp_cond_match(const struct XCSF *xcsf, const struct Cl *c, const double *x)
void rule_dgp_act_print(const struct XCSF *xcsf, const struct Cl *c)
void rule_dgp_act_free(const struct XCSF *xcsf, const struct Cl *c)
bool rule_dgp_act_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
void rule_dgp_cond_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x)
void rule_dgp_act_cover(const struct XCSF *xcsf, const struct Cl *c, const double *x, const int action)
size_t rule_dgp_cond_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
int rule_dgp_act_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
void rule_dgp_act_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
double rule_dgp_cond_size(const struct XCSF *xcsf, const struct Cl *c)
size_t rule_dgp_cond_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
void rule_dgp_cond_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Dynamical GP graph rule (condition + action) functions.
Classifier data structure.
void * cond
Condition structure.
Dynamical GP graph rule data structure.
struct Graph dgp
DGP graph.
int n_outputs
Number of action nodes (binarised)
Utility functions for random number handling, etc.
static int clamp_int(const int a, const int min, const int max)
Returns an integer clamped within the specified range.