DFLib  Release 1.0.0
Public Member Functions | Private Attributes | List of all members
DFLib::Util::Minimizer Class Reference

#include <Util_Minimization_Methods.hpp>

Collaboration diagram for DFLib::Util::Minimizer:
Collaboration graph
[legend]

Public Member Functions

 Minimizer (DFLib::Abstract::Group *aGroup)
 
void bracketMinimum (double &a, double &b, double &c, std::vector< double > &X0, std::vector< double > &direction)
 bracket minimum of function More...
 
double brentMinimize (double a, double b, double c, std::vector< double > &X0, std::vector< double > &direction, double &xmin)
 minimize by Brent's method with derivatives given a,b,c scalars that bracket the minimum in given direction from X0, search for minimum using Brent's method Returns function value, sets "xmin" to abscissa at minimum. Almost verbatim port out of Numerical Recipes in C More...
 
double lineSearch (std::vector< double > &X0, std::vector< double > &dir)
 minimize function in given direction perform a line search along the given direction for the minimum value of the function. More...
 
double conjugateGradientMinimize (std::vector< double > &X0, double ftol, int &iter)
 minimize function of vector value by method of conjugate gradients More...
 
int nelderMeadMinimize (std::vector< std::vector< double > > &Simplex)
 minimuze function of vector argument by Nelder-Mead simplex method. More...
 
double simpleF (double &x, std::vector< double > &X0, std::vector< double > &dir)
 Evaluate $F(x0+x*dir)$ where x0 and dir are vectors. More...
 
double simpleFandDeriv (double &x, std::vector< double > &X0, std::vector< double > &dir, double &df)
 

Private Attributes

DFLib::Abstract::GrouptheGroup
 

Constructor & Destructor Documentation

DFLib::Util::Minimizer::Minimizer ( DFLib::Abstract::Group aGroup)
inline

Member Function Documentation

void DFLib::Util::Minimizer::bracketMinimum ( double &  a,
double &  b,
double &  c,
std::vector< double > &  X0,
std::vector< double > &  direction 
)

bracket minimum of function

Given scalars $a,b,c$ and an initial point $X0$ and direction, find new values of $a, b,$ and $c$ such that the minimum value of theGroup's function in the chosen direction is bracketed (i.e. $f(x0+direction*b)<f(x0+direction*a) $ and $f(x0+direction*b) < f(x0+direction*c))$ Nearly verbatim port to C++ from Numerical Recipes in C

Here is the call graph for this function:

Here is the caller graph for this function:

double DFLib::Util::Minimizer::brentMinimize ( double  a,
double  b,
double  c,
std::vector< double > &  X0,
std::vector< double > &  direction,
double &  xmin 
)

minimize by Brent's method with derivatives given a,b,c scalars that bracket the minimum in given direction from X0, search for minimum using Brent's method Returns function value, sets "xmin" to abscissa at minimum. Almost verbatim port out of Numerical Recipes in C

Here is the call graph for this function:

Here is the caller graph for this function:

double DFLib::Util::Minimizer::conjugateGradientMinimize ( std::vector< double > &  X0,
double  ftol,
int &  iter 
)

minimize function of vector value by method of conjugate gradients

Parameters
X0on input starting point, on exit solution.
ftolconvergence tolerance on function.
iterreturned number of iterations taken
Returns
value of function at minimum.

Here is the call graph for this function:

Here is the caller graph for this function:

double DFLib::Util::Minimizer::lineSearch ( std::vector< double > &  X0,
std::vector< double > &  dir 
)

minimize function in given direction perform a line search along the given direction for the minimum value of the function.

Parameters
X0input: starting point output: minimum point
dirinput: direction to search output: actual displacement
Returns
function value at minimum. Nearly verbatim port out of Numerical Recipes in C

Here is the call graph for this function:

Here is the caller graph for this function:

int DFLib::Util::Minimizer::nelderMeadMinimize ( std::vector< std::vector< double > > &  Simplex)

minimuze function of vector argument by Nelder-Mead simplex method.

Parameters
Simplexvector of vector of points representing simplex vertices
Returns
index into modified simplex of vertex with lowest function value

The Nelder-Mead simplex method is a minimization method in which a "simplex" is morphed through the landscape of the function and tends downhill. In 2-D the simplex is a triangle, in 3-D a tetrahedron, and in more dimensions it is a generalization of such a shape. In $N$ dimensions, the simplex has $N+1$ vertices. The method keeps track of the best, worst, and "second worst" fucntion values at the vertices and at each step attempts to modify the simplex to make the collection better:

Centroid point: the centroid of the side opposite the worst point.

Reflected point: The reflection of the worst point through the centroid.

Expanded point: a point extrapolated along the line from the centroid to the reflected point at twice the distance.

Contracted point: a point halfway between the centroid and the worst point.

Reduced simplex: the simplex shrunk by half along all sides, leaving the best point unmodified.

The method improves the simplex by the following algorithm:

if the reflected point is the best so far, try the expanded point If the expanded point is the best so far, replace the worst point with it. Otherwise replace the worst point with the reflected point.

If the reflected point is not the best so far, but is better than the second-worst, replace the worst point with it.

If we haven't replaed the worst point yet, check the contracted point. If it is better than the second-worst point, replace the worst point with it.

If nothing has worked so far, reduce the size of the simplex by shrinking along all sides towards the current best point.

The method stops when we have either exceeded the maximum number of function evaluations (here hard-coded to 5000) or the spread of values between best and worst has been reduced to a sufficiently small fraction of the average of best and worst. The stopping criterion is (abs(diff)/average)<sqrt(machine_epsilon)

Here is the call graph for this function:

Here is the caller graph for this function:

double DFLib::Util::Minimizer::simpleF ( double &  x,
std::vector< double > &  X0,
std::vector< double > &  dir 
)

Evaluate $F(x0+x*dir)$ where x0 and dir are vectors.

F is the group's function "computeFunctionValue"

Returns
function value at $X0+x*dir$

Here is the call graph for this function:

Here is the caller graph for this function:

double DFLib::Util::Minimizer::simpleFandDeriv ( double &  x,
std::vector< double > &  X0,
std::vector< double > &  dir,
double &  df 
)

Evaluate F(x0+x*dir) and its directional derivative where x0 and dir are vectors. The directional derivative is the inner product of the gradient and the direction: $df = dir\cdot\nabla f$.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

DFLib::Abstract::Group* DFLib::Util::Minimizer::theGroup
private

The documentation for this class was generated from the following files: