Honeycomb  0.1
Component-Model Framework
Public Types | Public Member Functions | List of all members
honey::Minimize< Real > Class Template Reference

Find a local minimum of a 1-dimensional function using "Brent's method" – bisection and inverse quadratic interpolation. More...

#include <Minimize.h>

Public Types

typedef function< Real(Real)> Func
 

Public Member Functions

 Minimize (Real tol=Real_::zeroTol, int levelMax=30, int bracketMax=30)
 
tuple< Real, Realcalc (const Func &func, Real min, Real max, Real init)
 Find the minimum of a function within bounds [min,max] using init as an initial guess. More...
 

Detailed Description

template<class Real>
class honey::Minimize< Real >

Find a local minimum of a 1-dimensional function using "Brent's method" – bisection and inverse quadratic interpolation.

Member Typedef Documentation

template<class Real>
typedef function<Real (Real)> honey::Minimize< Real >::Func

Constructor & Destructor Documentation

template<class Real>
honey::Minimize< Real >::Minimize ( Real  tol = Real_::zeroTol,
int  levelMax = 30,
int  bracketMax = 30 
)
inline
Parameters
tolfind minimum to within tolerance
levelMaxmax number of bisection steps when looking for a bracketed minimum
bracketMaxmax number of bisection steps when looking for the minimum within a bracket

Member Function Documentation

template<class Real >
tuple< Real, Real > honey::Minimize< Real >::calc ( const Func func,
Real  min,
Real  max,
Real  init 
)

Find the minimum of a function within bounds [min,max] using init as an initial guess.

On each subinterval [a,b], the values f0 = f(a), f1 = f((a+b)/2), and f2 = f(b) are examined.

If (f0,f1,f2) is monotonic, then [a,b] is subdivided and processed on [a,(a+b)/2] and [(a+b)/2,b]. The max recursion depth is 'levelMax'.

If (f0,f1,f2) is not monotonic, then two cases arise:

  • If f1 = min(f0,f1,f2), then (f0,f1,f2) brackets a minimum. The minimum within the bracket is found using a form of bisection called "parabolic interpolation" with max depth 'bracketMax'.
  • If f1 = max(f0,f1,f2), then (f0,f1,f2) brackets a maximum. The minimum search continues recursively as in the monotonic case.
Parameters
func
minminimum lower bound
maxminimum upper bound
initinitial guess of minimum
Return values
argMinthe function arg that results in the minimum
valMinthe minimum

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