![]() |
Rivet
3.1.0
|
A genetic algorithm functional minimizer. More...
#include <MendelMin.hh>
Public Types | |
using | Params = std::valarray< double > |
Typedef for a valaray of parameters to the function to be minimised. | |
using | FuncT = std::function< double(const Params &, const Params &)> |
Typedef for the function to be minimised. | |
using | FuncNoFixedT = std::function< double(const Params &)> |
Typedef for the function to be minimised. | |
Public Member Functions | |
MendelMin (const FuncT &fin, unsigned int ndim, const Params &fixpar, unsigned int npop=20, unsigned int ngen=20, double margin=0.1) | |
MendelMin (const FuncNoFixedT &fin, unsigned int ndim, unsigned int npop=20, unsigned int ngen=20, double margin=0.1) | |
void | guess (const Params &p) |
double | evolve (unsigned int NGen) |
Params | fittest () const |
Return the fittest parameter point found. | |
double | fit () const |
Return the fittest value found. | |
double | rnd () const |
Simple wrapper around the random number generator. | |
Params | rndParams () const |
Return a random parameter point in the unit hypercube. | |
void | limit01 (Params &p) const |
Limit a parameter point to inside the unit hypercube. | |
void | move (Params &bad, const Params &better) const |
double | f (const Params &p) const |
Simple wrapper around the function to be minimised. | |
std::pair< double, double > | minmax () |
Public Attributes | |
bool | showTrace |
Set true to get a verbose record of the evolution. | |
A genetic algorithm functional minimizer.
MendelMin implements a home brewed genetic algorithm for finding the minimum of a function defined on a unit hypercube returning a non-negative real number (eg. a Chi-squared value).
|
inline |
Constructor with fixed parameters
Mandatory arguments: the function, fin, to be minimised; the dimension, ndim, of the unit hypercube for which fin is defined; a set of fixed parameters not to be optimised.
Optional arguments are: the number, npop, of individuals in the population; and margin which determines how much randomness is involved when an individual is evolved twowards the fittest individual.
|
inline |
Constructor without fixed parameters
Mandatory arguments: the function, fin, to be minimised; the dimension, ndim, of the unit hypercube for which fin is defined.
Optional arguments are: the number, npop, of individuals in the population; and margin which determines how much randomness is involved when an individual is evolved twowards the fittest individual.
|
inline |
|
inline |
Supply a best guess for the fittest parameter point to help things along.
References limit01().
|
inline |
Calculate the fitness values of all individuals and put the fittest one first.
References f(), Rivet::max(), Rivet::min(), and rndParams().
Referenced by evolve().
Move a bad parameter point towards a better one. The new point is picked randomly within the generalized hypercube where bad and better are at diagonally opposite corners, enlarged by a fraction _margin.
References limit01(), and rndParams().
Referenced by evolve().