XCSF  1.4.7
XCSF learning classifier system
param.c File Reference

Functions for setting and printing parameters. More...

#include "param.h"
#include "action.h"
#include "condition.h"
#include "ea.h"
#include "prediction.h"
#include "utils.h"
Include dependency graph for param.c:

Go to the source code of this file.

Macros

#define MAX_LEN   512
 Maximum length of a population filename. More...
 

Functions

void param_init (struct XCSF *xcsf, const int x_dim, const int y_dim, const int n_actions)
 Initialises default XCSF parameters. More...
 
void param_free (struct XCSF *xcsf)
 
char * param_json_export (const struct XCSF *xcsf)
 Returns a json formatted string representation of the parameters. More...
 
static bool param_json_import_general (struct XCSF *xcsf, const cJSON *json)
 Sets the general parameters from a cJSON object. More...
 
static bool param_json_import_multi (struct XCSF *xcsf, const cJSON *json)
 Sets the multi-step parameters from a cJSON object. More...
 
static bool param_json_import_subsump (struct XCSF *xcsf, const cJSON *json)
 Sets the subsumption parameters from a cJSON object. More...
 
static bool param_json_import_cl_general (struct XCSF *xcsf, const cJSON *json)
 Sets the general classifier parameters from a cJSON object. More...
 
static void param_json_import_action (struct XCSF *xcsf, cJSON *json)
 Sets the action parameters from a json formatted string. More...
 
static void param_json_import_condition (struct XCSF *xcsf, cJSON *json)
 Sets the condition parameters from a json formatted string. More...
 
static void param_json_import_prediction (struct XCSF *xcsf, cJSON *json)
 Sets the prediction parameters from a json formatted string. More...
 
void param_json_import (struct XCSF *xcsf, const char *json_str)
 Sets the parameters from a json formatted string. More...
 
void param_print (const struct XCSF *xcsf)
 Prints all XCSF parameters. More...
 
size_t param_save (const struct XCSF *xcsf, FILE *fp)
 Writes the XCSF data structure to a file. More...
 
size_t param_load (struct XCSF *xcsf, FILE *fp)
 Reads the XCSF data structure from a file. More...
 
const char * param_set_omp_num_threads (struct XCSF *xcsf, const int a)
 Sets the number of OMP threads. More...
 
const char * param_set_random_state (struct XCSF *xcsf, const int a)
 
const char * param_set_population_file (struct XCSF *xcsf, const char *a)
 
const char * param_set_pop_init (struct XCSF *xcsf, const bool a)
 
const char * param_set_max_trials (struct XCSF *xcsf, const int a)
 
const char * param_set_perf_trials (struct XCSF *xcsf, const int a)
 
const char * param_set_pop_size (struct XCSF *xcsf, const int a)
 
int param_set_loss_func_string (struct XCSF *xcsf, const char *a)
 
void param_set_loss_func (struct XCSF *xcsf, const int a)
 
const char * param_set_stateful (struct XCSF *xcsf, const bool a)
 
const char * param_set_compaction (struct XCSF *xcsf, const bool a)
 
const char * param_set_huber_delta (struct XCSF *xcsf, const double a)
 
const char * param_set_gamma (struct XCSF *xcsf, const double a)
 
const char * param_set_teletransportation (struct XCSF *xcsf, const int a)
 
const char * param_set_p_explore (struct XCSF *xcsf, const double a)
 
const char * param_set_alpha (struct XCSF *xcsf, const double a)
 
const char * param_set_beta (struct XCSF *xcsf, const double a)
 
const char * param_set_delta (struct XCSF *xcsf, const double a)
 
const char * param_set_e0 (struct XCSF *xcsf, const double a)
 
const char * param_set_init_error (struct XCSF *xcsf, const double a)
 
const char * param_set_init_fitness (struct XCSF *xcsf, const double a)
 
const char * param_set_nu (struct XCSF *xcsf, const double a)
 
const char * param_set_theta_del (struct XCSF *xcsf, const int a)
 
const char * param_set_m_probation (struct XCSF *xcsf, const int a)
 
const char * param_set_set_subsumption (struct XCSF *xcsf, const bool a)
 
const char * param_set_theta_sub (struct XCSF *xcsf, const int a)
 
const char * param_set_x_dim (struct XCSF *xcsf, const int a)
 
const char * param_set_explore (struct XCSF *xcsf, const bool a)
 
const char * param_set_y_dim (struct XCSF *xcsf, const int a)
 
const char * param_set_n_actions (struct XCSF *xcsf, const int a)
 

Detailed Description

Functions for setting and printing parameters.

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

Definition in file param.c.

Macro Definition Documentation

◆ MAX_LEN

#define MAX_LEN   512

Maximum length of a population filename.

Definition at line 35 of file param.c.

Function Documentation

◆ param_free()

void param_free ( struct XCSF xcsf)

Definition at line 93 of file param.c.

References action_param_free(), cond_param_free(), and pred_param_free().

Referenced by main().

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

◆ param_init()

void param_init ( struct XCSF xcsf,
const int  x_dim,
const int  y_dim,
const int  n_actions 
)

Initialises default XCSF parameters.

Parameters
[in]xcsfThe XCSF data structure.
[in]x_dimThe dimensionality of the input variables.
[in]y_dimThe dimensionality of the prediction variables.
[in]n_actionsThe total number of possible actions.

Definition at line 45 of file param.c.

References action_param_defaults(), cond_param_defaults(), ea_param_defaults(), LOSS_MAE, param_set_alpha(), param_set_beta(), param_set_compaction(), param_set_delta(), param_set_e0(), param_set_gamma(), param_set_huber_delta(), param_set_init_error(), param_set_init_fitness(), param_set_loss_func(), param_set_m_probation(), param_set_max_trials(), param_set_n_actions(), param_set_nu(), param_set_omp_num_threads(), param_set_p_explore(), param_set_perf_trials(), param_set_pop_init(), param_set_pop_size(), param_set_random_state(), param_set_set_subsumption(), param_set_stateful(), param_set_teletransportation(), param_set_theta_del(), param_set_theta_sub(), param_set_x_dim(), param_set_y_dim(), and pred_param_defaults().

Referenced by env_csv_init(), env_maze_init(), env_mux_init(), and XCS::reset().

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

◆ param_json_export()

char* param_json_export ( const struct XCSF xcsf)

Returns a json formatted string representation of the parameters.

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

Definition at line 113 of file param.c.

References action_param_json_export(), cond_param_json_export(), ea_param_json_export(), LOSS_HUBER, loss_type_as_string(), pred_param_json_export(), RULE_TYPE_DGP, RULE_TYPE_NETWORK, RULE_TYPE_NEURAL, VERSION_BUILD, VERSION_MAJOR, and VERSION_MINOR.

Referenced by XCS::internal_params(), param_print(), and XCS::update_params().

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

◆ param_json_import()

void param_json_import ( struct XCSF xcsf,
const char *  json_str 
)

Sets the parameters from a json formatted string.

Parameters
[in,out]xcsfThe XCSF data structure.
[in]json_strString encoded in json format.

Definition at line 437 of file param.c.

References ea_param_json_import(), param_json_import_action(), param_json_import_cl_general(), param_json_import_condition(), param_json_import_general(), param_json_import_multi(), param_json_import_prediction(), param_json_import_subsump(), and utils_json_parse_check().

Referenced by config_read(), and XCS::set_params().

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

◆ param_json_import_action()

static void param_json_import_action ( struct XCSF xcsf,
cJSON *  json 
)
static

Sets the action parameters from a json formatted string.

Parameters
[in,out]xcsfThe XCSF data structure.
[in]jsoncJSON object.

Definition at line 347 of file param.c.

References ACT_TYPE_INVALID, ACT_TYPE_OPTIONS, action_param_json_import(), and action_param_set_type_string().

Referenced by param_json_import().

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

◆ param_json_import_cl_general()

static bool param_json_import_cl_general ( struct XCSF xcsf,
const cJSON *  json 
)
static

Sets the general classifier parameters from a cJSON object.

Parameters
[in,out]xcsfThe XCSF data structure.
[in]jsoncJSON object.
Returns
Whether a parameter was found.

Definition at line 301 of file param.c.

References catch_error(), param_set_alpha(), param_set_beta(), param_set_compaction(), param_set_delta(), param_set_e0(), param_set_init_error(), param_set_init_fitness(), param_set_m_probation(), param_set_nu(), param_set_stateful(), and param_set_theta_del().

Referenced by param_json_import().

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

◆ param_json_import_condition()

static void param_json_import_condition ( struct XCSF xcsf,
cJSON *  json 
)
static

Sets the condition parameters from a json formatted string.

Parameters
[in,out]xcsfThe XCSF data structure.
[in]jsoncJSON object.

Definition at line 377 of file param.c.

References cond_param_json_import(), cond_param_set_type_string(), COND_TYPE_INVALID, and COND_TYPE_OPTIONS.

Referenced by param_json_import().

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

◆ param_json_import_general()

static bool param_json_import_general ( struct XCSF xcsf,
const cJSON *  json 
)
static

Sets the general parameters from a cJSON object.

Parameters
[in,out]xcsfThe XCSF data structure.
[in]jsoncJSON object.
Returns
Whether a parameter was found.

Definition at line 193 of file param.c.

References catch_error(), LOSS_OPTIONS, PARAM_INVALID, param_set_huber_delta(), param_set_loss_func_string(), param_set_max_trials(), param_set_n_actions(), param_set_omp_num_threads(), param_set_perf_trials(), param_set_pop_init(), param_set_pop_size(), param_set_population_file(), param_set_random_state(), param_set_x_dim(), and param_set_y_dim().

Referenced by param_json_import().

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

◆ param_json_import_multi()

static bool param_json_import_multi ( struct XCSF xcsf,
const cJSON *  json 
)
static

Sets the multi-step parameters from a cJSON object.

Parameters
[in,out]xcsfThe XCSF data structure.
[in]jsoncJSON object.
Returns
Whether a parameter was found.

Definition at line 253 of file param.c.

References catch_error(), param_set_gamma(), param_set_p_explore(), and param_set_teletransportation().

Referenced by param_json_import().

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

◆ param_json_import_prediction()

static void param_json_import_prediction ( struct XCSF xcsf,
cJSON *  json 
)
static

Sets the prediction parameters from a json formatted string.

Parameters
[in,out]xcsfThe XCSF data structure.
[in]jsoncJSON object.

Definition at line 407 of file param.c.

References pred_param_json_import(), pred_param_set_type_string(), PRED_TYPE_INVALID, and PRED_TYPE_OPTIONS.

Referenced by param_json_import().

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

◆ param_json_import_subsump()

static bool param_json_import_subsump ( struct XCSF xcsf,
const cJSON *  json 
)
static

Sets the subsumption parameters from a cJSON object.

Parameters
[in,out]xcsfThe XCSF data structure.
[in]jsoncJSON object.
Returns
Whether a parameter was found.

Definition at line 278 of file param.c.

References catch_error(), param_set_set_subsumption(), and param_set_theta_sub().

Referenced by param_json_import().

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

◆ param_load()

size_t param_load ( struct XCSF xcsf,
FILE *  fp 
)

Reads the XCSF data structure from a file.

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

Definition at line 548 of file param.c.

References action_param_load(), cond_param_load(), ea_param_load(), loss_set_func(), and pred_param_load().

Referenced by xcsf_load().

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

◆ param_print()

void param_print ( const struct XCSF xcsf)

Prints all XCSF parameters.

Parameters
[in]xcsfThe XCSF data structure.

Definition at line 481 of file param.c.

References param_json_export().

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

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

◆ param_save()

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

Writes the XCSF data structure to a file.

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

Definition at line 495 of file param.c.

References action_param_save(), cond_param_save(), ea_param_save(), MAX_LEN, and pred_param_save().

Referenced by xcsf_save().

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

◆ param_set_alpha()

const char* param_set_alpha ( struct XCSF xcsf,
const double  a 
)

Definition at line 764 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_beta()

const char* param_set_beta ( struct XCSF xcsf,
const double  a 
)

Definition at line 774 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_compaction()

const char* param_set_compaction ( struct XCSF xcsf,
const bool  a 
)

Definition at line 717 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_delta()

const char* param_set_delta ( struct XCSF xcsf,
const double  a 
)

Definition at line 784 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_e0()

const char* param_set_e0 ( struct XCSF xcsf,
const double  a 
)

Definition at line 794 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_explore()

const char* param_set_explore ( struct XCSF xcsf,
const bool  a 
)

Definition at line 881 of file param.c.

Referenced by XCS::decision(), xcs_rl_fit(), xcs_rl_trial(), xcs_supervised_fit(), xcs_supervised_predict(), xcs_supervised_score(), and xcs_supervised_score_n().

Here is the caller graph for this function:

◆ param_set_gamma()

const char* param_set_gamma ( struct XCSF xcsf,
const double  a 
)

Definition at line 734 of file param.c.

Referenced by param_init(), and param_json_import_multi().

Here is the caller graph for this function:

◆ param_set_huber_delta()

const char* param_set_huber_delta ( struct XCSF xcsf,
const double  a 
)

Definition at line 724 of file param.c.

Referenced by param_init(), and param_json_import_general().

Here is the caller graph for this function:

◆ param_set_init_error()

const char* param_set_init_error ( struct XCSF xcsf,
const double  a 
)

Definition at line 804 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_init_fitness()

const char* param_set_init_fitness ( struct XCSF xcsf,
const double  a 
)

Definition at line 814 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_loss_func()

void param_set_loss_func ( struct XCSF xcsf,
const int  a 
)

Definition at line 699 of file param.c.

References LOSS_NUM, and loss_set_func().

Referenced by param_init(), and xcsf_ae_to_classifier().

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

◆ param_set_loss_func_string()

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

Definition at line 686 of file param.c.

References LOSS_INVALID, loss_set_func(), loss_type_as_int(), PARAM_FOUND, and PARAM_INVALID.

Referenced by param_json_import_general().

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

◆ param_set_m_probation()

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

Definition at line 844 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_max_trials()

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

Definition at line 656 of file param.c.

Referenced by param_init(), and param_json_import_general().

Here is the caller graph for this function:

◆ param_set_n_actions()

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

Definition at line 898 of file param.c.

Referenced by param_init(), and param_json_import_general().

Here is the caller graph for this function:

◆ param_set_nu()

const char* param_set_nu ( struct XCSF xcsf,
const double  a 
)

Definition at line 824 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_omp_num_threads()

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

Sets the number of OMP threads.

Parameters
[in]xcsfThe XCSF data structure.
[in]aThe number of threads.
Returns
NULL if successful; or an error message.

Definition at line 614 of file param.c.

Referenced by param_init(), and param_json_import_general().

Here is the caller graph for this function:

◆ param_set_p_explore()

const char* param_set_p_explore ( struct XCSF xcsf,
const double  a 
)

Definition at line 754 of file param.c.

Referenced by param_init(), and param_json_import_multi().

Here is the caller graph for this function:

◆ param_set_perf_trials()

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

Definition at line 666 of file param.c.

Referenced by param_init(), and param_json_import_general().

Here is the caller graph for this function:

◆ param_set_pop_init()

const char* param_set_pop_init ( struct XCSF xcsf,
const bool  a 
)

Definition at line 649 of file param.c.

Referenced by param_init(), and param_json_import_general().

Here is the caller graph for this function:

◆ param_set_pop_size()

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

Definition at line 676 of file param.c.

Referenced by param_init(), and param_json_import_general().

Here is the caller graph for this function:

◆ param_set_population_file()

const char* param_set_population_file ( struct XCSF xcsf,
const char *  a 
)

Definition at line 639 of file param.c.

References MAX_LEN.

Referenced by param_json_import_general().

Here is the caller graph for this function:

◆ param_set_random_state()

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

Definition at line 627 of file param.c.

References rand_init(), and rand_init_seed().

Referenced by param_init(), and param_json_import_general().

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

◆ param_set_set_subsumption()

const char* param_set_set_subsumption ( struct XCSF xcsf,
const bool  a 
)

Definition at line 854 of file param.c.

Referenced by param_init(), and param_json_import_subsump().

Here is the caller graph for this function:

◆ param_set_stateful()

const char* param_set_stateful ( struct XCSF xcsf,
const bool  a 
)

Definition at line 710 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_teletransportation()

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

Definition at line 744 of file param.c.

Referenced by param_init(), and param_json_import_multi().

Here is the caller graph for this function:

◆ param_set_theta_del()

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

Definition at line 834 of file param.c.

Referenced by param_init(), and param_json_import_cl_general().

Here is the caller graph for this function:

◆ param_set_theta_sub()

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

Definition at line 861 of file param.c.

Referenced by param_init(), and param_json_import_subsump().

Here is the caller graph for this function:

◆ param_set_x_dim()

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

Definition at line 871 of file param.c.

Referenced by param_init(), and param_json_import_general().

Here is the caller graph for this function:

◆ param_set_y_dim()

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

Definition at line 888 of file param.c.

Referenced by param_init(), param_json_import_general(), and xcsf_ae_to_classifier().

Here is the caller graph for this function: