XCSF
1.4.7
XCSF learning classifier system
|
Utility functions for random number handling, etc. More...
#include "../lib/cJSON/cJSON.h"
#include "../lib/dSFMT/dSFMT.h"
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
Functions | |
double | rand_normal (const double mu, const double sigma) |
Returns a random Gaussian with specified mean and standard deviation. More... | |
double | rand_uniform (const double min, const double max) |
Returns a uniform random float [min,max]. More... | |
int | rand_uniform_int (const int min, const int max) |
Returns a uniform random integer [min,max] not inclusive of max. More... | |
void | rand_init (void) |
Initialises the pseudo-random number generator. More... | |
void | rand_init_seed (const uint32_t seed) |
Initialises the pseudo-random number generator with a fixed seed. More... | |
void | utils_json_parse_check (const cJSON *json) |
Checks whether JSON parsed correctly. More... | |
static double | clamp (const double a, const double min, const double max) |
Returns a float clamped within the specified range. More... | |
static int | clamp_int (const int a, const int min, const int max) |
Returns an integer clamped within the specified range. More... | |
static int | argmax (const double *X, const int N) |
Returns the index of the largest element in vector X. More... | |
static void | float_to_binary (const double f, char *binary, const int bits) |
Generates a binary string from a float. More... | |
static void | catch_error (const char *ret) |
Catches parameter value errors. More... | |
static bool | check_array_eq (const double *arr1, const double *arr2, int size) |
Checks whether two double arrays are approximately equal. More... | |
static bool | check_array_eq_int (const int *arr1, const int *arr2, int size) |
Checks whether two integer arrays are equal. More... | |
Utility functions for random number handling, etc.
Definition in file utils.h.
|
static |
Returns the index of the largest element in vector X.
First occurrence is selected in the case of a tie.
[in] | X | Vector with N elements. |
[in] | N | The number of elements in vector X. |
Definition at line 86 of file utils.h.
Referenced by act_neural_compute(), loss_onehot(), and pa_best_val().
|
static |
Catches parameter value errors.
[in] | ret | String return type from JSON import. |
Definition at line 134 of file utils.h.
Referenced by ea_param_json_import(), param_json_import_cl_general(), param_json_import_general(), param_json_import_multi(), and param_json_import_subsump().
|
static |
|
static |
|
static |
Returns a float clamped within the specified range.
[in] | a | The value to be clamped. |
[in] | min | Minimum value. |
[in] | max | Maximum value. |
Definition at line 60 of file utils.h.
Referenced by cond_ellipsoid_mutate(), cond_rectangle_mutate(), layer_mutate_eta(), layer_mutate_neurons(), layer_mutate_weights(), layer_weight_clamp(), neural_activate_array(), neural_layer_convolutional_mutate_filter(), node_activate(), pred_nlms_mutate(), sam_adapt(), and tree_eval().
|
static |
Returns an integer clamped within the specified range.
[in] | a | The value to be clamped. |
[in] | min | Minimum value. |
[in] | max | Maximum value. |
Definition at line 73 of file utils.h.
Referenced by rule_dgp_act_compute(), and rule_neural_act_compute().
|
static |
Generates a binary string from a float.
[in] | f | The float to binarise. |
[out] | binary | The converted binary string. |
[in] | bits | The number of bits to use for binarising. |
Definition at line 110 of file utils.h.
Referenced by cond_ternary_cover(), and cond_ternary_match().
void rand_init | ( | void | ) |
Initialises the pseudo-random number generator.
Definition at line 34 of file utils.c.
Referenced by param_set_random_state().
void rand_init_seed | ( | const uint32_t | seed | ) |
Initialises the pseudo-random number generator with a fixed seed.
[in] | seed | Random number seed. |
Definition at line 50 of file utils.c.
Referenced by param_set_random_state().
double rand_normal | ( | const double | mu, |
const double | sigma | ||
) |
Returns a random Gaussian with specified mean and standard deviation.
Box-Muller transform.
[in] | mu | Mean. |
[in] | sigma | Standard deviation. |
Definition at line 87 of file utils.c.
Referenced by cond_ellipsoid_mutate(), cond_rectangle_mutate(), layer_add_neurons(), layer_ensure_input_represention(), layer_mutate_connectivity(), layer_mutate_eta(), layer_mutate_neurons(), layer_mutate_weights(), layer_weight_rand(), neural_layer_connected_init(), neural_layer_connected_resize(), neural_layer_convolutional_add_filters(), neural_layer_convolutional_init(), neural_layer_convolutional_mutate_filter(), neural_layer_convolutional_resize(), neural_layer_noise_forward(), pred_nlms_mutate(), and sam_adapt().
double rand_uniform | ( | const double | min, |
const double | max | ||
) |
Returns a uniform random float [min,max].
[in] | min | Minimum value. |
[in] | max | Maximum value. |
Definition at line 62 of file utils.c.
Referenced by act_integer_mutate(), clset_pset_roulette(), cond_ellipsoid_cover(), cond_ellipsoid_crossover(), cond_ellipsoid_init(), cond_gp_crossover(), cond_rectangle_cover(), cond_rectangle_crossover(), cond_rectangle_init(), cond_ternary_cover(), cond_ternary_crossover(), cond_ternary_mutate(), cond_ternary_rand(), ea_select_rw(), ea_select_tournament(), env_mux_get_state(), graph_mutate_connectivity(), graph_mutate_functions(), graph_rand(), layer_add_neurons(), layer_init_eta(), layer_mutate_connectivity(), layer_mutate_functions(), layer_mutate_neurons(), neural_layer_convolutional_mutate_filter(), neural_layer_dropout_forward(), neural_layer_noise_forward(), pred_nlms_init(), rand_uniform_int(), random_connection(), sam_adapt(), sam_init(), tree_args_init_constants(), tree_grow(), tree_mutate(), and xcs_rl_decision().
int rand_uniform_int | ( | const int | min, |
const int | max | ||
) |
Returns a uniform random integer [min,max] not inclusive of max.
[in] | min | Minimum value. |
[in] | max | Maximum value (non-inclusive). |
Definition at line 74 of file utils.c.
References rand_uniform().
Referenced by act_integer_init(), act_integer_mutate(), ea_subsume(), env_maze_reset(), graph_mutate_functions(), graph_rand(), layer_ensure_input_represention(), layer_mutate_functions(), pa_best_action(), pa_rand_action(), random_connection(), sam_adapt(), sam_init(), tree_crossover(), tree_grow(), tree_mutate(), and xcs_supervised_sample().
void utils_json_parse_check | ( | const cJSON * | json | ) |
Checks whether JSON parsed correctly.
[in] | json | cJSON object. |
Definition at line 109 of file utils.c.
Referenced by clset_json_insert(), XCS::json_insert_cl(), and param_json_import().