XCSF  1.4.7
XCSF learning classifier system
pa.c File Reference

Prediction array functions. More...

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

Go to the source code of this file.

Functions

static void pa_reset (const struct XCSF *xcsf)
 Resets the prediction array to zero. More...
 
void pa_init (struct XCSF *xcsf)
 Initialises the prediction array. More...
 
void pa_build (const struct XCSF *xcsf, const double *x)
 Builds the prediction array for the specified input. More...
 
int pa_best_action (const struct XCSF *xcsf)
 Returns the best action in the prediction array. More...
 
int pa_rand_action (const struct XCSF *xcsf)
 Returns a random action from the prediction array. More...
 
double pa_best_val (const struct XCSF *xcsf)
 Returns the highest value in the prediction array. More...
 
double pa_val (const struct XCSF *xcsf, const int action)
 Returns the value of a specified action in the prediction array. More...
 
void pa_free (const struct XCSF *xcsf)
 Frees the prediction array. More...
 

Detailed Description

Prediction array functions.

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

Definition in file pa.c.

Function Documentation

◆ pa_best_action()

int pa_best_action ( const struct XCSF xcsf)

Returns the best action in the prediction array.

Ties broken uniformly random.

Parameters
[in]xcsfThe XCSF data structure.
Returns
The best action.

Definition at line 123 of file pa.c.

References rand_uniform_int().

Referenced by xcs_rl_decision().

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

◆ pa_best_val()

double pa_best_val ( const struct XCSF xcsf)

Returns the highest value in the prediction array.

Parameters
[in]xcsfThe XCSF data structure.
Returns
The highest value in the prediction array.

Definition at line 165 of file pa.c.

References argmax().

Referenced by xcs_rl_update().

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

◆ pa_build()

void pa_build ( const struct XCSF xcsf,
const double *  x 
)

Builds the prediction array for the specified input.

Calculates the match set mean fitness weighted prediction for each action. For supervised learning n_actions=1; reinforcement learning y_dim=1.

Parameters
[in]xcsfThe XCSF data structure.
[in]xThe input state.

Definition at line 62 of file pa.c.

References Cl::action, Clist::cl, cl_predict(), Cl::fit, Set::list, Clist::next, pa_reset(), Cl::prediction, and Set::size.

Referenced by xcs_rl_decision(), xcs_rl_fit(), and xcs_supervised_trial().

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

◆ pa_free()

void pa_free ( const struct XCSF xcsf)

Frees the prediction array.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 192 of file pa.c.

Referenced by xcsf_ae_to_classifier(), and xcsf_free().

Here is the caller graph for this function:

◆ pa_init()

void pa_init ( struct XCSF xcsf)

Initialises the prediction array.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 46 of file pa.c.

Referenced by xcsf_ae_to_classifier(), and xcsf_init().

Here is the caller graph for this function:

◆ pa_rand_action()

int pa_rand_action ( const struct XCSF xcsf)

Returns a random action from the prediction array.

Parameters
[in]xcsfThe XCSF data structure.
Returns
A random action.

Definition at line 150 of file pa.c.

References rand_uniform_int().

Referenced by xcs_rl_decision().

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

◆ pa_reset()

static void pa_reset ( const struct XCSF xcsf)
static

Resets the prediction array to zero.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 33 of file pa.c.

Referenced by pa_build().

Here is the caller graph for this function:

◆ pa_val()

double pa_val ( const struct XCSF xcsf,
const int  action 
)

Returns the value of a specified action in the prediction array.

Parameters
[in]xcsfThe XCSF data structure.
[in]actionThe specified action.
Returns
The value of the action in the prediction array.

Definition at line 178 of file pa.c.

Referenced by xcs_rl_end_step(), xcs_rl_error(), and xcs_rl_fit().

Here is the caller graph for this function: