XCSF  1.4.7
XCSF learning classifier system
pred_nlms.h File Reference

Normalised least mean squares prediction functions. More...

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

Go to the source code of this file.

Data Structures

struct  PredNLMS
 Normalised least mean squares prediction data structure. More...
 

Functions

char * pred_nlms_param_json_import (struct XCSF *xcsf, cJSON *json)
 Sets the NLMS parameters from a cJSON object. More...
 
char * pred_nlms_param_json_export (const struct XCSF *xcsf)
 Returns a json formatted string of the NLMS parameters. More...
 
bool pred_nlms_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Dummy function since NLMS predictions do not perform crossover. More...
 
bool pred_nlms_mutate (const struct XCSF *xcsf, const struct Cl *c)
 Mutates the gradient descent rate used to update an NLMS prediction. More...
 
double pred_nlms_size (const struct XCSF *xcsf, const struct Cl *c)
 Returns the size of an NLMS prediction. More...
 
size_t pred_nlms_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp)
 Reads an NLMS prediction from a file. More...
 
size_t pred_nlms_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
 Writes an NLMS prediction to a file. More...
 
void pred_nlms_compute (const struct XCSF *xcsf, const struct Cl *c, const double *x)
 Computes the current NLMS prediction for a provided input. More...
 
void pred_nlms_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
 Copies an NLMS prediction from one classifier to another. More...
 
void pred_nlms_free (const struct XCSF *xcsf, const struct Cl *c)
 Frees the memory used by an NLMS prediction. More...
 
void pred_nlms_init (const struct XCSF *xcsf, struct Cl *c)
 Initialises an NLMS prediction. More...
 
void pred_nlms_print (const struct XCSF *xcsf, const struct Cl *c)
 Prints an NLMS prediction. More...
 
void pred_nlms_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
 Updates an NLMS prediction for a given input and truth sample. More...
 
char * pred_nlms_json_export (const struct XCSF *xcsf, const struct Cl *c)
 Returns a json formatted string representation of an NLMS prediction. More...
 
void pred_nlms_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
 Creates an NLMS prediction from a cJSON object. More...
 

Variables

static struct PredVtbl const pred_nlms_vtbl
 Normalised least mean squares prediction implemented functions. More...
 

Detailed Description

Normalised least mean squares prediction functions.

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

Definition in file pred_nlms.h.

Function Documentation

◆ pred_nlms_compute()

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

Computes the current NLMS prediction for a provided input.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier calculating the prediction.
[in]xThe input state.

Definition at line 138 of file pred_nlms.c.

References blas_dot(), PredNLMS::n, Cl::pred, pred_transform_input(), Cl::prediction, PredNLMS::tmp_input, and PredNLMS::weights.

Here is the call graph for this function:

◆ pred_nlms_copy()

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

Copies an NLMS prediction from one classifier to another.

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

Definition at line 79 of file pred_nlms.c.

References PredNLMS::eta, PredNLMS::mu, N_MU, PredNLMS::n_weights, Cl::pred, pred_nlms_init(), and PredNLMS::weights.

Here is the call graph for this function:

◆ pred_nlms_crossover()

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

Dummy function since NLMS predictions do not perform crossover.

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

Definition at line 170 of file pred_nlms.c.

◆ pred_nlms_free()

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

Frees the memory used by an NLMS prediction.

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

Definition at line 96 of file pred_nlms.c.

References PredNLMS::mu, Cl::pred, PredNLMS::tmp_input, and PredNLMS::weights.

◆ pred_nlms_init()

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

Initialises an NLMS prediction.

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

Definition at line 44 of file pred_nlms.c.

References blas_fill(), PredNLMS::eta, PredNLMS::mu, MU_TYPE, PredNLMS::n, N_MU, PredNLMS::n_weights, Cl::pred, PRED_TYPE_NLMS_QUADRATIC, rand_uniform(), sam_init(), PredNLMS::tmp_input, and PredNLMS::weights.

Referenced by pred_nlms_copy(), and pred_nlms_load().

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

◆ pred_nlms_json_export()

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

Returns a json formatted string representation of an NLMS prediction.

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

Definition at line 264 of file pred_nlms.c.

References PredNLMS::eta, PredNLMS::mu, N_MU, PredNLMS::n_weights, Cl::pred, PRED_TYPE_NLMS_QUADRATIC, and PredNLMS::weights.

Referenced by pred_nlms_print().

Here is the caller graph for this function:

◆ pred_nlms_json_import()

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

Creates an NLMS prediction from a cJSON object.

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

Definition at line 290 of file pred_nlms.c.

References PredNLMS::eta, PredNLMS::mu, N_MU, PredNLMS::n_weights, Cl::pred, sam_json_import(), and PredNLMS::weights.

Here is the call graph for this function:

◆ pred_nlms_load()

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

Reads an NLMS prediction from a file.

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

Definition at line 244 of file pred_nlms.c.

References PredNLMS::eta, PredNLMS::mu, PredNLMS::n, N_MU, PredNLMS::n_weights, Cl::pred, pred_nlms_init(), and PredNLMS::weights.

Here is the call graph for this function:

◆ pred_nlms_mutate()

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

Mutates the gradient descent rate used to update an NLMS prediction.

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

Definition at line 186 of file pred_nlms.c.

References clamp(), PredNLMS::eta, PredNLMS::mu, MU_TYPE, N_MU, Cl::pred, rand_normal(), and sam_adapt().

Here is the call graph for this function:

◆ pred_nlms_param_json_export()

char* pred_nlms_param_json_export ( const struct XCSF xcsf)

Returns a json formatted string of the NLMS parameters.

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

Definition at line 319 of file pred_nlms.c.

References ArgsPred::eta, ArgsPred::eta_min, ArgsPred::evolve_eta, and ArgsPred::x0.

Referenced by pred_param_json_export().

Here is the caller graph for this function:

◆ pred_nlms_param_json_import()

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

Sets the NLMS 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 341 of file pred_nlms.c.

References pred_param_set_eta(), pred_param_set_eta_min(), pred_param_set_evolve_eta(), and pred_param_set_x0().

Referenced by pred_param_json_import().

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

◆ pred_nlms_print()

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

Prints an NLMS prediction.

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

Definition at line 155 of file pred_nlms.c.

References pred_nlms_json_export().

Here is the call graph for this function:

◆ pred_nlms_save()

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

Writes an NLMS prediction to a file.

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

Definition at line 223 of file pred_nlms.c.

References PredNLMS::eta, PredNLMS::mu, PredNLMS::n, N_MU, PredNLMS::n_weights, Cl::pred, and PredNLMS::weights.

◆ pred_nlms_size()

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

Returns the size of an NLMS prediction.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose prediction size to return.
Returns
The number of weights.

Definition at line 208 of file pred_nlms.c.

References PredNLMS::n_weights, and Cl::pred.

◆ pred_nlms_update()

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

Updates an NLMS prediction for a given input and truth sample.

Precondition
The prediction has been computed for the current state.
Parameters
[in]xcsfThe XCSF data structure.
[in]cClassifier whose prediction is to be updated.
[in]xInput state.
[in]yTruth/payoff value.

Definition at line 115 of file pred_nlms.c.

References blas_axpy(), blas_dot(), PredNLMS::eta, PredNLMS::n, Cl::pred, Cl::prediction, PredNLMS::tmp_input, and PredNLMS::weights.

Here is the call graph for this function:

Variable Documentation

◆ pred_nlms_vtbl

struct PredVtbl const pred_nlms_vtbl
static
Initial value:
= {
}
void pred_nlms_json_import(const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
Creates an NLMS prediction from a cJSON object.
Definition: pred_nlms.c:290
void pred_nlms_compute(const struct XCSF *xcsf, const struct Cl *c, const double *x)
Computes the current NLMS prediction for a provided input.
Definition: pred_nlms.c:138
char * pred_nlms_json_export(const struct XCSF *xcsf, const struct Cl *c)
Returns a json formatted string representation of an NLMS prediction.
Definition: pred_nlms.c:264
size_t pred_nlms_save(const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
Writes an NLMS prediction to a file.
Definition: pred_nlms.c:223
bool pred_nlms_crossover(const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
Dummy function since NLMS predictions do not perform crossover.
Definition: pred_nlms.c:170
void pred_nlms_print(const struct XCSF *xcsf, const struct Cl *c)
Prints an NLMS prediction.
Definition: pred_nlms.c:155
void pred_nlms_init(const struct XCSF *xcsf, struct Cl *c)
Initialises an NLMS prediction.
Definition: pred_nlms.c:44
void pred_nlms_free(const struct XCSF *xcsf, const struct Cl *c)
Frees the memory used by an NLMS prediction.
Definition: pred_nlms.c:96
bool pred_nlms_mutate(const struct XCSF *xcsf, const struct Cl *c)
Mutates the gradient descent rate used to update an NLMS prediction.
Definition: pred_nlms.c:186
double pred_nlms_size(const struct XCSF *xcsf, const struct Cl *c)
Returns the size of an NLMS prediction.
Definition: pred_nlms.c:208
void pred_nlms_update(const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
Updates an NLMS prediction for a given input and truth sample.
Definition: pred_nlms.c:115
void pred_nlms_copy(const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
Copies an NLMS prediction from one classifier to another.
Definition: pred_nlms.c:79
size_t pred_nlms_load(const struct XCSF *xcsf, struct Cl *c, FILE *fp)
Reads an NLMS prediction from a file.
Definition: pred_nlms.c:244

Normalised least mean squares prediction implemented functions.

Definition at line 86 of file pred_nlms.h.

Referenced by prediction_set().