XCSF  1.4.7
XCSF learning classifier system
act_integer.c File Reference

integer action functions. More...

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

Go to the source code of this file.

Macros

#define N_MU   (1)
 Number of integer action mutation rates. More...
 

Functions

bool act_integer_crossover (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Dummy function since integer actions do not perform crossover. More...
 
bool act_integer_general (const struct XCSF *xcsf, const struct Cl *c1, const struct Cl *c2)
 Returns whether the action of classifier c1 is more general than c2. More...
 
bool act_integer_mutate (const struct XCSF *xcsf, const struct Cl *c)
 Mutates an integer action. More...
 
int act_integer_compute (const struct XCSF *xcsf, const struct Cl *c, const double *x)
 Returns a classifier's integer action. More...
 
void act_integer_copy (const struct XCSF *xcsf, struct Cl *dest, const struct Cl *src)
 Copies an integer action from one classifier to another. More...
 
void act_integer_print (const struct XCSF *xcsf, const struct Cl *c)
 Prints an integer action. More...
 
void act_integer_cover (const struct XCSF *xcsf, const struct Cl *c, const double *x, const int action)
 Sets an integer action to a specified value. More...
 
void act_integer_free (const struct XCSF *xcsf, const struct Cl *c)
 Frees the memory used by an integer action. More...
 
void act_integer_init (const struct XCSF *xcsf, struct Cl *c)
 Initialises an integer action. More...
 
void act_integer_update (const struct XCSF *xcsf, const struct Cl *c, const double *x, const double *y)
 Dummy function since integer actions are not updated. More...
 
size_t act_integer_save (const struct XCSF *xcsf, const struct Cl *c, FILE *fp)
 Writes an integer action to a file. More...
 
size_t act_integer_load (const struct XCSF *xcsf, struct Cl *c, FILE *fp)
 Reads an integer action from a file. More...
 
char * act_integer_json_export (const struct XCSF *xcsf, const struct Cl *c)
 Returns a json formatted string representation of an integer action. More...
 
void act_integer_json_import (const struct XCSF *xcsf, struct Cl *c, const cJSON *json)
 Creates an integer action from a cJSON object. More...
 

Variables

static const int MU_TYPE [(1)] = { (0) }
 Self-adaptation method for mutating integer actions. More...
 

Detailed Description

integer action functions.

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

Definition in file act_integer.c.

Macro Definition Documentation

◆ N_MU

#define N_MU   (1)

Number of integer action mutation rates.

Definition at line 28 of file act_integer.c.

Function Documentation

◆ act_integer_compute()

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

Returns a classifier's integer action.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier whose action to return.
[in]xThe input state.
Returns
The classifier's action.

Definition at line 101 of file act_integer.c.

References Cl::act, and ActInteger::action.

◆ act_integer_copy()

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

Copies an integer action from one classifier to another.

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

Definition at line 117 of file act_integer.c.

References Cl::act, ActInteger::action, ActInteger::mu, and N_MU.

◆ act_integer_cover()

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

Sets an integer action to a specified value.

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 149 of file act_integer.c.

References Cl::act, and ActInteger::action.

◆ act_integer_crossover()

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

Dummy function since integer actions do not perform crossover.

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 43 of file act_integer.c.

◆ act_integer_free()

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

Frees the memory used by an integer action.

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

Definition at line 164 of file act_integer.c.

References Cl::act, and ActInteger::mu.

◆ act_integer_general()

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

Returns whether the action of classifier c1 is more general than c2.

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
Whether the action of c1 is more general than c2.

Definition at line 60 of file act_integer.c.

References Cl::act, and ActInteger::action.

◆ act_integer_init()

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

Initialises an integer action.

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

Definition at line 178 of file act_integer.c.

References Cl::act, MU_TYPE, N_MU, rand_uniform_int(), and sam_init().

Here is the call graph for this function:

◆ act_integer_json_export()

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

Returns a json formatted string representation of an integer action.

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

Definition at line 249 of file act_integer.c.

References Cl::act, ActInteger::action, ActInteger::mu, and N_MU.

Referenced by act_integer_print().

Here is the caller graph for this function:

◆ act_integer_json_import()

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

Creates an integer action from a cJSON object.

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

Definition at line 270 of file act_integer.c.

References Cl::act, ActInteger::action, ActInteger::mu, N_MU, and sam_json_import().

Here is the call graph for this function:

◆ act_integer_load()

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

Reads an integer 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 230 of file act_integer.c.

References Cl::act, and N_MU.

◆ act_integer_mutate()

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

Mutates an integer action.

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

Definition at line 79 of file act_integer.c.

References Cl::act, ActInteger::action, ActInteger::mu, MU_TYPE, N_MU, rand_uniform(), rand_uniform_int(), and sam_adapt().

Here is the call graph for this function:

◆ act_integer_print()

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

Prints an integer action.

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

Definition at line 134 of file act_integer.c.

References act_integer_json_export().

Here is the call graph for this function:

◆ act_integer_save()

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

Writes an integer 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 212 of file act_integer.c.

References Cl::act, ActInteger::action, ActInteger::mu, and N_MU.

◆ act_integer_update()

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

Dummy function since integer actions are not updated.

Parameters
[in]xcsfThe XCSF data structure.
[in]cA classifier data structure.
[in]xThe input state.
[in]yThe payoff value.

Definition at line 195 of file act_integer.c.

Variable Documentation

◆ MU_TYPE

const int MU_TYPE[(1)] = { (0) }
static

Self-adaptation method for mutating integer actions.

Definition at line 33 of file act_integer.c.

Referenced by act_integer_init(), and act_integer_mutate().