XCSF  1.4.7
XCSF learning classifier system
dgp.h File Reference

An implementation of dynamical GP graphs with fuzzy activations. More...

#include "xcsf.h"
Include dependency graph for dgp.h:
This graph shows which files directly or indirectly include this file:

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)
 

Detailed Description

An implementation of dynamical GP graphs with fuzzy activations.

Author
Richard Preen rpree.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om
Date
2016–2022.

Definition in file dgp.h.

Function Documentation

◆ graph_args_init()

void graph_args_init ( struct ArgsDGP args)

Sets DGP parameters to default values.

Parameters
[in]argsParameters 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().

Here is the caller graph for this function:

◆ graph_args_json_export()

char* graph_args_json_export ( const struct ArgsDGP args)

Returns a json formatted string of the DGP parameters.

Parameters
[in]argsParameters for initialising and operating DGP graphs.
Returns
String encoded in json format.

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().

Here is the caller graph for this function:

◆ graph_args_json_import()

char* graph_args_json_import ( struct ArgsDGP args,
cJSON *  json 
)

Sets the DGP graph parameters from a cJSON object.

Parameters
[in,out]argsDGP parameter data structure.
[in]jsoncJSON object.
Returns
NULL if successful; or the name of parameter if not found.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ graph_args_load()

size_t graph_args_load ( struct ArgsDGP args,
FILE *  fp 
)

Loads DGP parameters.

Parameters
[in]argsParameters for initialising and operating DGP graphs.
[in]fpPointer to the output file.
Returns
The total number of elements written.

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().

Here is the caller graph for this function:

◆ graph_args_save()

size_t graph_args_save ( const struct ArgsDGP args,
FILE *  fp 
)

Saves DGP parameters.

Parameters
[in]argsParameters for initialising and operating DGP graphs.
[in]fpPointer to the output file.
Returns
The total number of elements written.

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().

Here is the caller graph for this function:

◆ graph_copy()

void graph_copy ( struct Graph dest,
const struct Graph src 
)

Copies a DGP graph.

Parameters
[in]destThe destination DGP graph.
[in]srcThe 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().

Here is the caller graph for this function:

◆ graph_free()

void graph_free ( const struct Graph dgp)

Frees a DGP graph.

Parameters
[in]dgpThe 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().

Here is the caller graph for this function:

◆ graph_init()

void graph_init ( struct Graph dgp,
const struct ArgsDGP args 
)

Initialises a new DGP graph.

Parameters
[in]dgpThe DGP graph to initialise.
[in]argsParameters 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ graph_json_export()

char* graph_json_export ( const struct Graph dgp)

Returns a json formatted string representation of a DGP graph.

Parameters
[in]dgpThe DGP graph to return.
Returns
String encoded in json format.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ graph_json_import()

void graph_json_import ( struct Graph dgp,
const struct ArgsDGP args,
const cJSON *  json 
)

Creates a DGP graph from a cJSON object.

Parameters
[in,out]dgpThe DGP to initialise.
[in]argsParameters for initialising a DGP graph.
[in]jsoncJSON 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ graph_load()

size_t graph_load ( struct Graph dgp,
FILE *  fp 
)

Reads DGP graph from a file.

Parameters
[in]dgpThe DGP graph to load.
[in]fpPointer to the file to be written.
Returns
The number of elements 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().

Here is the caller graph for this function:

◆ graph_mutate()

bool graph_mutate ( struct Graph dgp)

Mutates a specified DGP graph.

Parameters
[in]dgpThe DGP graph to be mutated.
Returns
Whether any alterations were made.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ graph_output()

double graph_output ( const struct Graph dgp,
const int  IDX 
)

Returns the current state of a specified node in the graph.

Parameters
[in]dgpThe DGP graph to output.
[in]IDXWhich node within the graph to output.
Returns
The current state of the specified node.

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().

Here is the caller graph for this function:

◆ graph_param_set_evolve_cycles()

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().

Here is the caller graph for this function:

◆ graph_param_set_max_k()

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().

Here is the caller graph for this function:

◆ graph_param_set_max_t()

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().

Here is the caller graph for this function:

◆ graph_param_set_n()

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().

Here is the caller graph for this function:

◆ graph_param_set_n_inputs()

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().

Here is the caller graph for this function:

◆ graph_print()

void graph_print ( const struct Graph dgp)

Prints a DGP graph.

Parameters
[in]dgpThe DGP graph to print.

Definition at line 333 of file dgp.c.

References graph_json_export().

Here is the call graph for this function:

◆ graph_rand()

void graph_rand ( struct Graph dgp)

Randomises a specified DGP graph.

Parameters
[in]dgpThe 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ graph_reset()

void graph_reset ( const struct Graph dgp)

Resets the states to their initial state.

Parameters
[in]dgpThe 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().

Here is the caller graph for this function:

◆ graph_save()

size_t graph_save ( const struct Graph dgp,
FILE *  fp 
)

Writes DGP graph to a file.

Parameters
[in]dgpThe DGP graph to save.
[in]fpPointer to the file to be written.
Returns
The number of elements 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().

Here is the caller graph for this function:

◆ graph_update()

void graph_update ( const struct Graph dgp,
const double *  inputs,
const bool  reset 
)

Updates a DGP graph T cycles.

Parameters
[in]dgpThe DGP graph to update.
[in]inputsThe inputs to the graph.
[in]resetWhether 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().

Here is the call graph for this function:
Here is the caller graph for this function: