13#ifndef ROOT_Math_Minimizer
14#define ROOT_Math_Minimizer
33 class ParameterSettings;
107 if (
this == &rhs)
return *
this;
127 template<
class VariableIterator>
128 int SetVariables(
const VariableIterator & begin,
const VariableIterator & end) {
129 unsigned int ivar = 0;
130 for ( VariableIterator vitr = begin; vitr != end; ++vitr) {
132 if (vitr->IsFixed() )
134 else if (vitr->IsDoubleBound() )
135 iret =
SetLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->LowerLimit(), vitr->UpperLimit() );
136 else if (vitr->HasLowerLimit() )
138 else if (vitr->HasUpperLimit() )
141 iret =
SetVariable( ivar, vitr->Name(), vitr->Value(), vitr->StepSize() );
150 virtual bool SetVariable(
unsigned int ivar,
const std::string &
name,
double val,
double step) = 0;
161 double lower ,
double upper ) {
162 MATH_WARN_MSG(
"Minimizer::SetLimitedVariable",
"Setting of limited variable not implemented - set as unlimited");
168 MATH_ERROR_MSG(
"Minimizer::SetFixedVariable",
"Setting of fixed variable not implemented");
174 MATH_ERROR_MSG(
"Minimizer::SetVariableValue",
"Set of a variable value not implemented");
182 while ( i <=
NDim() && ret) {
189 MATH_ERROR_MSG(
"Minimizer::SetVariableStepSize",
"Setting an existing variable step size not implemented");
195 MATH_ERROR_MSG(
"Minimizer::SetVariableLowerLimit",
"Setting an existing variable limit not implemented");
201 MATH_ERROR_MSG(
"Minimizer::SetVariableUpperLimit",
"Setting an existing variable limit not implemented");
211 MATH_ERROR_MSG(
"Minimizer::FixVariable",
"Fixing an existing variable not implemented");
217 MATH_ERROR_MSG(
"Minimizer::ReleaseVariable",
"Releasing an existing variable not implemented");
224 MATH_ERROR_MSG(
"Minimizer::IsFixedVariable",
"Quering an existing variable not implemented");
230 MATH_ERROR_MSG(
"Minimizer::GetVariableSettings",
"Quering an existing variable not implemented");
248 virtual const double *
X()
const = 0;
251 virtual double Edm()
const {
return -1; }
257 virtual unsigned int NCalls()
const {
return 0; }
264 virtual unsigned int NDim()
const = 0;
275 virtual const double *
Errors()
const {
return NULL; }
281 virtual double CovMatrix(
unsigned int ivar ,
unsigned int jvar )
const {
323 virtual double Correlation(
unsigned int i,
unsigned int j )
const {
325 return ( tmp < 0) ? 0 :
CovMatrix(i,j) / std::sqrt( tmp );
345 virtual bool GetMinosError(
unsigned int ivar ,
double & errLow,
double & errUp,
int option = 0) {
346 MATH_ERROR_MSG(
"Minimizer::GetMinosError",
"Minos Error not implemented");
363 virtual bool Scan(
unsigned int ivar ,
unsigned int & nstep ,
double *
x ,
double *
y ,
375 virtual bool Contour(
unsigned int ivar ,
unsigned int jvar,
unsigned int & npoints,
376 double * xi ,
double * xj ) {
393 return std::string();
399 MATH_ERROR_MSG(
"Minimizer::VariableIndex",
"Getting variable index from name not implemented");
#define MATH_ERROR_MSG(loc, str)
#define MATH_WARN_MSG(loc, str)
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
Documentation for the abstract class IBaseFunctionMultiDim.
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Generic interface for defining configuration options of a numerical algorithm.
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
void SetStrategy(int stra)
set the strategy
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
int Strategy() const
strategy
double Tolerance() const
absolute tolerance
double Precision() const
precision in the objective funciton calculation (value <=0 means left to default)
double ErrorDef() const
error definition
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
unsigned int MaxIterations() const
max iterations
void SetPrecision(double prec)
set the precision
unsigned int MaxFunctionCalls() const
max number of function calls
void ResetToDefaultOptions()
non-static methods for setting options
int PrintLevel() const
non-static methods for retrieving options
void SetErrorDef(double err)
set error def
void SetPrintLevel(int level)
set print level
void SetTolerance(double tol)
set the tolerance
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
double Tolerance() const
absolute tolerance
virtual const double * Errors() const
return errors at the minimum
virtual bool GetCovMatrix(double *covMat) const
Fill the passed array with the covariance matrix elements if the variable is fixed or const the value...
unsigned int MaxFunctionCalls() const
max number of function calls
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
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 )
double Precision() const
precision of minimizer in the evaluation of the objective function ( a value <=0 corresponds to the l...
virtual const double * X() const =0
return pointer to X values at the minimum
virtual bool FixVariable(unsigned int ivar)
fix an existing variable
virtual unsigned int NIterations() const
number of iterations to reach the minimum
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
virtual void SetFunction(const ROOT::Math::IMultiGradFunction &func)
set a function to minimize using gradient
virtual bool SetVariableStepSize(unsigned int ivar, double value)
set the step size of an already existing variable
virtual bool SetVariableInitialRange(unsigned int, double, double)
set the initial range of an existing variable
void SetErrorDef(double up)
set scale for calculating the errors
virtual bool ReleaseVariable(unsigned int ivar)
release an existing variable
virtual bool SetVariableLowerLimit(unsigned int ivar, double lower)
set the lower-limit of an already existing variable
void SetValidError(bool on)
flag to check if minimizer needs to perform accurate error analysis (e.g. run Hesse for Minuit)
int SetVariables(const VariableIterator &begin, const VariableIterator &end)
add variables . Return number of variables successfully added
virtual const double * MinGradient() const
return pointer to gradient values at the minimum
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)=0
set the function to minimize
unsigned int MaxIterations() const
max iterations
void SetDefaultOptions()
reset the defaut options (defined in MinimizerOptions)
virtual bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings &pars) const
get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
virtual double GlobalCC(unsigned int ivar) const
return global correlation coefficient for variable i This is a number between zero and one which give...
virtual int MinosStatus() const
status code of Minos (to be re-implemented by the minimizers supporting Minos)
virtual bool SetVariableUpperLimit(unsigned int ivar, double upper)
set the upper-limit of an already existing variable
virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper)
set the limits of an already existing variable
void SetTolerance(double tol)
set the tolerance
virtual int CovMatrixStatus() const
return status of covariance matrix using Minuit convention {0 not calculated 1 approximated 2 made po...
virtual bool Minimize()=0
method to perform the minimization
int Status() const
status code of minimizer
Minimizer(const Minimizer &)
Copy constructor.
Minimizer()
Default constructor.
virtual 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 ...
void SetPrintLevel(int level)
set print level
int Strategy() const
strategy
virtual unsigned int NCalls() const
number of function calls to reach the minimum
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 )
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)=0
set a new free variable
void SetStrategy(int strategyLevel)
set the strategy
virtual bool ProvidesError() const
minimizer provides error and error matrix
virtual bool IsFixedVariable(unsigned int ivar) const
query if an existing variable is fixed (i.e.
Minimizer & operator=(const Minimizer &rhs)
Assignment operator.
void SetPrecision(double prec)
set in the minimizer the objective function evaluation precision ( a value <=0 means the minimizer wi...
virtual MinimizerOptions Options() const
retrieve the minimizer options (implement derived class if needed)
virtual double Correlation(unsigned int i, unsigned int j) const
return correlation coefficient between variable i and j.
virtual ~Minimizer()
Destructor (no operations)
virtual std::string VariableName(unsigned int ivar) const
get name of variables (override if minimizer support storing of variable names) return an empty strin...
double ErrorDef() const
return the statistical scale used for calculate the error is typically 1 for Chi2 and 0....
MinimizerOptions fOptions
virtual bool SetFixedVariable(unsigned int ivar, const std::string &name, double val)
set a new fixed variable (override if minimizer supports them )
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
bool IsValidError() const
return true if Minimizer has performed a detailed error validation (e.g. run Hesse for Minuit)
virtual 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 c...
virtual double Edm() const
return expected distance reached from the minimum (re-implement if minimizer provides it
void SetOptions(const MinimizerOptions &opt)
set all options in one go
virtual bool SetVariableValues(const double *x)
set the values of all existing variables (array must be dimensioned to the size of the existing param...
virtual bool Scan(unsigned int ivar, unsigned int &nstep, double *x, double *y, double xmin=0, double xmax=0)
scan function minimum for variable i.
virtual bool SetVariableValue(unsigned int ivar, double value)
set the value of an already existing variable
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...
virtual void Clear()
reset for consecutive minimizations - implement if needed
void SetExtraOptions(const IOptions &extraOptions)
set only the extra options
virtual double MinValue() const =0
return minimum function value
int PrintLevel() const
minimizer configuration parameters
virtual bool Hesse()
perform a full calculation of the Hessian matrix for error calculation
virtual void PrintResults()
return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const ...
virtual unsigned int NDim() const =0
this is <= Function().NDim() which is the total number of variables (free+ constrained ones)
virtual unsigned int NFree() const
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the to...
virtual 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 err...
virtual bool GetHessianMatrix(double *hMat) const
Fill the passed array with the Hessian matrix elements The Hessian matrix is the matrix of the second...
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...