libfgen
0.1.15
Library for optimization using a genetic algorithm or particle swarm optimization
|
Data Structures | |
struct | FpsoIndividual |
struct | FpsoPopulation |
Defines | |
#define | FPSO_DEFAULT_OMEGA 0.7298 |
#define | FPSO_DEFAULT_PHI1 1.49618 |
#define | FPSO_DEFAULT_PHI2 1.49618 |
#define | FPSO_TOPOLOGY_GBEST 0 |
#define | FPSO_TOPOLOGY_LBEST 1 |
#define | FPSO_BOUND_VELOCITY_ELEMENT 1 |
#define | FPSO_BOUND_POSITION_ELEMENT 2 |
#define | FPSO_BOUND_NOTHING 0 |
#define | FPSO_BOUND_VELOCITY 1 |
#define | FPSO_BOUND_POSITION 2 |
#define | FPSO_BOUND_POSITION_AND_VELOCITY 3 |
Typedefs | |
typedef void(* | FpsoGenerationCallbackFunc )(FpsoPopulation *pop, int generation) |
typedef double(* | FpsoCalculateErrorFunc )(const FpsoPopulation *pop, const double *parameters) |
Functions | |
FGEN_API FpsoPopulation * | fpso_create (int population_size, int nu_parameters, FpsoGenerationCallbackFunc fpso_generation_callback_func, FpsoCalculateErrorFunc fpso_calculate_error_func) |
FGEN_API void | fpso_set_parameters (FpsoPopulation *pop, int topology, int bounding_strategy, double omega, double phi1, double phi2) |
FGEN_API void | fpso_run (FpsoPopulation *pop, int max_generation) |
FGEN_API void | fpso_destroy (FpsoPopulation *pop) |
FGEN_API void | fpso_signal_stop (FpsoPopulation *pop) |
FGEN_API void | fpso_set_parameter_bounds (FpsoPopulation *pso, int parameter_index, double min_bound, double max_bound) |
FGEN_API void | fpso_set_topology (FpsoPopulation *pso, int type) |
FGEN_API void | fpso_set_bounding_strategy (FpsoPopulation *pso, int type) |
FGEN_API void | fpso_set_user_data (FpsoPopulation *pop, void *user_data) |
FGEN_API void | fpso_bound_position (const FpsoPopulation *pop, const double *source, double *dest) |
FGEN_API double * | fpso_get_best_known_position (const FpsoPopulation *pop) |
FGEN_API double | fpso_get_best_known_error (const FpsoPopulation *pop) |
FGEN_API FgenRNG * | fpso_get_rng (const FpsoPopulation *pop) |
FGEN_API FpsoPopulation* fpso_create | ( | int | population_size, |
int | nu_parameters, | ||
FpsoGenerationCallbackFunc | fpso_generation_callback_func, | ||
FpsoCalculateErrorFunc | fpso_calculate_error_func | ||
) |
Create a PSO population.
population_size | The size of the swarm population. |
nu_parameters | The number of parameters per individual. |
fpso_generation_callback_func | The generation callback function that is called after every generation of the algorithm. |
fpso_calculate_error_func | The error evaluation function that calculates the function value or error of an individual. |
FGEN_API void fpso_set_parameters | ( | FpsoPopulation * | pop, |
int | topology, | ||
int | bounding_strategy, | ||
double | omega, | ||
double | phi1, | ||
double | phi2 | ||
) |
Set the parameters for an fpso population.
pop | The population. |
topology | The swarm topology. One of FPSO_TOPOLOGY_GBEST and FPSO_TOPOLOGY_LBEST. |
bounding_strategy | The bounding strategy for parameters used in the algorithm. One of the following:
|
omega | The omega value used in the PSO. A default value is defined as FPSO_DEFAULT_OMEGA. |
phi1 | The phi1 value used in the PSO. A default value is defined as FPSO_DEFAULT_PHI1. |
phi2 | the phi2 value used in the PSO. A default value is defined as FPSO_DEFAULT_PHI2. |
FGEN_API void fpso_run | ( | FpsoPopulation * | pop, |
int | max_generation | ||
) |
Run the particle swarm optimization algorithm.
pop | The PSO population. |
max_generation | The number of generations to run. The algorithm terminates when this generation is reached. If it is equal to - 1, the algorithm runs indefinitely until fpso_signal_stop() is called. |
FGEN_API void fpso_destroy | ( | FpsoPopulation * | pop | ) |
FGEN_API void fpso_signal_stop | ( | FpsoPopulation * | pop | ) |
FGEN_API void fpso_set_parameter_bounds | ( | FpsoPopulation * | pop, |
int | index, | ||
double | min_bound, | ||
double | max_bound | ||
) |
FGEN_API void fpso_set_topology | ( | FpsoPopulation * | pop, |
int | type | ||
) |
FGEN_API void fpso_set_bounding_strategy | ( | FpsoPopulation * | pop, |
int | type | ||
) |
Set the bounding strategy used in the algorithm.
pop | The PSO population. |
type | The bounding strategy for parameters used in the algorithm. Irrespective of the value, the FpsoCalculateErrorFunc will always received bounded parameters. The value must be one of the following:
|
FGEN_API void fpso_set_user_data | ( | FpsoPopulation * | pop, |
void * | user_data | ||
) |
FGEN_API void fpso_bound_position | ( | const FpsoPopulation * | pop, |
const double * | src, | ||
double * | dest | ||
) |
FGEN_API double* fpso_get_best_known_position | ( | const FpsoPopulation * | pop | ) |
FGEN_API double fpso_get_best_known_error | ( | const FpsoPopulation * | pop | ) |
FGEN_API FgenRNG* fpso_get_rng | ( | const FpsoPopulation * | pop | ) |