Object-oriented Scientific Computing Library: Version 0.910
Public Member Functions | Data Fields
minimize< func_t, dfunc_t > Class Template Reference

One-dimensional minimization [abstract base]. More...

#include <minimize.h>

Inheritance diagram for minimize< func_t, dfunc_t >:
minimize_bkt< func_t, dfunc_t > minimize_de< func_t, dfunc_t > cern_minimize< func_t >

Detailed Description

template<class func_t = funct, class dfunc_t = func_t>
class minimize< func_t, dfunc_t >

Idea for Future:
Add a class for the quad_golden algorithm from GSL.

Definition at line 44 of file minimize.h.

Public Member Functions

virtual int print_iter (double x, double y, int iter, double value=0.0, double limit=0.0, std::string comment="")
 Print out iteration information.
virtual int min (double &x, double &fmin, func_t &func)=0
 Calculate the minimum min of func w.r.t 'x'.
virtual int min_bkt (double &x2, double x1, double x3, double &fmin, func_t &func)=0
 Calculate the minimum min of func with x2 bracketed between x1 and x3.
virtual int min_de (double &x, double &fmin, func_t &func, dfunc_t &df)=0
 Calculate the minimum min of func with derivative dfunc w.r.t 'x'.
virtual int bracket (double &ax, double &bx, double &cx, double &fa, double &fb, double &fc, func_t &func)
 Given interval (ax,bx), attempt to bracket a minimum for function func.
virtual const char * type ()
 Return string denoting type ("minimize")

Data Fields

int verbose
 Output control.
int ntrial
 Maximum number of iterations.
double tol_rel
 The tolerance for the minimum function value.
double tol_abs
 The tolerance for the location of the minimum.
int last_ntrial
 The number of iterations for in the most recent minimization.
int bracket_iter
 The number of iterations for automatically bracketing a minimum (default 20)
bool err_nonconv
 If true, call the error handler if the routine does not "converge".
int last_conv
 Zero if last call to min(), min_bkt(), or min_de() converged.

Member Function Documentation

template<class func_t = funct, class dfunc_t = func_t>
virtual int minimize< func_t, dfunc_t >::print_iter ( double  x,
double  y,
int  iter,
double  value = 0.0,
double  limit = 0.0,
std::string  comment = "" 
) [inline, virtual]

Depending on the value of the variable verbose, this prints out the iteration information. If verbose=0, then no information is printed, while if verbose>1, then after each iteration, the present values of x and y are output to std::cout along with the iteration number. If verbose>=2 then each iteration waits for a character.

Definition at line 102 of file minimize.h.

template<class func_t = funct, class dfunc_t = func_t>
virtual int minimize< func_t, dfunc_t >::min ( double &  x,
double &  fmin,
func_t &  func 
) [pure virtual]

If this is not overloaded, it attempts to bracket the minimum using bracket() and then calls min_bkt() with the newly bracketed minimum.

Implemented in minimize_de< func_t, dfunc_t >, minimize_bkt< func_t, dfunc_t >, and minimize_bkt< func_t >.

template<class func_t = funct, class dfunc_t = func_t>
virtual int minimize< func_t, dfunc_t >::min_bkt ( double &  x2,
double  x1,
double  x3,
double &  fmin,
func_t &  func 
) [pure virtual]
template<class func_t = funct, class dfunc_t = func_t>
virtual int minimize< func_t, dfunc_t >::min_de ( double &  x,
double &  fmin,
func_t &  func,
dfunc_t &  df 
) [pure virtual]

If this is not overloaded, it attempts to bracket the minimum using bracket() and then calls min_bkt_de() with the newly bracketed minimum.

Implemented in minimize_de< func_t, dfunc_t >, minimize_bkt< func_t, dfunc_t >, and minimize_bkt< func_t >.

template<class func_t = funct, class dfunc_t = func_t>
virtual int minimize< func_t, dfunc_t >::bracket ( double &  ax,
double &  bx,
double &  cx,
double &  fa,
double &  fb,
double &  fc,
func_t &  func 
) [inline, virtual]

Upon success, fa=func(ax), fb=func(bx), and fc=func(cx) with fb<fa, fb<fc and ax<bx<cx. The initial values of cx, fa, fb, and fc are all ignored.

The number of iterations is controlled by bracket_iter.

Note:
This algorithm can fail if there's a minimum which has a much smaller size than $ bx-ax $, or if the function has the same value at ax, bx, and the midpoint (ax+bx)/2.
Idea for Future:
Improve this algorithm with the golden ratio method in gsl/min/bracketing.c?

Definition at line 169 of file minimize.h.


Field Documentation

template<class func_t = funct, class dfunc_t = func_t>
int minimize< func_t, dfunc_t >::last_conv

This is particularly useful if err_nonconv is false to test if the last call to min(), min_bkt(), or min_de() converged.

Definition at line 91 of file minimize.h.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.