Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Math::BrentMinimizer1D Class Reference

User class for performing function minimization.

It will use the Brent Method for function minimization in a given interval. First, a grid search is used to bracket the minimum value with the a step size = (xmax-xmin)/npx. The step size can be controlled via the SetNpx() function. A default value of npx = 100 is used. The default value con be changed using the static method SetDefaultNpx. If the function is unimodal or if its extrema are far apart, setting the fNpx to a small value speeds the algorithm up many times. Then, Brent's method is applied on the bracketed interval. If the Brent method fails to converge the bracketing is repeated on the latest best estimate of the interval. The procedure is repeated with a maximum value (default =10) which can be set for all BrentRootFinder classes with the method SetDefaultNSearch

This class is implemented from TF1::GetMinimum.

To use the class, three steps have to be taken:

  1. Create the class.
  2. Set a function within an interval to look for the minimum.
  3. Call the Minimize function with the error parameters.

If another minimization is to be performed, repeat the last two steps.

Definition at line 62 of file BrentMinimizer1D.h.

Public Member Functions

 BrentMinimizer1D ()
 Default Constructor.
 
 ~BrentMinimizer1D () override
 Default Destructor.
 
double FValLower () const override
 Return function value at current lower bound of the minimization interval.
 
double FValMinimum () const override
 Return function value at current estimate of the minimum.
 
double FValUpper () const override
 Return function value at current upper bound of the minimization interval.
 
int Iterations () const override
 Return number of iteration used to find minimum.
 
bool Minimize (int maxIter, double absTol=1.E-8, double relTol=1.E-10) override
 Find minimum position iterating until convergence specified by the absolute and relative tolerance or the maximum number of iteration is reached.
 
const char * Name () const override
 Return name of minimization algorithm ("BrentMinimizer1D")
 
void SetFunction (const ROOT::Math::IGenFunction &f, double xlow, double xup)
 Sets function to be minimized.
 
void SetLogScan (bool on)
 Set a log grid scan (default is equidistant bins) will work only if xlow > 0.
 
void SetNpx (int npx)
 Set the number of point used to bracket root using a grid.
 
int Status () const override
 Returns status of last estimate.
 
double XLower () const override
 Return current lower bound of the minimization interval.
 
double XMinimum () const override
 Return current estimate of the position of the minimum.
 
double XUpper () const override
 Return current upper bound of the minimization interval.
 

Static Public Member Functions

static void SetDefaultNpx (int npx)
 set number of default Npx used at construction time (when SetNpx is not called) Default value is 100
 
static void SetDefaultNSearch (int n)
 set number of times the bracketing search in combination with is done to find a good interval Default value is 10
 

Private Attributes

const IGenFunctionfFunction
 Pointer to the function.
 
bool fLogScan
 flag to control usage of a log scan
 
int fNIter
 Number of iterations needed for the last estimation.
 
int fNpx
 Number of points to bracket minimum with grid (def is 100)
 
int fStatus
 Status of code of the last estimate.
 
double fXMax
 Upper bound of the search interval.
 
double fXMin
 Lower bound of the search interval.
 
double fXMinimum
 Position of the estimated minimum.
 

Additional Inherited Members

- Private Member Functions inherited from ROOT::Math::IMinimizer1D
 IMinimizer1D ()
 
virtual ~IMinimizer1D ()
 

#include <Math/BrentMinimizer1D.h>

Inheritance diagram for ROOT::Math::BrentMinimizer1D:
[legend]

Constructor & Destructor Documentation

◆ BrentMinimizer1D()

ROOT::Math::BrentMinimizer1D::BrentMinimizer1D ( )

Default Constructor.

Definition at line 33 of file BrentMinimizer1D.cxx.

◆ ~BrentMinimizer1D()

ROOT::Math::BrentMinimizer1D::~BrentMinimizer1D ( )
inlineoverride

Default Destructor.

Definition at line 70 of file BrentMinimizer1D.h.

Member Function Documentation

◆ FValLower()

double ROOT::Math::BrentMinimizer1D::FValLower ( ) const
overridevirtual

Return function value at current lower bound of the minimization interval.

Implements ROOT::Math::IMinimizer1D.

Definition at line 70 of file BrentMinimizer1D.cxx.

◆ FValMinimum()

double ROOT::Math::BrentMinimizer1D::FValMinimum ( ) const
overridevirtual

Return function value at current estimate of the minimum.

Implements ROOT::Math::IMinimizer1D.

Definition at line 67 of file BrentMinimizer1D.cxx.

◆ FValUpper()

double ROOT::Math::BrentMinimizer1D::FValUpper ( ) const
overridevirtual

Return function value at current upper bound of the minimization interval.

Implements ROOT::Math::IMinimizer1D.

Definition at line 73 of file BrentMinimizer1D.cxx.

◆ Iterations()

int ROOT::Math::BrentMinimizer1D::Iterations ( ) const
inlineoverridevirtual

Return number of iteration used to find minimum.

Implements ROOT::Math::IMinimizer1D.

Definition at line 102 of file BrentMinimizer1D.h.

◆ Minimize()

bool ROOT::Math::BrentMinimizer1D::Minimize ( int  maxIter,
double  absTol = 1.E-8,
double  relTol = 1.E-10 
)
overridevirtual

Find minimum position iterating until convergence specified by the absolute and relative tolerance or the maximum number of iteration is reached.

Return true if iterations converged successfully @param maxIter maximum number of iterations. @param absTol desired absolute error in the minimum position (default 1.E-8) @param absTol desired relative error in the minimum position (default = 1.E-10)

Implements ROOT::Math::IMinimizer1D.

Definition at line 76 of file BrentMinimizer1D.cxx.

◆ Name()

const char * ROOT::Math::BrentMinimizer1D::Name ( ) const
overridevirtual

Return name of minimization algorithm ("BrentMinimizer1D")

Implements ROOT::Math::IMinimizer1D.

Definition at line 124 of file BrentMinimizer1D.cxx.

◆ SetDefaultNpx()

void ROOT::Math::BrentMinimizer1D::SetDefaultNpx ( int  npx)
static

set number of default Npx used at construction time (when SetNpx is not called) Default value is 100

Definition at line 43 of file BrentMinimizer1D.cxx.

◆ SetDefaultNSearch()

void ROOT::Math::BrentMinimizer1D::SetDefaultNSearch ( int  n)
static

set number of times the bracketing search in combination with is done to find a good interval Default value is 10

Definition at line 45 of file BrentMinimizer1D.cxx.

◆ SetFunction()

void ROOT::Math::BrentMinimizer1D::SetFunction ( const ROOT::Math::IGenFunction f,
double  xlow,
double  xup 
)

Sets function to be minimized.

@param f Function to be minimized. @param xlow Lower bound of the search interval. @param xup Upper bound of the search interval.

Definition at line 48 of file BrentMinimizer1D.cxx.

◆ SetLogScan()

void ROOT::Math::BrentMinimizer1D::SetLogScan ( bool  on)
inline

Set a log grid scan (default is equidistant bins) will work only if xlow > 0.

Definition at line 122 of file BrentMinimizer1D.h.

◆ SetNpx()

void ROOT::Math::BrentMinimizer1D::SetNpx ( int  npx)
inline

Set the number of point used to bracket root using a grid.

Definition at line 116 of file BrentMinimizer1D.h.

◆ Status()

int ROOT::Math::BrentMinimizer1D::Status ( ) const
inlineoverridevirtual

Returns status of last estimate.

If = 0 is OK

Implements ROOT::Math::IMinimizer1D.

Definition at line 126 of file BrentMinimizer1D.h.

◆ XLower()

double ROOT::Math::BrentMinimizer1D::XLower ( ) const
inlineoverridevirtual

Return current lower bound of the minimization interval.

Implements ROOT::Math::IMinimizer1D.

Definition at line 78 of file BrentMinimizer1D.h.

◆ XMinimum()

double ROOT::Math::BrentMinimizer1D::XMinimum ( ) const
inlineoverridevirtual

Return current estimate of the position of the minimum.

Implements ROOT::Math::IMinimizer1D.

Definition at line 75 of file BrentMinimizer1D.h.

◆ XUpper()

double ROOT::Math::BrentMinimizer1D::XUpper ( ) const
inlineoverridevirtual

Return current upper bound of the minimization interval.

Implements ROOT::Math::IMinimizer1D.

Definition at line 81 of file BrentMinimizer1D.h.

Member Data Documentation

◆ fFunction

const IGenFunction* ROOT::Math::BrentMinimizer1D::fFunction
private

Pointer to the function.

Definition at line 142 of file BrentMinimizer1D.h.

◆ fLogScan

bool ROOT::Math::BrentMinimizer1D::fLogScan
private

flag to control usage of a log scan

Definition at line 143 of file BrentMinimizer1D.h.

◆ fNIter

int ROOT::Math::BrentMinimizer1D::fNIter
private

Number of iterations needed for the last estimation.

Definition at line 144 of file BrentMinimizer1D.h.

◆ fNpx

int ROOT::Math::BrentMinimizer1D::fNpx
private

Number of points to bracket minimum with grid (def is 100)

Definition at line 145 of file BrentMinimizer1D.h.

◆ fStatus

int ROOT::Math::BrentMinimizer1D::fStatus
private

Status of code of the last estimate.

Definition at line 146 of file BrentMinimizer1D.h.

◆ fXMax

double ROOT::Math::BrentMinimizer1D::fXMax
private

Upper bound of the search interval.

Definition at line 148 of file BrentMinimizer1D.h.

◆ fXMin

double ROOT::Math::BrentMinimizer1D::fXMin
private

Lower bound of the search interval.

Definition at line 147 of file BrentMinimizer1D.h.

◆ fXMinimum

double ROOT::Math::BrentMinimizer1D::fXMinimum
private

Position of the estimated minimum.

Definition at line 149 of file BrentMinimizer1D.h.

Libraries for ROOT::Math::BrentMinimizer1D:

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