Rivet API documentation
![]() |
Rivet 4.1.3
|
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, 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. | |
Detailed Description
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).
Constructor & Destructor Documentation
◆ MendelMin() [1/2]
|
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.
References showTrace.
Referenced by MendelMin().
◆ MendelMin() [2/2]
|
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.
References MendelMin().
Member Function Documentation
◆ evolve()
|
inline |
Evolve the population a given number of generations and return the best fit value.
References Rivet::minmax(), move(), rnd(), and showTrace.
◆ guess()
|
inline |
Supply a best guess for the fittest parameter point to help things along.
References f(), limit01(), and Rivet::Kin::p().
◆ minmax()
|
inline |
Calculate the fitness values of all individuals and put the fittest one first.
- Returns
- the best and worst fitness values.
References f(), and rndParams().
◆ move()
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().
The documentation for this class was generated from the following file:
- /builds/hepcedar/rivet/include/Rivet/Tools/MendelMin.hh
Generated on for Rivet by
