TooN 2.1
Classes | Functions
Function optimization

Classes and functions to perform function optimization. More...

Classes

struct  LineSearch< Size, Precision, Func >
 Turn a multidimensional function in to a 1D function by specifying a point and direction. More...
struct  ConjugateGradient< Size, Precision >
 This class provides a nonlinear conjugate-gradient optimizer. More...
class  DownhillSimplex< N, Precision >
 This is an implementation of the Downhill Simplex (Nelder & Mead, 1965) algorithm. More...

Functions

template<class Functor , class Precision >
Vector< 2, Precision > brent_line_search (Precision a, Precision x, Precision b, Precision fx, const Functor &func, int maxiterations, Precision tolerance=sqrt(numeric_limits< Precision >::epsilon()), Precision epsilon=numeric_limits< Precision >::epsilon())
template<typename Precision , typename Func >
Matrix< 3, 2, Precision > bracket_minimum_forward (Precision a_val, const Func &func, Precision initial_lambda, Precision zeps)
template<class Functor , class Precision >
Vector< 2, Precision > golden_section_search (Precision a, Precision b, Precision c, Precision fb, const Functor &func, int maxiterations, Precision tol=sqrt(numeric_limits< Precision >::epsilon()))
template<class Functor , class Precision >
Vector< 2, Precision > golden_section_search (Precision a, Precision b, Precision c, const Functor &func, int maxiterations, Precision tol=sqrt(numeric_limits< Precision >::epsilon()))

Detailed Description

Classes and functions to perform function optimization.

One dimensional function optimization

The following functions find the minimum of a 1-D function:

Multidimensional dimensional function optimization

The following classes perform multidimensional function minimization:

The mode of operation is to set up a mutable class, then repeatedly call an iterate function. This allows different sub algorithms (such as termination conditions) to be substituted in if need be.


Function Documentation

Vector<2, Precision> TooN::brent_line_search ( Precision  a,
Precision  x,
Precision  b,
Precision  fx,
const Functor &  func,
int  maxiterations,
Precision  tolerance = sqrt(numeric_limits<Precision>::epsilon()),
Precision  epsilon = numeric_limits<Precision>::epsilon() 
)

brent_line_search performs Brent's golden section/quadratic interpolation search on the functor provided.

The inputs a, x, b must bracket the minimum, and must be in order, so that $ a < x < b $ and $ f(a) > f(x) < f(b) $.

Parameters:
aThe most negative point along the line.
xThe central point.
fxThe value of the function at the central point ( $b$).
bThe most positive point along the line.
funcThe functor to minimize
maxiterationsMaximum number of iterations
toleranceTolerance at which the search should be stopped (defults to sqrt machine precision)
epsilonMinimum bracket width (defaults to machine precision)
Returns:
The minima position is returned as the first element of the vector, and the minimal value as the second element.

References TooN::sqrt().

Referenced by ConjugateGradient< Size, Precision >::find_next_point().

Matrix<3,2,Precision> TooN::Internal::bracket_minimum_forward ( Precision  a_val,
const Func &  func,
Precision  initial_lambda,
Precision  zeps 
)

Bracket a 1D function by searching forward from zero.

The assumption is that a minima exists in $f(x),\ x>0$, and this function searches for a bracket using exponentially growning or shrinking steps.

Parameters:
a_valThe value of the function at zero.
funcFunction to bracket
initial_lambdaInitial stepsize
zepsMinimum bracket size.
Returns:
m[i][0] contains the values of $x$ for the bracket, in increasing order, and m[i][1] contains the corresponding values of $f(x)$. If the bracket drops below the minimum bracket size, all zeros are returned.

References TooN::isnan(), and TooN::Zeros.

Referenced by ConjugateGradient< Size, Precision >::find_next_point().

Vector<2, Precision> TooN::golden_section_search ( Precision  a,
Precision  b,
Precision  c,
Precision  fb,
const Functor &  func,
int  maxiterations,
Precision  tol = sqrt(numeric_limits<Precision>::epsilon()) 
)

golden_section_search performs a golden section search line minimization on the functor provided.

The inputs a, b, c must bracket the minimum, and must be in order, so that $ a < b < c $ and $ f(a) > f(b) < f(c) $.

Parameters:
aThe most negative point along the line.
bThe central point.
fbThe value of the function at the central point ( $b$).
cThe most positive point along the line.
funcThe functor to minimize
maxiterationsMaximum number of iterations
tolTolerance at which the search should be stopped.
Returns:
The minima position is returned as the first element of the vector, and the minimal value as the second element.

References TooN::sqrt().

Referenced by TooN::golden_section_search().

Vector<2, Precision> TooN::golden_section_search ( Precision  a,
Precision  b,
Precision  c,
const Functor &  func,
int  maxiterations,
Precision  tol = sqrt(numeric_limits<Precision>::epsilon()) 
)

golden_section_search performs a golden section search line minimization on the functor provided.

The inputs a, b, c must bracket the minimum, and must be in order, so that $ a < b < c $ and $ f(a) > f(b) < f(c) $.

Parameters:
aThe most negative point along the line.
bThe central point.
cThe most positive point along the line.
funcThe functor to minimize
maxiterationsMaximum number of iterations
tolTolerance at which the search should be stopped.
Returns:
The minima position is returned as the first element of the vector, and the minimal value as the second element.

References TooN::golden_section_search().