XCSF  1.4.7
XCSF learning classifier system
pred_constant.c File Reference

Piece-wise constant prediction functions. More...

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

Go to the source code of this file.

Functions

void pred_constant_init (const struct XCSF *xcsf, struct Cl *c)
 Dummy function since constant predictions have no data structure. More...
 
void pred_constant_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
 Dummy function since constant predictions have no data structure. More...
 
void pred_constant_free (const struct XCSF *xcsf, const struct Cl *c)
 Dummy function since constant predictions have no data structure. More...
 
void pred_constant_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
 Updates a constant prediction for a given input and truth sample. More...
 
void pred_constant_compute (const struct XCSF *xcsf, const struct Cl *c, const double *x)
 Dummy function since constant predictions are not computed. More...
 
void pred_constant_print (const struct XCSF *xcsf, const struct Cl *c)
 Prints a constant prediction. More...
 
bool pred_constant_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Dummy function since constant predictions do not perform crossover. More...
 
bool pred_constant_mutate (const struct XCSF *xcsf, const struct Cl *c)
 Dummy function since constant predictions do not perform mutation. More...
 
double pred_constant_size (const struct XCSF *xcsf, const struct Cl *c)
 Returns the size of a constant prediction. More...
 
size_t pred_constant_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
 Dummy function since constant predictions have no data structure. More...
 
size_t pred_constant_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp)
 Dummy function since constant predictions have no data structure. More...
 
char * pred_constant_json_export (const struct XCSF *xcsf, const struct Cl *c)
 Returns a json formatted string representation of a prediction. More...
 
void pred_constant_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
 Creates a constant prediction from a cJSON object. More...
 

Detailed Description

Piece-wise constant prediction functions.

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

Definition in file pred_constant.c.

Function Documentation

◆ pred_constant_compute()

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

Dummy function since constant predictions are not computed.

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

Definition at line 97 of file pred_constant.c.

◆ pred_constant_copy()

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

Dummy function since constant predictions have no data structure.

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

Definition at line 46 of file pred_constant.c.

◆ pred_constant_crossover()

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

Dummy function since constant 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 126 of file pred_constant.c.

◆ pred_constant_free()

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

Dummy function since constant predictions have no data structure.

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

Definition at line 60 of file pred_constant.c.

◆ pred_constant_init()

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

Dummy function since constant predictions have no data structure.

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

Definition at line 33 of file pred_constant.c.

◆ pred_constant_json_export()

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

Returns a json formatted string representation of a prediction.

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

Definition at line 201 of file pred_constant.c.

References Cl::prediction.

Referenced by pred_constant_print().

Here is the caller graph for this function:

◆ pred_constant_json_import()

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

Creates a constant prediction from a cJSON object.

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

Definition at line 219 of file pred_constant.c.

References Cl::prediction.

◆ pred_constant_load()

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

Dummy function since constant predictions have no data structure.

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

Definition at line 186 of file pred_constant.c.

◆ pred_constant_mutate()

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

Dummy function since constant predictions do not perform mutation.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose prediction is being mutated.
Returns
False.

Definition at line 142 of file pred_constant.c.

◆ pred_constant_print()

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

Prints a constant prediction.

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

Definition at line 111 of file pred_constant.c.

References pred_constant_json_export().

Here is the call graph for this function:

◆ pred_constant_save()

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

Dummy function since constant predictions have no data structure.

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

Definition at line 170 of file pred_constant.c.

◆ pred_constant_size()

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

Returns the size of a constant prediction.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose prediction size to return.
Returns
The output dimension.

Definition at line 156 of file pred_constant.c.

◆ pred_constant_update()

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

Updates a constant prediction for a given input and truth sample.

Parameters
[in]xcsfThe XCSF data structure.
[in]cClassifier whose prediction is to be updated.
[in]xInput state.
[in]yTruth/payoff value.

Definition at line 74 of file pred_constant.c.

References Cl::exp, and Cl::prediction.