XCSF  1.4.7
XCSF learning classifier system
utils.c File Reference

Utility functions for random number handling, etc. More...

#include "utils.h"
#include <limits.h>
#include <stdbool.h>
#include <time.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Functions

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...
 
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...
 
double rand_normal (const double mu, const double sigma)
 Returns a random Gaussian with specified mean and standard deviation. More...
 
void utils_json_parse_check (const cJSON *json)
 Checks whether JSON parsed correctly. More...
 

Detailed Description

Utility functions for random number handling, etc.

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

Definition in file utils.c.

Function Documentation

◆ rand_init()

void rand_init ( void  )

Initialises the pseudo-random number generator.

Definition at line 34 of file utils.c.

Referenced by param_set_random_state().

Here is the caller graph for this function:

◆ rand_init_seed()

void rand_init_seed ( const uint32_t  seed)

Initialises the pseudo-random number generator with a fixed seed.

Parameters
[in]seedRandom number seed.

Definition at line 50 of file utils.c.

Referenced by param_set_random_state().

Here is the caller graph for this function:

◆ rand_normal()

double rand_normal ( const double  mu,
const double  sigma 
)

Returns a random Gaussian with specified mean and standard deviation.

Box-Muller transform.

Parameters
[in]muMean.
[in]sigmaStandard deviation.
Returns
A random float.

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().

Here is the caller graph for this function:

◆ rand_uniform()

◆ rand_uniform_int()

int rand_uniform_int ( const int  min,
const int  max 
)

Returns a uniform random integer [min,max] not inclusive of max.

Parameters
[in]minMinimum value.
[in]maxMaximum value (non-inclusive).
Returns
A random integer.

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().

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

◆ utils_json_parse_check()

void utils_json_parse_check ( const cJSON *  json)

Checks whether JSON parsed correctly.

Precondition
cJSON_Parse() called on the cJSON object.
Parameters
[in]jsoncJSON object.

Definition at line 109 of file utils.c.

Referenced by clset_json_insert(), XCS::json_insert_cl(), and param_json_import().

Here is the caller graph for this function: