XCSF  1.4.7
XCSF learning classifier system
condition.c File Reference

Interface for classifier conditions. More...

#include "cond_dgp.h"
#include "cond_dummy.h"
#include "cond_ellipsoid.h"
#include "cond_gp.h"
#include "cond_neural.h"
#include "cond_rectangle.h"
#include "cond_ternary.h"
#include "rule_dgp.h"
#include "rule_neural.h"
#include "utils.h"
Include dependency graph for condition.c:

Go to the source code of this file.

Functions

void condition_set (const struct XCSF *xcsf, struct Cl *c)
 Sets a classifier's condition functions to the implementations. More...
 
const char * condition_type_as_string (const int type)
 Returns a string representation of a condition type from an integer. More...
 
int condition_type_as_int (const char *type)
 Returns the integer representation of a condition type given a name. More...
 
void cond_param_defaults (struct XCSF *xcsf)
 Initialises default condition parameters. More...
 
static char * cond_param_json_export_csr (const struct XCSF *xcsf)
 Returns a json formatted string of the center-spread parameters. More...
 
static char * cond_param_json_import_csr (struct XCSF *xcsf, cJSON *json)
 Sets the center-spread parameters from a cJSON object. More...
 
char * cond_param_json_export (const struct XCSF *xcsf)
 Returns a json formatted string of the condition parameters. More...
 
char * cond_param_json_import (struct XCSF *xcsf, cJSON *json)
 Sets the condition parameters from a cJSON object. More...
 
size_t cond_param_save (const struct XCSF *xcsf, FILE *fp)
 Saves condition parameters. More...
 
size_t cond_param_load (struct XCSF *xcsf, FILE *fp)
 Loads condition parameters. More...
 
void cond_param_free (struct XCSF *xcsf)
 Frees condition parameters. More...
 
void cond_param_set_eta (struct XCSF *xcsf, const double a)
 
void cond_param_set_min (struct XCSF *xcsf, const double a)
 
void cond_param_set_max (struct XCSF *xcsf, const double a)
 
void cond_param_set_p_dontcare (struct XCSF *xcsf, const double a)
 
void cond_param_set_spread_min (struct XCSF *xcsf, const double a)
 
void cond_param_set_bits (struct XCSF *xcsf, const int a)
 
int cond_param_set_type_string (struct XCSF *xcsf, const char *a)
 
void cond_param_set_type (struct XCSF *xcsf, const int a)
 

Detailed Description

Interface for classifier conditions.

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

Definition in file condition.c.

Function Documentation

◆ cond_param_defaults()

void cond_param_defaults ( struct XCSF xcsf)

Initialises default condition parameters.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 166 of file condition.c.

References cond_dgp_param_defaults(), cond_gp_param_defaults(), cond_neural_param_defaults(), cond_param_set_eta(), cond_param_set_max(), cond_param_set_min(), cond_param_set_spread_min(), cond_param_set_type(), cond_ternary_param_defaults(), and COND_TYPE_HYPERRECTANGLE_CSR.

Referenced by param_init().

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

◆ cond_param_free()

void cond_param_free ( struct XCSF xcsf)

Frees condition parameters.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 365 of file condition.c.

References layer_args_free(), and tree_args_free().

Referenced by param_free().

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

◆ cond_param_json_export()

char* cond_param_json_export ( const struct XCSF xcsf)

Returns a json formatted string of the condition parameters.

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

Definition at line 232 of file condition.c.

References cond_dgp_param_json_export(), cond_gp_param_json_export(), cond_param_json_export_csr(), cond_ternary_param_json_export(), COND_TYPE_DGP, COND_TYPE_GP, COND_TYPE_HYPERELLIPSOID, COND_TYPE_HYPERRECTANGLE_CSR, COND_TYPE_HYPERRECTANGLE_UBR, COND_TYPE_NEURAL, COND_TYPE_TERNARY, condition_type_as_string(), layer_args_json_export(), RULE_TYPE_DGP, RULE_TYPE_NETWORK, RULE_TYPE_NEURAL, and ArgsCond::type.

Referenced by param_json_export().

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

◆ cond_param_json_export_csr()

static char* cond_param_json_export_csr ( const struct XCSF xcsf)
static

Returns a json formatted string of the center-spread parameters.

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

Definition at line 185 of file condition.c.

References ArgsCond::eta, ArgsCond::max, ArgsCond::min, and ArgsCond::spread_min.

Referenced by cond_param_json_export().

Here is the caller graph for this function:

◆ cond_param_json_import()

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

Sets the condition 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 281 of file condition.c.

References cond_dgp_param_json_import(), cond_gp_param_json_import(), cond_neural_param_json_import(), cond_param_json_import_csr(), cond_ternary_param_json_import(), COND_TYPE_DGP, COND_TYPE_GP, COND_TYPE_HYPERELLIPSOID, COND_TYPE_HYPERRECTANGLE_CSR, COND_TYPE_HYPERRECTANGLE_UBR, COND_TYPE_NEURAL, COND_TYPE_TERNARY, RULE_TYPE_DGP, RULE_TYPE_NETWORK, and RULE_TYPE_NEURAL.

Referenced by param_json_import_condition().

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

◆ cond_param_json_import_csr()

static char* cond_param_json_import_csr ( struct XCSF xcsf,
cJSON *  json 
)
static

Sets the center-spread 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 205 of file condition.c.

References cond_param_set_eta(), cond_param_set_max(), cond_param_set_min(), and cond_param_set_spread_min().

Referenced by cond_param_json_import().

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

◆ cond_param_load()

size_t cond_param_load ( struct XCSF xcsf,
FILE *  fp 
)

Loads condition parameters.

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

Definition at line 343 of file condition.c.

References ArgsCond::bits, ArgsCond::dargs, ArgsCond::eta, graph_args_load(), ArgsCond::largs, layer_args_load(), ArgsCond::max, ArgsCond::min, ArgsCond::p_dontcare, ArgsCond::spread_min, ArgsCond::targs, tree_args_load(), and ArgsCond::type.

Referenced by param_load().

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

◆ cond_param_save()

size_t cond_param_save ( const struct XCSF xcsf,
FILE *  fp 
)

Saves condition parameters.

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

Definition at line 319 of file condition.c.

References ArgsCond::bits, ArgsCond::dargs, ArgsCond::eta, graph_args_save(), ArgsCond::largs, layer_args_save(), ArgsCond::max, ArgsCond::min, ArgsCond::p_dontcare, ArgsCond::spread_min, ArgsCond::targs, tree_args_save(), and ArgsCond::type.

Referenced by param_save().

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

◆ cond_param_set_bits()

void cond_param_set_bits ( struct XCSF xcsf,
const int  a 
)

Definition at line 429 of file condition.c.

Referenced by cond_ternary_param_defaults(), and cond_ternary_param_json_import().

Here is the caller graph for this function:

◆ cond_param_set_eta()

void cond_param_set_eta ( struct XCSF xcsf,
const double  a 
)

Definition at line 378 of file condition.c.

Referenced by cond_param_defaults(), and cond_param_json_import_csr().

Here is the caller graph for this function:

◆ cond_param_set_max()

void cond_param_set_max ( struct XCSF xcsf,
const double  a 
)

Definition at line 398 of file condition.c.

Referenced by cond_param_defaults(), and cond_param_json_import_csr().

Here is the caller graph for this function:

◆ cond_param_set_min()

void cond_param_set_min ( struct XCSF xcsf,
const double  a 
)

Definition at line 392 of file condition.c.

Referenced by cond_param_defaults(), and cond_param_json_import_csr().

Here is the caller graph for this function:

◆ cond_param_set_p_dontcare()

void cond_param_set_p_dontcare ( struct XCSF xcsf,
const double  a 
)

Definition at line 404 of file condition.c.

Referenced by cond_ternary_param_defaults(), and cond_ternary_param_json_import().

Here is the caller graph for this function:

◆ cond_param_set_spread_min()

void cond_param_set_spread_min ( struct XCSF xcsf,
const double  a 
)

Definition at line 418 of file condition.c.

Referenced by cond_param_defaults(), and cond_param_json_import_csr().

Here is the caller graph for this function:

◆ cond_param_set_type()

void cond_param_set_type ( struct XCSF xcsf,
const int  a 
)

Definition at line 450 of file condition.c.

Referenced by cond_param_defaults().

Here is the caller graph for this function:

◆ cond_param_set_type_string()

int cond_param_set_type_string ( struct XCSF xcsf,
const char *  a 
)

Definition at line 440 of file condition.c.

References COND_TYPE_INVALID, condition_type_as_int(), and ArgsCond::type.

Referenced by param_json_import_condition().

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

◆ condition_set()

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

Sets a classifier's condition functions to the implementations.

Parameters
[in]xcsfThe XCSF data structure.
[in]cThe classifier to set.

Definition at line 41 of file condition.c.

References Cl::act_vptr, cond_dgp_vtbl, cond_dummy_vtbl, cond_ellipsoid_vtbl, cond_gp_vtbl, cond_neural_vtbl, cond_rectangle_vtbl, cond_ternary_vtbl, COND_TYPE_DGP, COND_TYPE_DUMMY, COND_TYPE_GP, COND_TYPE_HYPERELLIPSOID, COND_TYPE_HYPERRECTANGLE_CSR, COND_TYPE_HYPERRECTANGLE_UBR, COND_TYPE_NEURAL, COND_TYPE_TERNARY, Cl::cond_vptr, rule_dgp_act_vtbl, rule_dgp_cond_vtbl, rule_neural_act_vtbl, rule_neural_cond_vtbl, RULE_TYPE_DGP, and RULE_TYPE_NEURAL.

Referenced by cl_load(), and cl_rand().

Here is the caller graph for this function:

◆ condition_type_as_int()

int condition_type_as_int ( const char *  type)

Returns the integer representation of a condition type given a name.

Parameters
[in]typeString representation of a condition type.
Returns
Integer representing the condition type.

Definition at line 123 of file condition.c.

References COND_STRING_DGP, COND_STRING_DUMMY, COND_STRING_GP, COND_STRING_HYPERELLIPSOID, COND_STRING_HYPERRECTANGLE_CSR, COND_STRING_HYPERRECTANGLE_UBR, COND_STRING_NEURAL, COND_STRING_RULE_DGP, COND_STRING_RULE_NETWORK, COND_STRING_RULE_NEURAL, COND_STRING_TERNARY, COND_TYPE_DGP, COND_TYPE_DUMMY, COND_TYPE_GP, COND_TYPE_HYPERELLIPSOID, COND_TYPE_HYPERRECTANGLE_CSR, COND_TYPE_HYPERRECTANGLE_UBR, COND_TYPE_INVALID, COND_TYPE_NEURAL, COND_TYPE_TERNARY, RULE_TYPE_DGP, RULE_TYPE_NETWORK, and RULE_TYPE_NEURAL.

Referenced by cond_json_import(), and cond_param_set_type_string().

Here is the caller graph for this function:

◆ condition_type_as_string()

const char* condition_type_as_string ( const int  type)

Returns a string representation of a condition type from an integer.

Parameters
[in]typeInteger representation of a condition type.
Returns
String representing the name of the condition type.

Definition at line 86 of file condition.c.

References COND_STRING_DGP, COND_STRING_DUMMY, COND_STRING_GP, COND_STRING_HYPERELLIPSOID, COND_STRING_HYPERRECTANGLE_CSR, COND_STRING_HYPERRECTANGLE_UBR, COND_STRING_NEURAL, COND_STRING_RULE_DGP, COND_STRING_RULE_NETWORK, COND_STRING_RULE_NEURAL, COND_STRING_TERNARY, COND_TYPE_DGP, COND_TYPE_DUMMY, COND_TYPE_GP, COND_TYPE_HYPERELLIPSOID, COND_TYPE_HYPERRECTANGLE_CSR, COND_TYPE_HYPERRECTANGLE_UBR, COND_TYPE_NEURAL, COND_TYPE_TERNARY, RULE_TYPE_DGP, RULE_TYPE_NETWORK, and RULE_TYPE_NEURAL.

Referenced by cond_json_import(), and cond_param_json_export().

Here is the caller graph for this function: