XCSF  1.4.7
XCSF learning classifier system
xcsf.h File Reference

XCSF data structures. More...

#include "utils.h"
#include <errno.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for xcsf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Cl
 Classifier data structure. More...
 
struct  Clist
 Classifier linked list. More...
 
struct  Set
 Classifier set. More...
 
struct  XCSF
 XCSF data structure. More...
 
struct  Input
 Input data structure. More...
 

Functions

size_t xcsf_load (struct XCSF *xcsf, const char *filename)
 Reads the state of XCSF from a file. More...
 
size_t xcsf_save (const struct XCSF *xcsf, const char *filename)
 Writes the current state of XCSF to a file. More...
 
void xcsf_free (struct XCSF *xcsf)
 Frees XCSF population sets. More...
 
void xcsf_init (struct XCSF *xcsf)
 Initialises XCSF with an empty population. More...
 
void xcsf_print_pset (const struct XCSF *xcsf, const bool print_cond, const bool print_act, const bool print_pred)
 Prints the current XCSF population. More...
 
void xcsf_ae_to_classifier (struct XCSF *xcsf, const int y_dim, const int n_del)
 Switches from autoencoding to classification. More...
 
void xcsf_pred_expand (const struct XCSF *xcsf)
 Inserts a new hidden layer before the output layer within all prediction neural networks in the population. More...
 
void xcsf_retrieve_pset (struct XCSF *xcsf)
 Retrieves the previously stored population. More...
 
void xcsf_store_pset (struct XCSF *xcsf)
 Stores the current population. More...
 

Variables

static const int VERSION_MAJOR = 1
 XCSF major version number. More...
 
static const int VERSION_MINOR = 4
 XCSF minor version number. More...
 
static const int VERSION_BUILD = 7
 XCSF build version number. More...
 

Detailed Description

XCSF data structures.

Author
Richard Preen rpree.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om
Date
2019–2024.

Definition in file xcsf.h.

Function Documentation

◆ xcsf_ae_to_classifier()

void xcsf_ae_to_classifier ( struct XCSF xcsf,
const int  y_dim,
const int  n_del 
)

Switches from autoencoding to classification.

Parameters
[in]xcsfThe XCSF data structure.
[in]y_dimThe output dimension (i.e., the number of classes).
[in]n_delThe number of hidden layers to remove.

Definition at line 171 of file xcsf.c.

References Clist::cl, Cl::err, Cl::exp, Cl::fit, LOSS_ONEHOT, Clist::next, pa_free(), pa_init(), param_set_loss_func(), param_set_y_dim(), pred_neural_ae_to_classifier(), Cl::prediction, and Cl::time.

Referenced by XCS::ae_to_classifier().

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

◆ xcsf_free()

void xcsf_free ( struct XCSF xcsf)

Frees XCSF population sets.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 56 of file xcsf.c.

References clset_kill(), and pa_free().

Referenced by XCS::fit(), and main().

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

◆ xcsf_init()

void xcsf_init ( struct XCSF xcsf)

Initialises XCSF with an empty population.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 37 of file xcsf.c.

References clset_init(), clset_pset_init(), and pa_init().

Referenced by XCS::fit(), main(), and XCS::XCS().

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

◆ xcsf_load()

size_t xcsf_load ( struct XCSF xcsf,
const char *  filename 
)

Reads the state of XCSF from a file.

Parameters
[in]xcsfThe XCSF data structure.
[in]filenameThe name of the input file.
Returns
The total number of elements read.

Definition at line 114 of file xcsf.c.

References clset_init(), clset_kill(), clset_pset_load(), param_load(), VERSION_MAJOR, and VERSION_MINOR.

Referenced by XCS::deserialize(), XCS::load(), and main().

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

◆ xcsf_pred_expand()

void xcsf_pred_expand ( const struct XCSF xcsf)

Inserts a new hidden layer before the output layer within all prediction neural networks in the population.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 151 of file xcsf.c.

References Clist::cl, Cl::err, Cl::exp, Cl::fit, Clist::next, pred_neural_expand(), and Cl::time.

Referenced by XCS::pred_expand().

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

◆ xcsf_print_pset()

void xcsf_print_pset ( const struct XCSF xcsf,
const bool  print_cond,
const bool  print_act,
const bool  print_pred 
)

Prints the current XCSF population.

Parameters
[in]xcsfThe XCSF data structure.
[in]print_condWhether to print condition structures.
[in]print_actWhether to print action structures.
[in]print_predWhether to print prediction structures.

Definition at line 77 of file xcsf.c.

References clset_print().

Referenced by XCS::print_pset().

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

◆ xcsf_retrieve_pset()

void xcsf_retrieve_pset ( struct XCSF xcsf)

Retrieves the previously stored population.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 213 of file xcsf.c.

References clset_init(), and clset_kill().

Referenced by EarlyStoppingCallback::retrieve(), and XCS::retrieve().

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

◆ xcsf_save()

size_t xcsf_save ( const struct XCSF xcsf,
const char *  filename 
)

Writes the current state of XCSF to a file.

Parameters
[in]xcsfThe XCSF data structure.
[in]filenameThe name of the output file.
Returns
The total number of elements written.

Definition at line 90 of file xcsf.c.

References clset_pset_save(), param_save(), VERSION_BUILD, VERSION_MAJOR, and VERSION_MINOR.

Referenced by XCS::save(), CheckpointCallback::save(), and XCS::serialize().

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

◆ xcsf_store_pset()

void xcsf_store_pset ( struct XCSF xcsf)

Stores the current population.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 195 of file xcsf.c.

References Clist::cl, cl_init_copy(), clset_add(), clset_kill(), and Clist::next.

Referenced by EarlyStoppingCallback::store(), and XCS::store().

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

Variable Documentation

◆ VERSION_BUILD

const int VERSION_BUILD = 7
static

XCSF build version number.

Definition at line 40 of file xcsf.h.

Referenced by param_json_export(), and xcsf_save().

◆ VERSION_MAJOR

const int VERSION_MAJOR = 1
static

XCSF major version number.

Definition at line 38 of file xcsf.h.

Referenced by param_json_export(), xcsf_load(), and xcsf_save().

◆ VERSION_MINOR

const int VERSION_MINOR = 4
static

XCSF minor version number.

Definition at line 39 of file xcsf.h.

Referenced by param_json_export(), xcsf_load(), and xcsf_save().