XCSF  1.4.7
XCSF learning classifier system
cond_neural.c File Reference

Multi-layer perceptron neural network condition functions. More...

Include dependency graph for cond_neural.c:

Go to the source code of this file.

Functions

void cond_neural_init (const struct XCSF *xcsf, struct Cl *c)
 Creates and initialises a neural network condition. More...
 
void cond_neural_free (const struct XCSF *xcsf, const struct Cl *c)
 Frees the memory used by a neural network condition. More...
 
void cond_neural_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
 Copies a neural network condition from one classifier to another. More...
 
void cond_neural_cover (const struct XCSF *xcsf, const struct Cl *c, const double *x)
 Generates a neural network that matches the current input. More...
 
void cond_neural_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
 Dummy update function. More...
 
bool cond_neural_match (const struct XCSF *xcsf, const struct Cl *c, const double *x)
 Generates a neural network that matches the current input. More...
 
bool cond_neural_mutate (const struct XCSF *xcsf, const struct Cl *c)
 Mutates a neural network condition with the self-adaptive rates. More...
 
bool cond_neural_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Dummy crossover function. More...
 
bool cond_neural_general (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Dummy general function. More...
 
void cond_neural_print (const struct XCSF *xcsf, const struct Cl *c)
 Prints a neural network condition. More...
 
double cond_neural_size (const struct XCSF *xcsf, const struct Cl *c)
 Returns the size of a neural network condition. More...
 
size_t cond_neural_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
 Writes a neural network condition to a file. More...
 
size_t cond_neural_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp)
 Reads a neural network condition from a file. More...
 
int cond_neural_neurons (const struct XCSF *xcsf, const struct Cl *c, int layer)
 Returns the number of neurons in a neural condition layer. More...
 
int cond_neural_connections (const struct XCSF *xcsf, const struct Cl *c, int layer)
 Returns the number of active connections in a neural condition layer. More...
 
int cond_neural_layers (const struct XCSF *xcsf, const struct Cl *c)
 Returns the number of layers within a neural network condition. More...
 
char * cond_neural_json_export (const struct XCSF *xcsf, const struct Cl *c)
 Returns a json formatted string representation of a neural condition. More...
 
void cond_neural_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
 Creates a neural condition from a cJSON object. More...
 
char * cond_neural_param_json_import (struct XCSF *xcsf, cJSON *json)
 Sets the neural network parameters from a cJSON object. More...
 
void cond_neural_param_defaults (struct XCSF *xcsf)
 Initialises default neural condition parameters. More...
 

Detailed Description

Multi-layer perceptron neural network condition functions.

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

Definition in file cond_neural.c.

Function Documentation

◆ cond_neural_connections()

int cond_neural_connections ( const struct XCSF xcsf,
const struct Cl c,
int  layer 
)

Returns the number of active connections in a neural condition layer.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier maintaining a neural network condition.
[in]layerPosition of a layer in the network.
Returns
The current number of active connections in a layer.

Definition at line 273 of file cond_neural.c.

References Cl::cond, Llist::layer, Layer::n_active, CondNeural::net, Llist::prev, and Net::tail.

Referenced by clset_mean_cond_connections().

Here is the caller graph for this function:

◆ cond_neural_copy()

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

Copies a neural network condition from one classifier to another.

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

Definition at line 70 of file cond_neural.c.

References Cl::cond, CondNeural::net, and neural_copy().

Here is the call graph for this function:

◆ cond_neural_cover()

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

Generates a neural network 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 86 of file cond_neural.c.

References Cl::cond, cond_neural_match(), CondNeural::net, and neural_rand().

Here is the call graph for this function:

◆ cond_neural_crossover()

bool cond_neural_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 150 of file cond_neural.c.

◆ cond_neural_free()

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

Frees the memory used by a neural network condition.

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

Definition at line 55 of file cond_neural.c.

References Cl::cond, CondNeural::net, and neural_free().

Here is the call graph for this function:

◆ cond_neural_general()

bool cond_neural_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 167 of file cond_neural.c.

◆ cond_neural_init()

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

Creates and initialises a neural network condition.

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

Definition at line 42 of file cond_neural.c.

References Cl::cond, and neural_create().

Here is the call graph for this function:

◆ cond_neural_json_export()

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

Returns a json formatted string representation of a neural condition.

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

Definition at line 312 of file cond_neural.c.

References Cl::cond, CondNeural::net, and neural_json_export().

Referenced by cond_neural_print().

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

◆ cond_neural_json_import()

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

Creates a neural condition from a cJSON object.

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

Definition at line 334 of file cond_neural.c.

References Cl::cond, CondNeural::net, and neural_json_import().

Here is the call graph for this function:

◆ cond_neural_layers()

int cond_neural_layers ( const struct XCSF xcsf,
const struct Cl c 
)

Returns the number of layers within a neural network condition.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier maintaining a neural network condition.
Returns
The number of layers.

Definition at line 297 of file cond_neural.c.

References Cl::cond, Net::n_layers, and CondNeural::net.

Referenced by clset_mean_cond_layers().

Here is the caller graph for this function:

◆ cond_neural_load()

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

Reads a neural network 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 228 of file cond_neural.c.

References Cl::cond, and neural_load().

Here is the call graph for this function:

◆ cond_neural_match()

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

Generates a neural network 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 118 of file cond_neural.c.

References Cl::cond, CondNeural::net, neural_output(), and neural_propagate().

Referenced by cond_neural_cover().

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

◆ cond_neural_mutate()

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

Mutates a neural network 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 135 of file cond_neural.c.

References Cl::cond, CondNeural::net, and neural_mutate().

Here is the call graph for this function:

◆ cond_neural_neurons()

int cond_neural_neurons ( const struct XCSF xcsf,
const struct Cl c,
int  layer 
)

Returns the number of neurons in a neural condition layer.

Parameters
[in]xcsfXCSF data structure.
[in]cClassifier maintaining a neural network prediction.
[in]layerPosition of a layer in the network.
Returns
The current number of neurons in a layer.

Definition at line 245 of file cond_neural.c.

References Cl::cond, CONVOLUTIONAL, Llist::layer, Layer::n_filters, Layer::n_outputs, CondNeural::net, Llist::prev, Net::tail, and Layer::type.

Referenced by clset_mean_cond_neurons().

Here is the caller graph for this function:

◆ cond_neural_param_defaults()

void cond_neural_param_defaults ( struct XCSF xcsf)

Initialises default neural condition parameters.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 383 of file cond_neural.c.

References CONNECTED, ArgsLayer::evolve_connect, ArgsLayer::evolve_neurons, ArgsLayer::evolve_weights, ArgsLayer::function, layer_args_copy(), layer_args_init(), LINEAR, LOGISTIC, ArgsLayer::max_neuron_grow, ArgsLayer::n_init, ArgsLayer::n_inputs, ArgsLayer::n_max, ArgsLayer::next, and ArgsLayer::type.

Referenced by cond_param_defaults().

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

◆ cond_neural_param_json_import()

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

Sets the neural network 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 353 of file cond_neural.c.

References layer_args_free(), layer_args_init(), layer_args_json_import(), layer_args_validate(), ArgsLayer::n_inputs, and ArgsLayer::next.

Referenced by cond_param_json_import().

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

◆ cond_neural_print()

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

Prints a neural network condition.

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

Definition at line 182 of file cond_neural.c.

References cond_neural_json_export().

Here is the call graph for this function:

◆ cond_neural_save()

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

Writes a neural network 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 212 of file cond_neural.c.

References Cl::cond, CondNeural::net, and neural_save().

Here is the call graph for this function:

◆ cond_neural_size()

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

Returns the size of a neural network condition.

See also
neural_size()
Parameters
[in]xcsfXCSF data structure.
[in]cClassifier whose condition size to return.
Returns
The network size.

Definition at line 197 of file cond_neural.c.

References Cl::cond, CondNeural::net, and neural_size().

Here is the call graph for this function:

◆ cond_neural_update()

void cond_neural_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 102 of file cond_neural.c.