XCSF  1.4.7
XCSF learning classifier system
cond_dgp.c File Reference

Dynamical GP graph condition functions. More...

#include "cond_dgp.h"
#include "sam.h"
#include "utils.h"
Include dependency graph for cond_dgp.c:

Go to the source code of this file.

Functions

void cond_dgp_init (const struct XCSF *xcsf, struct Cl *c)
 Creates and initialises a dynamical GP graph condition. More...
 
void cond_dgp_free (const struct XCSF *xcsf, const struct Cl *c)
 Frees the memory used by a dynamical GP graph condition. More...
 
void cond_dgp_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
 Copies a dynamical GP graph condition from one classifier to another. More...
 
void cond_dgp_cover (const struct XCSF *xcsf, const struct Cl *c, const double *x)
 Generates a dynamical GP graph that matches the current input. More...
 
void cond_dgp_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
 Dummy update function. More...
 
bool cond_dgp_match (const struct XCSF *xcsf, const struct Cl *c, const double *x)
 Calculates whether a dynamical GP graph condition matches an input. More...
 
bool cond_dgp_mutate (const struct XCSF *xcsf, const struct Cl *c)
 Mutates a dynamical GP graph condition with the self-adaptive rates. More...
 
bool cond_dgp_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Dummy crossover function. More...
 
bool cond_dgp_general (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Dummy general function. More...
 
void cond_dgp_print (const struct XCSF *xcsf, const struct Cl *c)
 Prints a dynamical GP graph condition. More...
 
double cond_dgp_size (const struct XCSF *xcsf, const struct Cl *c)
 Returns the size of a dynamical GP graph condition. More...
 
size_t cond_dgp_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
 Writes a dynamical GP graph condition to a file. More...
 
size_t cond_dgp_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp)
 Reads a dynamical GP graph condition from a file. More...
 
char * cond_dgp_json_export (const struct XCSF *xcsf, const struct Cl *c)
 Returns a json formatted string representation of a DGP condition. More...
 
void cond_dgp_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
 Creates a DGP condition from a cJSON object. More...
 
char * cond_dgp_param_json_export (const struct XCSF *xcsf)
 Returns a json formatted string of the DGP parameters. More...
 
char * cond_dgp_param_json_import (struct XCSF *xcsf, cJSON *json)
 Sets the DGP parameters from a cJSON object. More...
 
void cond_dgp_param_defaults (struct XCSF *xcsf)
 Initialises default DGP condition parameters. More...
 

Detailed Description

Dynamical GP graph condition functions.

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

Definition in file cond_dgp.c.

Function Documentation

◆ cond_dgp_copy()

void cond_dgp_copy ( const struct XCSF xcsf,
struct Cl dest,
const struct Cl src 
)

Copies a dynamical GP graph condition from one classifier to another.

Parameters
[in]xcsfXCSF data structure.
[in]destDestination classifier.
[in]srcSource classifier.

Definition at line 63 of file cond_dgp.c.

References Cl::cond, CondDGP::dgp, graph_copy(), and graph_init().

Here is the call graph for this function:

◆ cond_dgp_cover()

void cond_dgp_cover ( const struct XCSF xcsf,
const struct Cl c,
const double *  x 
)

Generates a dynamical GP graph that matches the current input.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition is being covered.
[in]xInput state to cover.

Definition at line 79 of file cond_dgp.c.

References Cl::cond, cond_dgp_match(), CondDGP::dgp, and graph_rand().

Here is the call graph for this function:

◆ cond_dgp_crossover()

bool cond_dgp_crossover ( const struct XCSF xcsf,
const struct Cl c1,
const struct Cl c2 
)

Dummy crossover function.

Parameters
[in]xcsfXCSF data structure.
[in]c1First classifier whose condition is being crossed.
[in]c2Second classifier whose condition is being crossed.
Returns
False.

Definition at line 145 of file cond_dgp.c.

◆ cond_dgp_free()

void cond_dgp_free ( const struct XCSF xcsf,
const struct Cl c 
)

Frees the memory used by a dynamical GP graph condition.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition is to be freed.

Definition at line 48 of file cond_dgp.c.

References Cl::cond, CondDGP::dgp, and graph_free().

Here is the call graph for this function:

◆ cond_dgp_general()

bool cond_dgp_general ( const struct XCSF xcsf,
const struct Cl c1,
const struct Cl c2 
)

Dummy general function.

Parameters
[in]xcsfXCSF data structure.
[in]c1Classifier whose condition is tested to be more general.
[in]c2Classifier whose condition is tested to be more specific.
Returns
False.

Definition at line 162 of file cond_dgp.c.

◆ cond_dgp_init()

void cond_dgp_init ( const struct XCSF xcsf,
struct Cl c 
)

Creates and initialises a dynamical GP graph condition.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose condition is to be initialised.

Definition at line 34 of file cond_dgp.c.

References Cl::cond, graph_init(), and graph_rand().

Here is the call graph for this function:

◆ cond_dgp_json_export()

char* cond_dgp_json_export ( const struct XCSF xcsf,
const struct Cl c 
)

Returns a json formatted string representation of a DGP condition.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition is to be returned.
Returns
String encoded in json format.

Definition at line 238 of file cond_dgp.c.

References Cl::cond, CondDGP::dgp, and graph_json_export().

Referenced by cond_dgp_print().

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

◆ cond_dgp_json_import()

void cond_dgp_json_import ( const struct XCSF xcsf,
struct Cl c,
const cJSON *  json 
)

Creates a DGP condition from a cJSON object.

Parameters
[in]xcsfThe XCSF data structure.
[in,out]cThe classifier to initialise.
[in]jsoncJSON object.

Definition at line 260 of file cond_dgp.c.

References Cl::cond, CondDGP::dgp, graph_free(), and graph_json_import().

Here is the call graph for this function:

◆ cond_dgp_load()

size_t cond_dgp_load ( const struct XCSF xcsf,
struct Cl c,
FILE *  fp 
)

Reads a dynamical GP graph condition from a file.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition is to be read.
[in]fpPointer to the file to be read.
Returns
The number of elements read.

Definition at line 222 of file cond_dgp.c.

References Cl::cond, and graph_load().

Here is the call graph for this function:

◆ cond_dgp_match()

bool cond_dgp_match ( const struct XCSF xcsf,
const struct Cl c,
const double *  x 
)

Calculates whether a dynamical GP graph condition matches an input.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition to match.
[in]xInput state.
Returns
Whether the dynamical GP graph condition matches the input.

Definition at line 113 of file cond_dgp.c.

References Cl::cond, CondDGP::dgp, graph_output(), and graph_update().

Referenced by cond_dgp_cover().

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

◆ cond_dgp_mutate()

bool cond_dgp_mutate ( const struct XCSF xcsf,
const struct Cl c 
)

Mutates a dynamical GP graph condition with the self-adaptive rates.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition is being mutated.
Returns
Whether any alterations were made.

Definition at line 130 of file cond_dgp.c.

References Cl::cond, CondDGP::dgp, and graph_mutate().

Here is the call graph for this function:

◆ cond_dgp_param_defaults()

void cond_dgp_param_defaults ( struct XCSF xcsf)

Initialises default DGP condition parameters.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 300 of file cond_dgp.c.

References graph_args_init(), graph_param_set_evolve_cycles(), graph_param_set_max_k(), graph_param_set_max_t(), graph_param_set_n(), and graph_param_set_n_inputs().

Referenced by cond_param_defaults().

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

◆ cond_dgp_param_json_export()

char* cond_dgp_param_json_export ( const struct XCSF xcsf)

Returns a json formatted string of the DGP parameters.

Parameters
[in]xcsfThe XCSF data structure.
Returns
String encoded in json format.

Definition at line 278 of file cond_dgp.c.

References graph_args_json_export().

Referenced by cond_param_json_export().

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

◆ cond_dgp_param_json_import()

char* cond_dgp_param_json_import ( struct XCSF xcsf,
cJSON *  json 
)

Sets the DGP parameters from a cJSON object.

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

Definition at line 290 of file cond_dgp.c.

References graph_args_json_import().

Referenced by cond_param_json_import().

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

◆ cond_dgp_print()

void cond_dgp_print ( const struct XCSF xcsf,
const struct Cl c 
)

Prints a dynamical GP graph condition.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition is to be printed.

Definition at line 177 of file cond_dgp.c.

References cond_dgp_json_export().

Here is the call graph for this function:

◆ cond_dgp_save()

size_t cond_dgp_save ( const struct XCSF xcsf,
const struct Cl c,
FILE *  fp 
)

Writes a dynamical GP graph condition to a file.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition is to be written.
[in]fpPointer to the file to be written.
Returns
The number of elements written.

Definition at line 206 of file cond_dgp.c.

References Cl::cond, CondDGP::dgp, and graph_save().

Here is the call graph for this function:

◆ cond_dgp_size()

double cond_dgp_size ( const struct XCSF xcsf,
const struct Cl c 
)

Returns the size of a dynamical GP graph condition.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition size to return.
Returns
The number of nodes in the graph.

Definition at line 191 of file cond_dgp.c.

References Cl::cond, CondDGP::dgp, and Graph::n.

◆ cond_dgp_update()

void cond_dgp_update ( const struct XCSF xcsf,
const struct Cl c,
const double *  x,
const double *  y 
)

Dummy update function.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition is to be updated.
[in]xInput state.
[in]yTruth/payoff value.

Definition at line 96 of file cond_dgp.c.