XCSF  1.4.7
XCSF learning classifier system
act_neural.c File Reference

Neural network action functions. More...

Include dependency graph for act_neural.c:

Go to the source code of this file.

Functions

void act_neural_init (const struct XCSF *xcsf, struct Cl *c)
 Creates and initialises an action neural network. More...
 
bool act_neural_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Dummy function since crossover is not performed on neural actions. More...
 
bool act_neural_general (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Dummy function since neural actions do not generalise another. More...
 
bool act_neural_mutate (const struct XCSF *xcsf, const struct Cl *c)
 Mutates a neural network action. More...
 
int act_neural_compute (const struct XCSF *xcsf, const struct Cl *c, const double *x)
 Computes the current neural network action using the input. More...
 
void act_neural_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
 Copies a neural network action from one classifier to another. More...
 
void act_neural_print (const struct XCSF *xcsf, const struct Cl *c)
 Prints a neural network action. More...
 
void act_neural_cover (const struct XCSF *xcsf, const struct Cl *c, const double *x, const int action)
 Generates a neural network that covers the specified input:action. More...
 
void act_neural_free (const struct XCSF *xcsf, const struct Cl *c)
 Frees the memory used by a neural network action. More...
 
void act_neural_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
 Dummy function since neural network actions are not updated. More...
 
size_t act_neural_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
 Writes a neural network action to a file. More...
 
size_t act_neural_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp)
 Reads a neural network action from a file. More...
 
char * act_neural_json_export (const struct XCSF *xcsf, const struct Cl *c)
 Returns a json formatted string representation of a neural action. More...
 
void act_neural_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
 Creates a neural action from a cJSON object. More...
 
void act_neural_param_defaults (struct XCSF *xcsf)
 Initialises default neural action parameters. More...
 
char * act_neural_param_json_import (struct XCSF *xcsf, cJSON *json)
 Sets the neural network parameters from a cJSON object. More...
 

Detailed Description

Neural network action functions.

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

Definition in file act_neural.c.

Function Documentation

◆ act_neural_compute()

int act_neural_compute ( const struct XCSF xcsf,
const struct Cl c,
const double *  x 
)

Computes the current neural network action using the input.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier calculating the action.
[in]xThe input state.
Returns
The neural action.

Definition at line 107 of file act_neural.c.

References Cl::act, argmax(), ActNeural::net, neural_outputs(), and neural_propagate().

Referenced by act_neural_cover().

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

◆ act_neural_copy()

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

Copies a neural network action from one classifier to another.

Parameters
[in]xcsfThe XCSF data structure.
[in]destThe destination classifier.
[in]srcThe source classifier.

Definition at line 122 of file act_neural.c.

References Cl::act, ActNeural::net, and neural_copy().

Here is the call graph for this function:

◆ act_neural_cover()

void act_neural_cover ( const struct XCSF xcsf,
const struct Cl c,
const double *  x,
const int  action 
)

Generates a neural network that covers the specified input:action.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose action is being covered.
[in]xThe input state to cover.
[in]actionThe action to cover.

Definition at line 152 of file act_neural.c.

References Cl::act, act_neural_compute(), ActNeural::net, and neural_rand().

Here is the call graph for this function:

◆ act_neural_crossover()

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

Dummy function since crossover is not performed on neural actions.

Parameters
[in]xcsfThe XCSF data structure.
[in]c1The first classifier whose action is being crossed.
[in]c2The second classifier whose action is being crossed.
Returns
False.

Definition at line 59 of file act_neural.c.

◆ act_neural_free()

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

Frees the memory used by a neural network action.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose action is to be freed.

Definition at line 167 of file act_neural.c.

References Cl::act, ActNeural::net, and neural_free().

Here is the call graph for this function:

◆ act_neural_general()

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

Dummy function since neural actions do not generalise another.

Parameters
[in]xcsfThe XCSF data structure.
[in]c1The classifier whose action is tested to be more general.
[in]c2The classifier whose action is tested to be more specific.
Returns
False.

Definition at line 76 of file act_neural.c.

◆ act_neural_init()

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

Creates and initialises an action neural network.

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

Definition at line 44 of file act_neural.c.

References Cl::act, and neural_create().

Here is the call graph for this function:

◆ act_neural_json_export()

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

Returns a json formatted string representation of a neural action.

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

Definition at line 232 of file act_neural.c.

References Cl::act, ActNeural::net, and neural_json_export().

Referenced by act_neural_print().

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

◆ act_neural_json_import()

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

Creates a neural action from a cJSON object.

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

Definition at line 254 of file act_neural.c.

References Cl::act, ActNeural::net, and neural_json_import().

Here is the call graph for this function:

◆ act_neural_load()

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

Reads a neural network action from a file.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose action is to be read.
[in]fpPointer to the file to be read.
Returns
The number of elements read.

Definition at line 216 of file act_neural.c.

References Cl::act, and neural_load().

Here is the call graph for this function:

◆ act_neural_mutate()

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

Mutates a neural network action.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose action is being mutated.
Returns
Whether any alterations were made.

Definition at line 92 of file act_neural.c.

References Cl::act, ActNeural::net, and neural_mutate().

Here is the call graph for this function:

◆ act_neural_param_defaults()

void act_neural_param_defaults ( struct XCSF xcsf)

Initialises default neural action parameters.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 270 of file act_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, ArgsLayer::scale, SOFTMAX, and ArgsLayer::type.

Referenced by action_param_defaults().

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

◆ act_neural_param_json_import()

char* act_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 305 of file act_neural.c.

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

Referenced by action_param_json_import().

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

◆ act_neural_print()

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

Prints a neural network action.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose action is to be printed.

Definition at line 137 of file act_neural.c.

References act_neural_json_export().

Here is the call graph for this function:

◆ act_neural_save()

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

Writes a neural network action to a file.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose action is to be written.
[in]fpPointer to the file to be written.
Returns
The number of elements written.

Definition at line 200 of file act_neural.c.

References Cl::act, ActNeural::net, and neural_save().

Here is the call graph for this function:

◆ act_neural_update()

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

Dummy function since neural network actions are not updated.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose action is to be updated.
[in]xThe input state.
[in]yThe payoff value.

Definition at line 183 of file act_neural.c.