ROOT logo
ROOT » MATH » MATHCORE » ROOT::Math::Minimizer

class ROOT::Math::Minimizer


   Abstract Minimizer class, defining  the interface for the various minimizer
   (like Minuit2, Minuit, GSL, etc..)
   Plug-in's exist in ROOT to be able to instantiate the derived classes like
   ROOT::Math::GSLMinimizer or ROOT::Math::Minuit2Minimizer via the
   plug-in manager.

   Provides interface for setting the function to be minimized.
   The function must  implemente the multi-dimensional generic interface
   ROOT::Math::IBaseFunctionMultiDim.
   If the function provides gradient calculation
   (implements the ROOT::Math::IGradientFunctionMultiDim interface) this will be
   used by the Minimizer.

   It Defines also interface for setting the initial values for the function variables (which are the parameters in
   of the model function in case of solving for fitting) and especifying their limits.

   It defines the interface to set and retrieve basic minimization parameters
   (for specific Minimizer parameters one must use the derived classes).

   Then it defines the interface to retrieve the result of minimization ( minimum X values, function value,
   gradient, error on the mimnimum, etc...)

   @ingroup MultiMin

Function Members (Methods)

 
    This is an abstract class, constructors will not be documented.
    Look at the header to check for available constructors.

public:
virtual~Minimizer()
virtual voidClear()
virtual boolContour(unsigned int ivar, unsigned int jvar, unsigned int& npoints, double* xi, double* xj)
virtual doubleCorrelation(unsigned int i, unsigned int j) const
virtual doubleCovMatrix(unsigned int ivar, unsigned int jvar) const
virtual intCovMatrixStatus() const
virtual doubleEdm() const
doubleErrorDef() const
virtual const double*Errors() const
virtual boolFixVariable(unsigned int ivar)
virtual boolGetCovMatrix(double* covMat) const
virtual boolGetHessianMatrix(double* hMat) const
virtual boolGetMinosError(unsigned int ivar, double& errLow, double& errUp, int option = 0)
virtual boolGetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings&) const
virtual doubleGlobalCC(unsigned int ivar) const
virtual boolHesse()
virtual boolIsFixedVariable(unsigned int ivar) const
boolIsValidError() const
unsigned intMaxFunctionCalls() const
unsigned intMaxIterations() const
virtual const double*MinGradient() const
virtual boolMinimize()
virtual doubleMinValue() const
virtual unsigned intNCalls() const
virtual unsigned intNDim() const
virtual unsigned intNFree() const
virtual unsigned intNIterations() const
virtual ROOT::Math::MinimizerOptionsOptions() const
doublePrecision() const
intPrintLevel() const
virtual voidPrintResults()
virtual boolProvidesError() const
virtual boolReleaseVariable(unsigned int ivar)
virtual boolScan(unsigned int ivar, unsigned int& nstep, double* x, double* y, double xmin = 0, double xmax = 0)
voidSetDefaultOptions()
voidSetErrorDef(double up)
virtual boolSetFixedVariable(unsigned int ivar, const string& name, double val)
virtual voidSetFunction(const ROOT::Math::IMultiGenFunction& func)
virtual voidSetFunction(const ROOT::Math::IMultiGradFunction& func)
virtual boolSetLimitedVariable(unsigned int ivar, const string& name, double val, double step, double lower, double upper)
virtual boolSetLowerLimitedVariable(unsigned int ivar, const string& name, double val, double step, double lower)
voidSetMaxFunctionCalls(unsigned int maxfcn)
voidSetMaxIterations(unsigned int maxiter)
voidSetOptions(const ROOT::Math::MinimizerOptions& opt)
voidSetPrecision(double prec)
voidSetPrintLevel(int level)
voidSetStrategy(int strategyLevel)
voidSetTolerance(double tol)
virtual boolSetUpperLimitedVariable(unsigned int ivar, const string& name, double val, double step, double upper)
voidSetValidError(bool on)
virtual boolSetVariable(unsigned int ivar, const string& name, double val, double step)
virtual boolSetVariableInitialRange(unsigned int, double, double)
virtual boolSetVariableLimits(unsigned int ivar, double lower, double upper)
virtual boolSetVariableLowerLimit(unsigned int ivar, double lower)
virtual boolSetVariableStepSize(unsigned int ivar, double value)
virtual boolSetVariableUpperLimit(unsigned int ivar, double upper)
virtual boolSetVariableValue(unsigned int ivar, double value)
virtual boolSetVariableValues(const double* x)
intStatus() const
intStrategy() const
doubleTolerance() const
virtual intVariableIndex(const string& name) const
virtual stringVariableName(unsigned int ivar) const
virtual const double*X() const
private:
ROOT::Math::Minimizer&operator=(const ROOT::Math::Minimizer& rhs)

Data Members

protected:
ROOT::Math::MinimizerOptionsfOptionsminimizer options
intfStatusstatus of minimizer
boolfValidErrorflag to control if errors have been validated (Hesse has been run in case of Minuit)

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

virtual ~Minimizer()
      Destructor (no operations)

{}
void Clear()
 reset for consecutive minimizations - implement if needed
{}
void SetFunction(const ROOT::Math::IMultiGenFunction& func)
 set the function to minimize
void SetFunction(const ROOT::Math::IMultiGradFunction& func)
 set a function to minimize using gradient
bool SetVariable(unsigned int ivar, const string& name, double val, double step)
 set a new free variable
bool SetLowerLimitedVariable(unsigned int ivar, const string& name, double val, double step, double lower)
 set a new lower limit variable  (override if minimizer supports them )
return SetLimitedVariable(unsigned int ivar, const string& name, double val, double step, double lower, double upper)
bool SetUpperLimitedVariable(unsigned int ivar, const string& name, double val, double step, double upper)
 set a new upper limit variable (override if minimizer supports them )
bool SetFixedVariable(unsigned int ivar, const string& name, double val)
 set a new fixed variable (override if minimizer supports them )
bool SetVariableValue(unsigned int ivar, double value)
 set the value of an already existing variable
bool SetVariableValues(const double* x)
 set the values of all existing variables (array must be dimensioned to the size of the existing parameters)
bool SetVariableStepSize(unsigned int ivar, double value)
 set the step size of an already existing variable
bool SetVariableLowerLimit(unsigned int ivar, double lower)
 set the lower-limit of an already existing variable
bool SetVariableUpperLimit(unsigned int ivar, double upper)
 set the upper-limit of an already existing variable
bool SetVariableLimits(unsigned int ivar, double lower, double upper)
 set the limits of an already existing variable
bool FixVariable(unsigned int ivar)
 fix an existing variable
bool ReleaseVariable(unsigned int ivar)
 release an existing variable
bool IsFixedVariable(unsigned int ivar) const
 query if an existing variable is fixed (i.e. considered constant in the minimization)
 note that by default all variables are not fixed
bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings& ) const
 get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
bool SetVariableInitialRange(unsigned int , double , double )
 set the initial range of an existing variable
bool Minimize()
 method to perform the minimization
double MinValue() const
 return minimum function value
const double * X() const
 return  pointer to X values at the minimum
double Edm() const
 return expected distance reached from the minimum (re-implement if minimizer provides it
{ return -1; }
const double * MinGradient() const
 return pointer to gradient values at the minimum
{ return NULL; }
unsigned int NCalls() const
 number of function calls to reach the minimum
{ return 0; }
unsigned int NIterations() const
 number of iterations to reach the minimum
{ return NCalls(); }
unsigned int NDim() const
 this is <= Function().NDim() which is the total
 number of variables (free+ constrained ones)
unsigned int NFree() const
 number of free variables (real dimension of the problem)
 this is <= Function().NDim() which is the total
 (re-implement if minimizer supports bounded parameters)
{ return NDim(); }
bool ProvidesError() const
 minimizer provides error and error matrix
{ return false; }
const double * Errors() const
 return errors at the minimum
{ return NULL; }
double CovMatrix(unsigned int ivar, unsigned int jvar) const
 return covariance matrices element for variables ivar,jvar
       if the variable is fixed the return value is zero
       The ordering of the variables is the same as in the parameter and errors vectors

bool GetCovMatrix(double* covMat) const
       Fill the passed array with the  covariance matrix elements
       if the variable is fixed or const the value is zero.
       The array will be filled as cov[i *ndim + j]
       The ordering of the variables is the same as in errors and parameter value.
       This is different from the direct interface of Minuit2 or TMinuit where the
       values were obtained only to variable parameters

bool GetHessianMatrix(double* hMat) const
       Fill the passed array with the Hessian matrix elements
       The Hessian matrix is the matrix of the second derivatives
       and is the inverse of the covariance matrix
       If the variable is fixed or const the values for that variables are zero.
       The array will be filled as h[i *ndim + j]

int CovMatrixStatus() const
return status of covariance matrix
 using Minuit convention {0 not calculated 1 approximated 2 made pos def , 3 accurate}
 Minimizer who implements covariance matrix calculation will re-implement the method
double Correlation(unsigned int i, unsigned int j) const
      return correlation coefficient between variable i and j.
      If the variable is fixed or const the return value is zero

double GlobalCC(unsigned int ivar) const
      return global correlation coefficient for variable i
      This is a number between zero and one which gives
      the correlation between the i-th parameter  and that linear combination of all
      other parameters which is most strongly correlated with i.
      Minimizer must overload method if implemented

bool GetMinosError(unsigned int ivar, double& errLow, double& errUp, int option = 0)
      minos error for variable i, return false if Minos failed or not supported
      and the lower and upper errors are returned in errLow and errUp
      An extra flag  specifies if only the lower (option=-1) or the upper (option=+1) error calculation is run
      (This feature is not yet implemented)

bool Hesse()
      perform a full calculation of the Hessian matrix for error calculation

bool Scan(unsigned int ivar, unsigned int& nstep, double* x, double* y, double xmin = 0, double xmax = 0)
      scan function minimum for variable i. Variable and function must be set before using Scan
      Return false if an error or if minimizer does not support this functionality

bool Contour(unsigned int ivar, unsigned int jvar, unsigned int& npoints, double* xi, double* xj)
      find the contour points (xi, xj) of the function for parameter ivar and jvar around the minimum
      The contour will be find for value of the function = Min + ErrorUp();

void PrintResults()
 return reference to the objective function
virtual const ROOT::Math::IGenFunction & Function() const = 0;
 print the result according to set level (implemented for TMinuit for mantaining Minuit-style printing)
{}
std::string VariableName(unsigned int ivar) const
 get name of variables (override if minimizer support storing of variable names)
 return an empty string if variable is not found
int VariableIndex(const string& name) const
 get index of variable given a variable given a name
 return -1 if variable is not found
int PrintLevel() const
 minimizer configuration parameters 
 set print level
{ return fOptions.PrintLevel(); }
unsigned int MaxFunctionCalls() const
  max number of function calls
unsigned int MaxIterations() const
 max iterations
{ return fOptions.MaxIterations(); }
double Tolerance() const
 absolute tolerance
{ return fOptions.Tolerance(); }
double Precision() const
 precision of minimizer in the evaluation of the objective function
 ( a value <=0 corresponds to the let the minimizer choose its default one)
{ return fOptions.Precision(); }
int Strategy() const
 strategy
{ return fOptions.Strategy(); }
int Status() const
 status code of minimizer
{ return fStatus; }
double ErrorDef() const
 return the statistical scale used for calculate the error
 is typically 1 for Chi2 and 0.5 for likelihood minimization
{ return fOptions.ErrorDef(); }
bool IsValidError() const
return true if Minimizer has performed a detailed error validation (e.g. run Hesse for Minuit)
{ return fValidError; }
void SetPrintLevel(int level)
 set print level
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
{ if (maxfcn > 0) fOptions.SetMaxFunctionCalls(maxfcn); }
void SetMaxIterations(unsigned int maxiter)
 set maximum iterations (one iteration can have many function calls)
{ if (maxiter > 0) fOptions.SetMaxIterations(maxiter); }
void SetTolerance(double tol)
 set the tolerance
void SetPrecision(double prec)
 set in the minimizer the objective function evaluation precision
 ( a value <=0 means the minimizer will choose its optimal value automatically, i.e. default case)
void SetStrategy(int strategyLevel)
set the strategy
{ fOptions.SetStrategy(strategyLevel); }
void SetErrorDef(double up)
 set scale for calculating the errors
void SetValidError(bool on)
 flag to check if minimizer needs to perform accurate error analysis (e.g. run Hesse for Minuit)
{ fValidError = on; }
void SetOptions(const ROOT::Math::MinimizerOptions& opt)
 set all options in one go
void SetDefaultOptions()
 reset the defaut options (defined in MinimizerOptions)