rivet is hosted by Hepforge, IPPP Durham
Rivet 4.0.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, 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]

Rivet::MendelMin::MendelMin ( const FuncT fin,
unsigned int  ndim,
const Params fixpar,
unsigned int  npop = 20,
double  margin = 0.1 
)
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.

◆ MendelMin() [2/2]

Rivet::MendelMin::MendelMin ( const FuncNoFixedT fin,
unsigned int  ndim,
unsigned int  npop = 20,
unsigned int  ngen = 20,
double  margin = 0.1 
)
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.

Member Function Documentation

◆ evolve()

double Rivet::MendelMin::evolve ( unsigned int  nGen)
inline

Evolve the population a given number of generations and return the best fit value.

References Rivet::minmax().

◆ guess()

void Rivet::MendelMin::guess ( const Params p)
inline

Supply a best guess for the fittest parameter point to help things along.

◆ minmax()

std::pair< double, double > Rivet::MendelMin::minmax ( )
inline

Calculate the fitness values of all individuals and put the fittest one first.

Returns
the best and worst fitness values.

◆ move()

void Rivet::MendelMin::move ( Params bad,
const Params better 
) const
inline

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.


The documentation for this class was generated from the following file:
  • /Users/chrisg/software/rivet/include/Rivet/Tools/MendelMin.hh