BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ROOT::Math::Minimizer Class Referenceabstract

Description

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...)

Definition at line 78 of file Minimizer.h.

Inheritance diagram for ROOT::Math::Minimizer:
[legend]
Collaboration diagram for ROOT::Math::Minimizer:
[legend]

Public Member Functions

 Minimizer ()
 
virtual ~Minimizer ()
 
virtual void Clear ()
 reset for consecutive minimizations - implement if needed More...
 
virtual bool Contour (unsigned int ivar, unsigned int jvar, unsigned int &npoints, double *xi, double *xj)
 
virtual double Correlation (unsigned int i, unsigned int j) const
 
virtual double CovMatrix (unsigned int ivar, unsigned int jvar) const
 
virtual 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 More...
 
virtual double Edm () const
 return expected distance reached from the minimum (re-implement if minimizer provides it More...
 
double ErrorDef () const
 return the statistical scale used for calculate the error is typically 1 for Chi2 and 0.5 for likelihood minimization More...
 
virtual const double * Errors () const
 return errors at the minimum More...
 
virtual bool FixVariable (unsigned int ivar)
 fix an existing variable More...
 
virtual bool GetCovMatrix (double *covMat) const
 
virtual bool GetHessianMatrix (double *hMat) const
 
virtual bool GetMinosError (unsigned int ivar, double &errLow, double &errUp, int option=0)
 
virtual bool GetVariableSettings (unsigned int ivar, ROOT::Fit::ParameterSettings &pars) const
 get variable settings in a variable object (like ROOT::Fit::ParamsSettings) More...
 
virtual double GlobalCC (unsigned int ivar) const
 
virtual bool Hesse ()
 
virtual 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 More...
 
bool IsValidError () const
 return true if Minimizer has performed a detailed error validation (e.g. run Hesse for Minuit) More...
 
unsigned int MaxFunctionCalls () const
 max number of function calls More...
 
unsigned int MaxIterations () const
 max iterations More...
 
virtual const double * MinGradient () const
 return pointer to gradient values at the minimum More...
 
virtual bool Minimize ()=0
 method to perform the minimization More...
 
virtual double MinValue () const =0
 return minimum function value More...
 
virtual unsigned int NCalls () const
 number of function calls to reach the minimum More...
 
virtual unsigned int NDim () const =0
 this is <= Function().NDim() which is the total number of variables (free+ constrained ones) More...
 
virtual 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) More...
 
virtual unsigned int NIterations () const
 number of iterations to reach the minimum More...
 
virtual MinimizerOptions Options () const
 retrieve the minimizer options (implement derived class if needed) More...
 
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) More...
 
int PrintLevel () const
 set print level More...
 
virtual void PrintResults ()
 return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const = 0; More...
 
virtual bool ProvidesError () const
 minimizer provides error and error matrix More...
 
virtual bool ReleaseVariable (unsigned int ivar)
 release an existing variable More...
 
virtual bool Scan (unsigned int ivar, unsigned int &nstep, double *x, double *y, double xmin=0, double xmax=0)
 
void SetDefaultOptions ()
 reset the defaut options (defined in MinimizerOptions) More...
 
void SetErrorDef (double up)
 set scale for calculating the errors More...
 
virtual bool SetFixedVariable (unsigned int ivar, const std::string &name, double val)
 set a new fixed variable (override if minimizer supports them ) More...
 
virtual void SetFunction (const ROOT::Math::IMultiGenFunction &func)=0
 set the function to minimize More...
 
virtual void SetFunction (const ROOT::Math::IMultiGradFunction &func)
 set a function to minimize using gradient More...
 
virtual bool SetLimitedVariable (unsigned int ivar, const std::string &name, double val, double step, double lower, double upper)
 set a new upper/lower limited variable (override if minimizer supports them ) otherwise as default set an unlimited variable More...
 
virtual bool SetLowerLimitedVariable (unsigned int ivar, const std::string &name, double val, double step, double lower)
 set a new lower limit variable (override if minimizer supports them ) More...
 
void SetMaxFunctionCalls (unsigned int maxfcn)
 set maximum of function calls More...
 
void SetMaxIterations (unsigned int maxiter)
 set maximum iterations (one iteration can have many function calls) More...
 
void SetOptions (const MinimizerOptions &opt)
 set all options in one go More...
 
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) More...
 
void SetPrintLevel (int level)
 set print level More...
 
void SetStrategy (int strategyLevel)
 set the strategy More...
 
void SetTolerance (double tol)
 set the tolerance More...
 
virtual bool SetUpperLimitedVariable (unsigned int ivar, const std::string &name, double val, double step, double upper)
 set a new upper limit variable (override if minimizer supports them ) More...
 
void SetValidError (bool on)
 flag to check if minimizer needs to perform accurate error analysis (e.g. run Hesse for Minuit) More...
 
virtual bool SetVariable (unsigned int ivar, const std::string &name, double val, double step)=0
 set a new free variable More...
 
virtual bool SetVariableInitialRange (unsigned int, double, double)
 set the initial range of an existing variable More...
 
virtual bool SetVariableLimits (unsigned int ivar, double lower, double upper)
 set the limits of an already existing variable More...
 
virtual bool SetVariableLowerLimit (unsigned int ivar, double lower)
 set the lower-limit of an already existing variable More...
 
template<class VariableIterator >
int SetVariables (const VariableIterator &begin, const VariableIterator &end)
 add variables . Return number of variables successfully added More...
 
virtual bool SetVariableStepSize (unsigned int ivar, double value)
 set the step size of an already existing variable More...
 
virtual bool SetVariableUpperLimit (unsigned int ivar, double upper)
 set the upper-limit of an already existing variable More...
 
virtual bool SetVariableValue (unsigned int ivar, double value)
 set the value of an already existing variable More...
 
virtual bool SetVariableValues (const double *x)
 set the values of all existing variables (array must be dimensioned to the size of the existing parameters) More...
 
int Status () const
 status code of minimizer More...
 
int Strategy () const
 strategy More...
 
double Tolerance () const
 absolute tolerance More...
 
virtual int VariableIndex (const std::string &name) const
 get index of variable given a variable given a name return -1 if variable is not found More...
 
virtual 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 More...
 
virtual const double * X () const =0
 return pointer to X values at the minimum More...
 

Protected Attributes

MinimizerOptions fOptions
 
int fStatus
 
bool fValidError
 

Private Member Functions

 Minimizer (const Minimizer &)
 
Minimizeroperator= (const Minimizer &rhs)
 

Constructor & Destructor Documentation

◆ Minimizer() [1/2]

ROOT::Math::Minimizer::Minimizer ( )
inline

Default constructor

Definition at line 85 of file Minimizer.h.

85  :
86  fValidError(false),
87  fStatus(-1)
88  {}

◆ ~Minimizer()

virtual ROOT::Math::Minimizer::~Minimizer ( )
inlinevirtual

Destructor (no operations)

Definition at line 93 of file Minimizer.h.

93 {}

◆ Minimizer() [2/2]

ROOT::Math::Minimizer::Minimizer ( const Minimizer )
inlineprivate

Copy constructor

Definition at line 104 of file Minimizer.h.

104 {}

Member Function Documentation

◆ Clear()

virtual void ROOT::Math::Minimizer::Clear ( )
inlinevirtual

reset for consecutive minimizations - implement if needed

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::GeneticMinimizer.

Definition at line 117 of file Minimizer.h.

117 {}

◆ Contour()

virtual bool ROOT::Math::Minimizer::Contour ( unsigned int  ivar,
unsigned int  jvar,
unsigned int &  npoints,
double *  xi,
double *  xj 
)
inlinevirtual

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();

Reimplemented in ROOT::Minuit2::Minuit2Minimizer.

Definition at line 379 of file Minimizer.h.

380  {
381  MATH_ERROR_MSG("Minimizer::Contour","Contour not implemented");
382  MATH_UNUSED(ivar); MATH_UNUSED(jvar); MATH_UNUSED(npoints);
383  MATH_UNUSED(xi); MATH_UNUSED(xj);
384  return false;
385  }
#define MATH_ERROR_MSG(loc, str)
Definition: Error.h:50
#define MATH_UNUSED(var)
Definition: Util.h:26

References MATH_ERROR_MSG, and MATH_UNUSED.

◆ Correlation()

virtual double ROOT::Math::Minimizer::Correlation ( unsigned int  i,
unsigned int  j 
) const
inlinevirtual

return correlation coefficient between variable i and j. If the variable is fixed or const the return value is zero

Reimplemented in ROOT::Minuit2::Minuit2Minimizer.

Definition at line 326 of file Minimizer.h.

326  {
327  double tmp = CovMatrix(i,i) * CovMatrix(j,j);
328  return ( tmp < 0) ? 0 : CovMatrix(i,j) / std::sqrt( tmp );
329  }
virtual double CovMatrix(unsigned int ivar, unsigned int jvar) const
Definition: Minimizer.h:284

References CovMatrix().

Referenced by MinimizerAdapter::propagateResults().

Here is the call graph for this function:

◆ CovMatrix()

virtual double ROOT::Math::Minimizer::CovMatrix ( unsigned int  ivar,
unsigned int  jvar 
) const
inlinevirtual

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

Reimplemented in ROOT::Math::GSLNLSMinimizer, ROOT::Math::GSLMinimizer, ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::GeneticMinimizer.

Definition at line 284 of file Minimizer.h.

284  {
285  MATH_UNUSED(ivar); MATH_UNUSED(jvar);
286  return 0;
287  }

References MATH_UNUSED.

Referenced by Correlation().

◆ CovMatrixStatus()

virtual int ROOT::Math::Minimizer::CovMatrixStatus ( ) const
inlinevirtual

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

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::GSLNLSMinimizer.

Definition at line 318 of file Minimizer.h.

318  {
319  return 0;
320  }

Referenced by GSLLevenbergMarquardtMinimizer::statusMap(), and Minuit2Minimizer::statusMap().

◆ Edm()

virtual double ROOT::Math::Minimizer::Edm ( ) const
inlinevirtual

return expected distance reached from the minimum (re-implement if minimizer provides it

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::GSLNLSMinimizer, ROOT::Math::GSLMinimizer, and ROOT::Math::GeneticMinimizer.

Definition at line 254 of file Minimizer.h.

254 { return -1; }

◆ ErrorDef()

double ROOT::Math::Minimizer::ErrorDef ( ) const
inline

return the statistical scale used for calculate the error is typically 1 for Chi2 and 0.5 for likelihood minimization

Definition at line 434 of file Minimizer.h.

434 { return fOptions.ErrorDef(); }
double ErrorDef() const
error definition
MinimizerOptions fOptions
Definition: Minimizer.h:489

References ROOT::Math::MinimizerOptions::ErrorDef(), and fOptions.

Here is the call graph for this function:

◆ Errors()

virtual const double* ROOT::Math::Minimizer::Errors ( ) const
inlinevirtual

return errors at the minimum

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::GSLNLSMinimizer, ROOT::Math::GSLMinimizer, and ROOT::Math::GeneticMinimizer.

Definition at line 278 of file Minimizer.h.

278 { return NULL; }

◆ FixVariable()

virtual bool ROOT::Math::Minimizer::FixVariable ( unsigned int  ivar)
inlinevirtual

fix an existing variable

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 213 of file Minimizer.h.

213  {
214  MATH_ERROR_MSG("Minimizer::FixVariable","Fixing an existing variable not implemented");
215  MATH_UNUSED(ivar);
216  return false;
217  }

References MATH_ERROR_MSG, and MATH_UNUSED.

◆ GetCovMatrix()

virtual bool ROOT::Math::Minimizer::GetCovMatrix ( double *  covMat) const
inlinevirtual

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

Reimplemented in ROOT::Minuit2::Minuit2Minimizer.

Definition at line 297 of file Minimizer.h.

297  {
298  MATH_UNUSED(covMat);
299  return false;
300  }

References MATH_UNUSED.

◆ GetHessianMatrix()

virtual bool ROOT::Math::Minimizer::GetHessianMatrix ( double *  hMat) const
inlinevirtual

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]

Reimplemented in ROOT::Minuit2::Minuit2Minimizer.

Definition at line 309 of file Minimizer.h.

309  {
310  MATH_UNUSED(hMat);
311  return false;
312  }

References MATH_UNUSED.

◆ GetMinosError()

virtual bool ROOT::Math::Minimizer::GetMinosError ( unsigned int  ivar,
double &  errLow,
double &  errUp,
int  option = 0 
)
inlinevirtual

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)

Reimplemented in ROOT::Minuit2::Minuit2Minimizer.

Definition at line 349 of file Minimizer.h.

349  {
350  MATH_ERROR_MSG("Minimizer::GetMinosError","Minos Error not implemented");
351  MATH_UNUSED(ivar); MATH_UNUSED(errLow); MATH_UNUSED(errUp); MATH_UNUSED(option);
352  return false;
353  }

References MATH_ERROR_MSG, and MATH_UNUSED.

◆ GetVariableSettings()

virtual bool ROOT::Math::Minimizer::GetVariableSettings ( unsigned int  ivar,
ROOT::Fit::ParameterSettings pars 
) const
inlinevirtual

get variable settings in a variable object (like ROOT::Fit::ParamsSettings)

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 232 of file Minimizer.h.

232  {
233  MATH_ERROR_MSG("Minimizer::GetVariableSettings","Quering an existing variable not implemented");
234  MATH_UNUSED(ivar); MATH_UNUSED(pars);
235  return false;
236  }

References MATH_ERROR_MSG, and MATH_UNUSED.

◆ GlobalCC()

virtual double ROOT::Math::Minimizer::GlobalCC ( unsigned int  ivar) const
inlinevirtual

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

Reimplemented in ROOT::Minuit2::Minuit2Minimizer.

Definition at line 338 of file Minimizer.h.

338  {
339  MATH_UNUSED(ivar);
340  return -1;
341  }

References MATH_UNUSED.

◆ Hesse()

virtual bool ROOT::Math::Minimizer::Hesse ( )
inlinevirtual

perform a full calculation of the Hessian matrix for error calculation

Reimplemented in ROOT::Minuit2::Minuit2Minimizer.

Definition at line 358 of file Minimizer.h.

358  {
359  MATH_ERROR_MSG("Minimizer::Hesse","Hesse not implemented");
360  return false;
361  }

References MATH_ERROR_MSG.

◆ IsFixedVariable()

virtual bool ROOT::Math::Minimizer::IsFixedVariable ( unsigned int  ivar) const
inlinevirtual

query if an existing variable is fixed (i.e. considered constant in the minimization) note that by default all variables are not fixed

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 226 of file Minimizer.h.

226  {
227  MATH_ERROR_MSG("Minimizer::IsFixedVariable","Quering an existing variable not implemented");
228  MATH_UNUSED(ivar);
229  return false;
230  }

References MATH_ERROR_MSG, and MATH_UNUSED.

◆ IsValidError()

bool ROOT::Math::Minimizer::IsValidError ( ) const
inline

return true if Minimizer has performed a detailed error validation (e.g. run Hesse for Minuit)

Definition at line 437 of file Minimizer.h.

437 { return fValidError; }

References fValidError.

◆ MaxFunctionCalls()

unsigned int ROOT::Math::Minimizer::MaxFunctionCalls ( ) const
inline

max number of function calls

Definition at line 414 of file Minimizer.h.

414 { return fOptions.MaxFunctionCalls(); }
unsigned int MaxFunctionCalls() const
max number of function calls

References fOptions, and ROOT::Math::MinimizerOptions::MaxFunctionCalls().

Here is the call graph for this function:

◆ MaxIterations()

unsigned int ROOT::Math::Minimizer::MaxIterations ( ) const
inline

max iterations

Definition at line 417 of file Minimizer.h.

417 { return fOptions.MaxIterations(); }
unsigned int MaxIterations() const
max iterations

References fOptions, and ROOT::Math::MinimizerOptions::MaxIterations().

Here is the call graph for this function:

◆ MinGradient()

virtual const double* ROOT::Math::Minimizer::MinGradient ( ) const
inlinevirtual

return pointer to gradient values at the minimum

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::GSLNLSMinimizer, ROOT::Math::GSLMinimizer, and ROOT::Math::GeneticMinimizer.

Definition at line 257 of file Minimizer.h.

257 { return NULL; }

◆ Minimize()

virtual bool ROOT::Math::Minimizer::Minimize ( )
pure virtual

◆ MinValue()

virtual double ROOT::Math::Minimizer::MinValue ( ) const
pure virtual

◆ NCalls()

virtual unsigned int ROOT::Math::Minimizer::NCalls ( ) const
inlinevirtual

number of function calls to reach the minimum

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::GSLSimAnMinimizer, ROOT::Math::GSLNLSMinimizer, ROOT::Math::GSLMinimizer, and ROOT::Math::GeneticMinimizer.

Definition at line 260 of file Minimizer.h.

260 { return 0; }

Referenced by NIterations().

◆ NDim()

virtual unsigned int ROOT::Math::Minimizer::NDim ( ) const
pure virtual

this is <= Function().NDim() which is the total number of variables (free+ constrained ones)

Implemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::GeneticMinimizer, and ROOT::Math::BasicMinimizer.

Referenced by MinimizerAdapter::fitRank(), NFree(), and SetVariableValues().

◆ NFree()

virtual unsigned int ROOT::Math::Minimizer::NFree ( ) const
inlinevirtual

number of free variables (real dimension of the problem) this is <= Function().NDim() which is the total (re-implement if minimizer supports bounded parameters)

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::GeneticMinimizer, and ROOT::Math::BasicMinimizer.

Definition at line 272 of file Minimizer.h.

272 { return NDim(); }
virtual unsigned int NDim() const =0
this is <= Function().NDim() which is the total number of variables (free+ constrained ones)

References NDim().

Here is the call graph for this function:

◆ NIterations()

virtual unsigned int ROOT::Math::Minimizer::NIterations ( ) const
inlinevirtual

number of iterations to reach the minimum

Definition at line 263 of file Minimizer.h.

263 { return NCalls(); }
virtual unsigned int NCalls() const
number of function calls to reach the minimum
Definition: Minimizer.h:260

References NCalls().

Here is the call graph for this function:

◆ operator=()

Minimizer& ROOT::Math::Minimizer::operator= ( const Minimizer rhs)
inlineprivate

Assignment operator

Definition at line 109 of file Minimizer.h.

109  {
110  if (this == &rhs) return *this; // time saving self-test
111  return *this;
112  }

◆ Options()

virtual MinimizerOptions ROOT::Math::Minimizer::Options ( ) const
inlinevirtual

retrieve the minimizer options (implement derived class if needed)

Reimplemented in ROOT::Math::GeneticMinimizer.

Definition at line 440 of file Minimizer.h.

440  {
441  return fOptions;
442  }

References fOptions.

◆ Precision()

double ROOT::Math::Minimizer::Precision ( ) const
inline

precision of minimizer in the evaluation of the objective function ( a value <=0 corresponds to the let the minimizer choose its default one)

Definition at line 424 of file Minimizer.h.

424 { return fOptions.Precision(); }
double Precision() const
precision in the objective funciton calculation (value <=0 means left to default)

References fOptions, and ROOT::Math::MinimizerOptions::Precision().

Here is the call graph for this function:

◆ PrintLevel()

int ROOT::Math::Minimizer::PrintLevel ( ) const
inline

set print level

minimizer configuration parameters

Definition at line 411 of file Minimizer.h.

411 { return fOptions.PrintLevel(); }
int PrintLevel() const
set print level

References fOptions, and ROOT::Math::MinimizerOptions::PrintLevel().

Here is the call graph for this function:

◆ PrintResults()

virtual void ROOT::Math::Minimizer::PrintResults ( )
inlinevirtual

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)

Reimplemented in ROOT::Minuit2::Minuit2Minimizer.

Definition at line 391 of file Minimizer.h.

391 {}

◆ ProvidesError()

virtual bool ROOT::Math::Minimizer::ProvidesError ( ) const
inlinevirtual

minimizer provides error and error matrix

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::GSLNLSMinimizer, ROOT::Math::GSLMinimizer, and ROOT::Math::GeneticMinimizer.

Definition at line 275 of file Minimizer.h.

275 { return false; }

Referenced by MinimizerAdapter::providesError().

◆ ReleaseVariable()

virtual bool ROOT::Math::Minimizer::ReleaseVariable ( unsigned int  ivar)
inlinevirtual

release an existing variable

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 219 of file Minimizer.h.

219  {
220  MATH_ERROR_MSG("Minimizer::ReleaseVariable","Releasing an existing variable not implemented");
221  MATH_UNUSED(ivar);
222  return false;
223  }

References MATH_ERROR_MSG, and MATH_UNUSED.

◆ Scan()

virtual bool ROOT::Math::Minimizer::Scan ( unsigned int  ivar,
unsigned int &  nstep,
double *  x,
double *  y,
double  xmin = 0,
double  xmax = 0 
)
inlinevirtual

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

Reimplemented in ROOT::Minuit2::Minuit2Minimizer.

Definition at line 367 of file Minimizer.h.

368  {
369  MATH_ERROR_MSG("Minimizer::Scan","Scan not implemented");
370  MATH_UNUSED(ivar); MATH_UNUSED(nstep); MATH_UNUSED(x); MATH_UNUSED(y);
371  MATH_UNUSED(xmin); MATH_UNUSED(xmax);
372  return false;
373  }

References MATH_ERROR_MSG, and MATH_UNUSED.

◆ SetDefaultOptions()

void ROOT::Math::Minimizer::SetDefaultOptions ( )
inline

reset the defaut options (defined in MinimizerOptions)

Definition at line 475 of file Minimizer.h.

475  {
477  }

References fOptions, and ROOT::Math::MinimizerOptions::ResetToDefaultOptions().

Here is the call graph for this function:

◆ SetErrorDef()

void ROOT::Math::Minimizer::SetErrorDef ( double  up)
inline

set scale for calculating the errors

Definition at line 464 of file Minimizer.h.

464 { fOptions.SetErrorDef(up); }
void SetErrorDef(double err)
set error def

References fOptions, and ROOT::Math::MinimizerOptions::SetErrorDef().

Here is the call graph for this function:

◆ SetFixedVariable()

virtual bool ROOT::Math::Minimizer::SetFixedVariable ( unsigned int  ivar,
const std::string &  name,
double  val 
)
inlinevirtual

set a new fixed variable (override if minimizer supports them )

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::BasicMinimizer, and ROOT::Math::GeneticMinimizer.

Definition at line 170 of file Minimizer.h.

170  {
171  MATH_ERROR_MSG("Minimizer::SetFixedVariable","Setting of fixed variable not implemented");
172  MATH_UNUSED(ivar); MATH_UNUSED(name); MATH_UNUSED(val);
173  return false;
174  }

References MATH_ERROR_MSG, and MATH_UNUSED.

Referenced by MinimizerAdapter::setParameter(), and SetVariables().

◆ SetFunction() [1/2]

◆ SetFunction() [2/2]

virtual void ROOT::Math::Minimizer::SetFunction ( const ROOT::Math::IMultiGradFunction func)
inlinevirtual

set a function to minimize using gradient

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::GSLNLSMinimizer, ROOT::Math::GSLMinimizer, and ROOT::Math::BasicMinimizer.

Definition at line 123 of file Minimizer.h.

124  {
125  SetFunction(static_cast<const ::ROOT::Math::IMultiGenFunction &> (func));
126  }
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)=0
set the function to minimize

References SetFunction().

Here is the call graph for this function:

◆ SetLimitedVariable()

virtual bool ROOT::Math::Minimizer::SetLimitedVariable ( unsigned int  ivar,
const std::string &  name,
double  val,
double  step,
double  lower,
double  upper 
)
inlinevirtual

set a new upper/lower limited variable (override if minimizer supports them ) otherwise as default set an unlimited variable

Reimplemented in ROOT::Math::GeneticMinimizer, ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 163 of file Minimizer.h.

164  {
165  MATH_WARN_MSG("Minimizer::SetLimitedVariable","Setting of limited variable not implemented - set as unlimited");
166  MATH_UNUSED(lower); MATH_UNUSED(upper);
167  return SetVariable(ivar, name, val, step);
168  }
#define MATH_WARN_MSG(loc, str)
Definition: Error.h:47
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)=0
set a new free variable

References MATH_UNUSED, MATH_WARN_MSG, and SetVariable().

Referenced by SetLowerLimitedVariable(), MinimizerAdapter::setParameter(), SetUpperLimitedVariable(), and SetVariables().

Here is the call graph for this function:

◆ SetLowerLimitedVariable()

virtual bool ROOT::Math::Minimizer::SetLowerLimitedVariable ( unsigned int  ivar,
const std::string &  name,
double  val,
double  step,
double  lower 
)
inlinevirtual

set a new lower limit variable (override if minimizer supports them )

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 155 of file Minimizer.h.

155  {
156  return SetLimitedVariable(ivar, name, val, step, lower, std::numeric_limits<double>::infinity() );
157  }
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double lower, double upper)
set a new upper/lower limited variable (override if minimizer supports them ) otherwise as default se...
Definition: Minimizer.h:163

References SetLimitedVariable().

Referenced by MinimizerAdapter::setParameter(), and SetVariables().

Here is the call graph for this function:

◆ SetMaxFunctionCalls()

void ROOT::Math::Minimizer::SetMaxFunctionCalls ( unsigned int  maxfcn)
inline

set maximum of function calls

Definition at line 448 of file Minimizer.h.

448 { if (maxfcn > 0) fOptions.SetMaxFunctionCalls(maxfcn); }
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls

References fOptions, and ROOT::Math::MinimizerOptions::SetMaxFunctionCalls().

Here is the call graph for this function:

◆ SetMaxIterations()

void ROOT::Math::Minimizer::SetMaxIterations ( unsigned int  maxiter)
inline

set maximum iterations (one iteration can have many function calls)

Definition at line 451 of file Minimizer.h.

451 { if (maxiter > 0) fOptions.SetMaxIterations(maxiter); }
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)

References fOptions, and ROOT::Math::MinimizerOptions::SetMaxIterations().

Here is the call graph for this function:

◆ SetOptions()

void ROOT::Math::Minimizer::SetOptions ( const MinimizerOptions opt)
inline

set all options in one go

Definition at line 470 of file Minimizer.h.

470  {
471  fOptions = opt;
472  }

References fOptions.

◆ SetPrecision()

void ROOT::Math::Minimizer::SetPrecision ( double  prec)
inline

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)

Definition at line 458 of file Minimizer.h.

458 { fOptions.SetPrecision(prec); }
void SetPrecision(double prec)
set the precision

References fOptions, and ROOT::Math::MinimizerOptions::SetPrecision().

Here is the call graph for this function:

◆ SetPrintLevel()

void ROOT::Math::Minimizer::SetPrintLevel ( int  level)
inline

set print level

Definition at line 445 of file Minimizer.h.

445 { fOptions.SetPrintLevel(level); }
void SetPrintLevel(int level)
set print level

References fOptions, and ROOT::Math::MinimizerOptions::SetPrintLevel().

Here is the call graph for this function:

◆ SetStrategy()

void ROOT::Math::Minimizer::SetStrategy ( int  strategyLevel)
inline

set the strategy

Definition at line 461 of file Minimizer.h.

461 { fOptions.SetStrategy(strategyLevel); }
void SetStrategy(int stra)
set the strategy

References fOptions, and ROOT::Math::MinimizerOptions::SetStrategy().

Here is the call graph for this function:

◆ SetTolerance()

void ROOT::Math::Minimizer::SetTolerance ( double  tol)
inline

set the tolerance

Definition at line 454 of file Minimizer.h.

454 { fOptions.SetTolerance(tol); }
void SetTolerance(double tol)
set the tolerance

References fOptions, and ROOT::Math::MinimizerOptions::SetTolerance().

Here is the call graph for this function:

◆ SetUpperLimitedVariable()

virtual bool ROOT::Math::Minimizer::SetUpperLimitedVariable ( unsigned int  ivar,
const std::string &  name,
double  val,
double  step,
double  upper 
)
inlinevirtual

set a new upper limit variable (override if minimizer supports them )

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 159 of file Minimizer.h.

159  {
160  return SetLimitedVariable(ivar, name, val, step, - std::numeric_limits<double>::infinity(), upper );
161  }

References SetLimitedVariable().

Referenced by MinimizerAdapter::setParameter(), and SetVariables().

Here is the call graph for this function:

◆ SetValidError()

void ROOT::Math::Minimizer::SetValidError ( bool  on)
inline

flag to check if minimizer needs to perform accurate error analysis (e.g. run Hesse for Minuit)

Definition at line 467 of file Minimizer.h.

467 { fValidError = on; }

References fValidError.

◆ SetVariable()

virtual bool ROOT::Math::Minimizer::SetVariable ( unsigned int  ivar,
const std::string &  name,
double  val,
double  step 
)
pure virtual

◆ SetVariableInitialRange()

virtual bool ROOT::Math::Minimizer::SetVariableInitialRange ( unsigned int  ,
double  ,
double   
)
inlinevirtual

set the initial range of an existing variable

Definition at line 240 of file Minimizer.h.

240  {
241  return false;
242  }

◆ SetVariableLimits()

virtual bool ROOT::Math::Minimizer::SetVariableLimits ( unsigned int  ivar,
double  lower,
double  upper 
)
inlinevirtual

set the limits of an already existing variable

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 209 of file Minimizer.h.

209  {
210  return SetVariableLowerLimit(ivar,lower) && SetVariableUpperLimit(ivar,upper);
211  }
virtual bool SetVariableLowerLimit(unsigned int ivar, double lower)
set the lower-limit of an already existing variable
Definition: Minimizer.h:197
virtual bool SetVariableUpperLimit(unsigned int ivar, double upper)
set the upper-limit of an already existing variable
Definition: Minimizer.h:203

References SetVariableLowerLimit(), and SetVariableUpperLimit().

Here is the call graph for this function:

◆ SetVariableLowerLimit()

virtual bool ROOT::Math::Minimizer::SetVariableLowerLimit ( unsigned int  ivar,
double  lower 
)
inlinevirtual

set the lower-limit of an already existing variable

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 197 of file Minimizer.h.

197  {
198  MATH_ERROR_MSG("Minimizer::SetVariableLowerLimit","Setting an existing variable limit not implemented");
199  MATH_UNUSED(ivar); MATH_UNUSED(lower);
200  return false;
201  }

References MATH_ERROR_MSG, and MATH_UNUSED.

Referenced by SetVariableLimits().

◆ SetVariables()

template<class VariableIterator >
int ROOT::Math::Minimizer::SetVariables ( const VariableIterator &  begin,
const VariableIterator &  end 
)
inline

add variables . Return number of variables successfully added

Definition at line 131 of file Minimizer.h.

131  {
132  unsigned int ivar = 0;
133  for ( VariableIterator vitr = begin; vitr != end; ++vitr) {
134  bool iret = false;
135  if (vitr->IsFixed() )
136  iret = SetFixedVariable(ivar, vitr->Name(), vitr->Value() );
137  else if (vitr->IsDoubleBound() )
138  iret = SetLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->LowerLimit(), vitr->UpperLimit() );
139  else if (vitr->HasLowerLimit() )
140  iret = SetLowerLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->LowerLimit() );
141  else if (vitr->HasUpperLimit() )
142  iret = SetUpperLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->UpperLimit() );
143  else
144  iret = SetVariable( ivar, vitr->Name(), vitr->Value(), vitr->StepSize() );
145 
146  if (iret) ivar++;
147 
148  // an error message should be eventually be reported in the virtual single SetVariable methods
149  }
150  return ivar;
151  }
virtual bool SetLowerLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double lower)
set a new lower limit variable (override if minimizer supports them )
Definition: Minimizer.h:155
virtual bool SetUpperLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double upper)
set a new upper limit variable (override if minimizer supports them )
Definition: Minimizer.h:159
virtual bool SetFixedVariable(unsigned int ivar, const std::string &name, double val)
set a new fixed variable (override if minimizer supports them )
Definition: Minimizer.h:170

References SetFixedVariable(), SetLimitedVariable(), SetLowerLimitedVariable(), SetUpperLimitedVariable(), and SetVariable().

Here is the call graph for this function:

◆ SetVariableStepSize()

virtual bool ROOT::Math::Minimizer::SetVariableStepSize ( unsigned int  ivar,
double  value 
)
inlinevirtual

set the step size of an already existing variable

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 191 of file Minimizer.h.

191  {
192  MATH_ERROR_MSG("Minimizer::SetVariableStepSize","Setting an existing variable step size not implemented");
193  MATH_UNUSED(ivar); MATH_UNUSED(value);
194  return false;
195  }

References MATH_ERROR_MSG, and MATH_UNUSED.

◆ SetVariableUpperLimit()

virtual bool ROOT::Math::Minimizer::SetVariableUpperLimit ( unsigned int  ivar,
double  upper 
)
inlinevirtual

set the upper-limit of an already existing variable

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 203 of file Minimizer.h.

203  {
204  MATH_ERROR_MSG("Minimizer::SetVariableUpperLimit","Setting an existing variable limit not implemented");
205  MATH_UNUSED(ivar); MATH_UNUSED(upper);
206  return false;
207  }

References MATH_ERROR_MSG, and MATH_UNUSED.

Referenced by SetVariableLimits().

◆ SetVariableValue()

virtual bool ROOT::Math::Minimizer::SetVariableValue ( unsigned int  ivar,
double  value 
)
inlinevirtual

set the value of an already existing variable

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 176 of file Minimizer.h.

176  {
177  MATH_ERROR_MSG("Minimizer::SetVariableValue","Set of a variable value not implemented");
178  MATH_UNUSED(ivar); MATH_UNUSED(value);
179  return false;
180  }

References MATH_ERROR_MSG, and MATH_UNUSED.

Referenced by SetVariableValues().

◆ SetVariableValues()

virtual bool ROOT::Math::Minimizer::SetVariableValues ( const double *  x)
inlinevirtual

set the values of all existing variables (array must be dimensioned to the size of the existing parameters)

Reimplemented in ROOT::Math::BasicMinimizer, and ROOT::Minuit2::Minuit2Minimizer.

Definition at line 182 of file Minimizer.h.

182  {
183  bool ret = true;
184  unsigned int i = 0;
185  while ( i <= NDim() && ret) {
186  ret &= SetVariableValue(i,x[i] ); i++;
187  }
188  return ret;
189  }
virtual bool SetVariableValue(unsigned int ivar, double value)
set the value of an already existing variable
Definition: Minimizer.h:176

References NDim(), and SetVariableValue().

Here is the call graph for this function:

◆ Status()

int ROOT::Math::Minimizer::Status ( ) const
inline

status code of minimizer

Definition at line 430 of file Minimizer.h.

430 { return fStatus; }

References fStatus.

Referenced by GeneticMinimizer::statusToString(), and Minuit2Minimizer::statusToString().

◆ Strategy()

int ROOT::Math::Minimizer::Strategy ( ) const
inline

strategy

Definition at line 427 of file Minimizer.h.

427 { return fOptions.Strategy(); }
int Strategy() const
strategy

References fOptions, and ROOT::Math::MinimizerOptions::Strategy().

Here is the call graph for this function:

◆ Tolerance()

double ROOT::Math::Minimizer::Tolerance ( ) const
inline

absolute tolerance

Definition at line 420 of file Minimizer.h.

420 { return fOptions.Tolerance(); }
double Tolerance() const
absolute tolerance

References fOptions, and ROOT::Math::MinimizerOptions::Tolerance().

Here is the call graph for this function:

◆ VariableIndex()

virtual int ROOT::Math::Minimizer::VariableIndex ( const std::string &  name) const
inlinevirtual

get index of variable given a variable given a name return -1 if variable is not found

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 402 of file Minimizer.h.

402  {
403  MATH_ERROR_MSG("Minimizer::VariableIndex","Getting variable index from name not implemented");
404  MATH_UNUSED(name);
405  return -1;
406  }

References MATH_ERROR_MSG, and MATH_UNUSED.

◆ VariableName()

virtual std::string ROOT::Math::Minimizer::VariableName ( unsigned int  ivar) const
inlinevirtual

get name of variables (override if minimizer support storing of variable names) return an empty string if variable is not found

Reimplemented in ROOT::Minuit2::Minuit2Minimizer, and ROOT::Math::BasicMinimizer.

Definition at line 395 of file Minimizer.h.

395  {
396  MATH_UNUSED(ivar);
397  return std::string(); // return empty string
398  }

References MATH_UNUSED.

◆ X()

virtual const double* ROOT::Math::Minimizer::X ( ) const
pure virtual

return pointer to X values at the minimum

Implemented in ROOT::Minuit2::Minuit2Minimizer, ROOT::Math::GeneticMinimizer, and ROOT::Math::BasicMinimizer.

Member Data Documentation

◆ fOptions

◆ fStatus

int ROOT::Math::Minimizer::fStatus
protected

Definition at line 490 of file Minimizer.h.

Referenced by Status().

◆ fValidError

bool ROOT::Math::Minimizer::fValidError
protected

Definition at line 488 of file Minimizer.h.

Referenced by IsValidError(), and SetValidError().


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