XCSF
1.4.7
XCSF learning classifier system
|
An implementation of dynamical GP graphs with fuzzy activations. More...
#include "xcsf.h"
Go to the source code of this file.
Data Structures | |
struct | ArgsDGP |
Parameters for initialising DGP graphs. More... | |
struct | Graph |
Dynamical GP graph data structure. More... | |
Functions | |
bool | graph_mutate (struct Graph *dgp) |
Mutates a specified DGP graph. More... | |
char * | graph_json_export (const struct Graph *dgp) |
Returns a json formatted string representation of a DGP graph. More... | |
void | graph_json_import (struct Graph *dgp, const struct ArgsDGP *args, const cJSON *json) |
Creates a DGP graph from a cJSON object. More... | |
double | graph_output (const struct Graph *dgp, const int IDX) |
Returns the current state of a specified node in the graph. More... | |
size_t | graph_load (struct Graph *dgp, FILE *fp) |
Reads DGP graph from a file. More... | |
size_t | graph_save (const struct Graph *dgp, FILE *fp) |
Writes DGP graph to a file. More... | |
void | graph_copy (struct Graph *dest, const struct Graph *src) |
Copies a DGP graph. More... | |
void | graph_free (const struct Graph *dgp) |
Frees a DGP graph. More... | |
void | graph_init (struct Graph *dgp, const struct ArgsDGP *args) |
Initialises a new DGP graph. More... | |
void | graph_print (const struct Graph *dgp) |
Prints a DGP graph. More... | |
void | graph_rand (struct Graph *dgp) |
Randomises a specified DGP graph. More... | |
void | graph_reset (const struct Graph *dgp) |
Resets the states to their initial state. More... | |
void | graph_update (const struct Graph *dgp, const double *inputs, const bool reset) |
Updates a DGP graph T cycles. More... | |
void | graph_args_init (struct ArgsDGP *args) |
Sets DGP parameters to default values. More... | |
char * | graph_args_json_import (struct ArgsDGP *args, cJSON *json) |
Sets the DGP graph parameters from a cJSON object. More... | |
char * | graph_args_json_export (const struct ArgsDGP *args) |
Returns a json formatted string of the DGP parameters. More... | |
size_t | graph_args_save (const struct ArgsDGP *args, FILE *fp) |
Saves DGP parameters. More... | |
size_t | graph_args_load (struct ArgsDGP *args, FILE *fp) |
Loads DGP parameters. More... | |
void | graph_param_set_max_k (struct ArgsDGP *args, const int a) |
void | graph_param_set_max_t (struct ArgsDGP *args, const int a) |
void | graph_param_set_n (struct ArgsDGP *args, const int a) |
void | graph_param_set_n_inputs (struct ArgsDGP *args, const int a) |
void | graph_param_set_evolve_cycles (struct ArgsDGP *args, const bool a) |
An implementation of dynamical GP graphs with fuzzy activations.
Definition in file dgp.h.
void graph_args_init | ( | struct ArgsDGP * | args | ) |
Sets DGP parameters to default values.
[in] | args | Parameters for initialising and operating DGP graphs. |
Definition at line 624 of file dgp.c.
References ArgsDGP::evolve_cycles, ArgsDGP::max_k, ArgsDGP::max_t, ArgsDGP::n, and ArgsDGP::n_inputs.
Referenced by cond_dgp_param_defaults().
char* graph_args_json_export | ( | const struct ArgsDGP * | args | ) |
Returns a json formatted string of the DGP parameters.
[in] | args | Parameters for initialising and operating DGP graphs. |
Definition at line 639 of file dgp.c.
References ArgsDGP::evolve_cycles, ArgsDGP::max_k, ArgsDGP::max_t, and ArgsDGP::n.
Referenced by cond_dgp_param_json_export().
char* graph_args_json_import | ( | struct ArgsDGP * | args, |
cJSON * | json | ||
) |
Sets the DGP graph parameters from a cJSON object.
[in,out] | args | DGP parameter data structure. |
[in] | json | cJSON object. |
Definition at line 658 of file dgp.c.
References graph_param_set_evolve_cycles(), graph_param_set_max_k(), graph_param_set_max_t(), and graph_param_set_n().
Referenced by cond_dgp_param_json_import().
size_t graph_args_load | ( | struct ArgsDGP * | args, |
FILE * | fp | ||
) |
Loads DGP parameters.
[in] | args | Parameters for initialising and operating DGP graphs. |
[in] | fp | Pointer to the output file. |
Definition at line 705 of file dgp.c.
References ArgsDGP::evolve_cycles, ArgsDGP::max_k, ArgsDGP::max_t, ArgsDGP::n, and ArgsDGP::n_inputs.
Referenced by cond_param_load().
size_t graph_args_save | ( | const struct ArgsDGP * | args, |
FILE * | fp | ||
) |
Saves DGP parameters.
[in] | args | Parameters for initialising and operating DGP graphs. |
[in] | fp | Pointer to the output file. |
Definition at line 687 of file dgp.c.
References ArgsDGP::evolve_cycles, ArgsDGP::max_k, ArgsDGP::max_t, ArgsDGP::n, and ArgsDGP::n_inputs.
Referenced by cond_param_save().
Copies a DGP graph.
[in] | dest | The destination DGP graph. |
[in] | src | The source DGP graph. |
Definition at line 251 of file dgp.c.
References Graph::connectivity, Graph::evolve_cycles, Graph::function, Graph::initial_state, Graph::klen, Graph::max_k, Graph::max_t, Graph::mu, Graph::n, Graph::n_inputs, N_MU, Graph::state, and Graph::t.
Referenced by cond_dgp_copy(), and rule_dgp_cond_copy().
void graph_free | ( | const struct Graph * | dgp | ) |
Frees a DGP graph.
[in] | dgp | The DGP graph to be freed. |
Definition at line 523 of file dgp.c.
References Graph::connectivity, Graph::function, Graph::initial_state, Graph::mu, Graph::state, Graph::tmp_input, and Graph::tmp_state.
Referenced by cond_dgp_free(), cond_dgp_json_import(), rule_dgp_cond_free(), and rule_dgp_cond_json_import().
Initialises a new DGP graph.
[in] | dgp | The DGP graph to initialise. |
[in] | args | Parameters for initialising a DGP graph. |
Definition at line 226 of file dgp.c.
References Graph::connectivity, ArgsDGP::evolve_cycles, Graph::evolve_cycles, Graph::function, Graph::initial_state, Graph::klen, ArgsDGP::max_k, Graph::max_k, ArgsDGP::max_t, Graph::max_t, Graph::mu, MU_TYPE, ArgsDGP::n, Graph::n, ArgsDGP::n_inputs, Graph::n_inputs, N_MU, sam_init(), Graph::state, Graph::t, Graph::tmp_input, and Graph::tmp_state.
Referenced by cond_dgp_copy(), cond_dgp_init(), rule_dgp_cond_copy(), and rule_dgp_cond_init().
char* graph_json_export | ( | const struct Graph * | dgp | ) |
Returns a json formatted string representation of a DGP graph.
[in] | dgp | The DGP graph to return. |
Definition at line 346 of file dgp.c.
References Graph::connectivity, Graph::function, function_string(), Graph::initial_state, Graph::klen, Graph::mu, Graph::n, Graph::n_inputs, N_MU, Graph::state, and Graph::t.
Referenced by cond_dgp_json_export(), graph_print(), and rule_dgp_cond_json_export().
Creates a DGP graph from a cJSON object.
[in,out] | dgp | The DGP to initialise. |
[in] | args | Parameters for initialising a DGP graph. |
[in] | json | cJSON object. |
Definition at line 477 of file dgp.c.
References Graph::connectivity, ArgsDGP::evolve_cycles, Graph::evolve_cycles, Graph::function, graph_json_import_connectivity(), graph_json_import_current_state(), graph_json_import_functions(), graph_json_import_initial_state(), graph_rand(), Graph::initial_state, Graph::klen, ArgsDGP::max_k, Graph::max_k, ArgsDGP::max_t, Graph::max_t, Graph::mu, ArgsDGP::n, Graph::n, ArgsDGP::n_inputs, Graph::n_inputs, N_MU, sam_json_import(), Graph::state, Graph::t, Graph::tmp_input, and Graph::tmp_state.
Referenced by cond_dgp_json_import(), and rule_dgp_cond_json_import().
size_t graph_load | ( | struct Graph * | dgp, |
FILE * | fp | ||
) |
Reads DGP graph from a file.
[in] | dgp | The DGP graph to load. |
[in] | fp | Pointer to the file to be written. |
Definition at line 588 of file dgp.c.
References Graph::connectivity, Graph::evolve_cycles, Graph::function, Graph::initial_state, Graph::klen, Graph::max_k, Graph::max_t, Graph::mu, Graph::n, Graph::n_inputs, N_MU, Graph::state, Graph::t, Graph::tmp_input, and Graph::tmp_state.
Referenced by cond_dgp_load(), and rule_dgp_cond_load().
bool graph_mutate | ( | struct Graph * | dgp | ) |
Mutates a specified DGP graph.
[in] | dgp | The DGP graph to be mutated. |
Definition at line 540 of file dgp.c.
References Graph::evolve_cycles, graph_mutate_connectivity(), graph_mutate_cycles(), graph_mutate_functions(), Graph::mu, MU_TYPE, N_MU, and sam_adapt().
Referenced by cond_dgp_mutate(), and rule_dgp_cond_mutate().
double graph_output | ( | const struct Graph * | dgp, |
const int | IDX | ||
) |
Returns the current state of a specified node in the graph.
[in] | dgp | The DGP graph to output. |
[in] | IDX | Which node within the graph to output. |
Definition at line 274 of file dgp.c.
References Graph::state.
Referenced by cond_dgp_match(), rule_dgp_act_compute(), and rule_dgp_cond_match().
void graph_param_set_evolve_cycles | ( | struct ArgsDGP * | args, |
const bool | a | ||
) |
Definition at line 763 of file dgp.c.
References ArgsDGP::evolve_cycles.
Referenced by cond_dgp_param_defaults(), and graph_args_json_import().
void graph_param_set_max_k | ( | struct ArgsDGP * | args, |
const int | a | ||
) |
Definition at line 719 of file dgp.c.
References ArgsDGP::max_k.
Referenced by cond_dgp_param_defaults(), and graph_args_json_import().
void graph_param_set_max_t | ( | struct ArgsDGP * | args, |
const int | a | ||
) |
Definition at line 730 of file dgp.c.
References ArgsDGP::max_t.
Referenced by cond_dgp_param_defaults(), and graph_args_json_import().
void graph_param_set_n | ( | struct ArgsDGP * | args, |
const int | a | ||
) |
Definition at line 741 of file dgp.c.
References ArgsDGP::n.
Referenced by cond_dgp_param_defaults(), and graph_args_json_import().
void graph_param_set_n_inputs | ( | struct ArgsDGP * | args, |
const int | a | ||
) |
Definition at line 752 of file dgp.c.
References ArgsDGP::n_inputs.
Referenced by cond_dgp_param_defaults().
void graph_print | ( | const struct Graph * | dgp | ) |
Prints a DGP graph.
[in] | dgp | The DGP graph to print. |
Definition at line 333 of file dgp.c.
References graph_json_export().
void graph_rand | ( | struct Graph * | dgp | ) |
Randomises a specified DGP graph.
[in] | dgp | The DGP graph to randomise. |
Definition at line 296 of file dgp.c.
References Graph::connectivity, Graph::evolve_cycles, Graph::function, Graph::initial_state, Graph::klen, Graph::max_t, Graph::n, Graph::n_inputs, NUM_FUNC, rand_uniform(), rand_uniform_int(), random_connection(), Graph::state, and Graph::t.
Referenced by cond_dgp_cover(), cond_dgp_init(), graph_json_import(), rule_dgp_act_cover(), and rule_dgp_cond_init().
void graph_reset | ( | const struct Graph * | dgp | ) |
Resets the states to their initial state.
[in] | dgp | The DGP graph to reset. |
Definition at line 284 of file dgp.c.
References Graph::initial_state, Graph::n, and Graph::state.
Referenced by graph_update().
size_t graph_save | ( | const struct Graph * | dgp, |
FILE * | fp | ||
) |
Writes DGP graph to a file.
[in] | dgp | The DGP graph to save. |
[in] | fp | Pointer to the file to be written. |
Definition at line 563 of file dgp.c.
References Graph::connectivity, Graph::evolve_cycles, Graph::function, Graph::initial_state, Graph::klen, Graph::max_k, Graph::max_t, Graph::mu, Graph::n, Graph::n_inputs, N_MU, Graph::state, and Graph::t.
Referenced by cond_dgp_save(), and rule_dgp_cond_save().
void graph_update | ( | const struct Graph * | dgp, |
const double * | inputs, | ||
const bool | reset | ||
) |
Updates a DGP graph T cycles.
[in] | dgp | The DGP graph to update. |
[in] | inputs | The inputs to the graph. |
[in] | reset | Whether to reset states to initial values. |
Definition at line 318 of file dgp.c.
References graph_reset(), synchronous_update(), and Graph::t.
Referenced by cond_dgp_match(), and rule_dgp_cond_match().