Logo ROOT  
Reference Guide
Minimizer.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Author: L. Moneta Fri Sep 22 15:06:47 2006
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header file for class Minimizer
12 
13 #ifndef ROOT_Math_Minimizer
14 #define ROOT_Math_Minimizer
15 
16 #include "Math/IFunction.h"
17 
18 #include "Math/MinimizerOptions.h"
19 
20 #include "Math/Util.h"
21 
22 #include "Math/Error.h"
23 
24 
25 #include <string>
26 #include <limits>
27 #include <cmath>
28 
29 
30 namespace ROOT {
31 
32  namespace Fit {
33  class ParameterSettings;
34  }
35 
36 
37  namespace Math {
38 
39 /**
40  @defgroup MultiMin Multi-dimensional Minimization
41  @ingroup NumAlgo
42 
43  Classes implementing algorithms for multi-dimensional minimization
44  */
45 
46 
47 
48 //_______________________________________________________________________________
49 /**
50  Abstract Minimizer class, defining the interface for the various minimizer
51  (like Minuit2, Minuit, GSL, etc..)
52  Plug-in's exist in ROOT to be able to instantiate the derived classes like
53  ROOT::Math::GSLMinimizer or ROOT::Math::Minuit2Minimizer via the
54  plug-in manager.
55 
56  Provides interface for setting the function to be minimized.
57  The function must implemente the multi-dimensional generic interface
58  ROOT::Math::IBaseFunctionMultiDim.
59  If the function provides gradient calculation
60  (implements the ROOT::Math::IGradientFunctionMultiDim interface) this will be
61  used by the Minimizer.
62 
63  It Defines also interface for setting the initial values for the function variables (which are the parameters in
64  of the model function in case of solving for fitting) and especifying their limits.
65 
66  It defines the interface to set and retrieve basic minimization parameters
67  (for specific Minimizer parameters one must use the derived classes).
68 
69  Then it defines the interface to retrieve the result of minimization ( minimum X values, function value,
70  gradient, error on the mimnimum, etc...)
71 
72  @ingroup MultiMin
73 */
74 
75 class Minimizer {
76 
77 public:
78 
79  /**
80  Default constructor
81  */
82  Minimizer () :
83  fValidError(false),
84  fStatus(-1)
85  {}
86 
87  /**
88  Destructor (no operations)
89  */
90  virtual ~Minimizer () {}
91 
92 
93 
94 
95 private:
96  // usually copying is non trivial, so we make this unaccessible
97 
98  /**
99  Copy constructor
100  */
101  Minimizer(const Minimizer &) {}
102 
103  /**
104  Assignment operator
105  */
106  Minimizer & operator = (const Minimizer & rhs) {
107  if (this == &rhs) return *this; // time saving self-test
108  return *this;
109  }
110 
111 public:
112 
113  /// reset for consecutive minimizations - implement if needed
114  virtual void Clear() {}
115 
116  /// set the function to minimize
117  virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func) = 0;
118 
119  /// set a function to minimize using gradient
120  virtual void SetFunction(const ROOT::Math::IMultiGradFunction & func)
121  {
122  SetFunction(static_cast<const ::ROOT::Math::IMultiGenFunction &> (func));
123  }
124 
125 
126  /// add variables . Return number of variables successfully added
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) {
131  bool iret = false;
132  if (vitr->IsFixed() )
133  iret = SetFixedVariable(ivar, vitr->Name(), vitr->Value() );
134  else if (vitr->IsDoubleBound() )
135  iret = SetLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->LowerLimit(), vitr->UpperLimit() );
136  else if (vitr->HasLowerLimit() )
137  iret = SetLowerLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->LowerLimit() );
138  else if (vitr->HasUpperLimit() )
139  iret = SetUpperLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->UpperLimit() );
140  else
141  iret = SetVariable( ivar, vitr->Name(), vitr->Value(), vitr->StepSize() );
142 
143  if (iret) ivar++;
144 
145  // an error message should be eventually be reported in the virtual single SetVariable methods
146  }
147  return ivar;
148  }
149  /// set a new free variable
150  virtual bool SetVariable(unsigned int ivar, const std::string & name, double val, double step) = 0;
151  /// set a new lower limit variable (override if minimizer supports them )
152  virtual bool SetLowerLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double lower ) {
153  return SetLimitedVariable(ivar, name, val, step, lower, std::numeric_limits<double>::infinity() );
154  }
155  /// set a new upper limit variable (override if minimizer supports them )
156  virtual bool SetUpperLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double upper ) {
157  return SetLimitedVariable(ivar, name, val, step, - std::numeric_limits<double>::infinity(), upper );
158  }
159  /// set a new upper/lower limited variable (override if minimizer supports them ) otherwise as default set an unlimited variable
160  virtual bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step ,
161  double lower , double upper ) {
162  MATH_WARN_MSG("Minimizer::SetLimitedVariable","Setting of limited variable not implemented - set as unlimited");
163  MATH_UNUSED(lower); MATH_UNUSED(upper);
164  return SetVariable(ivar, name, val, step);
165  }
166  /// set a new fixed variable (override if minimizer supports them )
167  virtual bool SetFixedVariable(unsigned int ivar , const std::string & name , double val ) {
168  MATH_ERROR_MSG("Minimizer::SetFixedVariable","Setting of fixed variable not implemented");
169  MATH_UNUSED(ivar); MATH_UNUSED(name); MATH_UNUSED(val);
170  return false;
171  }
172  /// set the value of an already existing variable
173  virtual bool SetVariableValue(unsigned int ivar , double value) {
174  MATH_ERROR_MSG("Minimizer::SetVariableValue","Set of a variable value not implemented");
175  MATH_UNUSED(ivar); MATH_UNUSED(value);
176  return false;
177  }
178  /// set the values of all existing variables (array must be dimensioned to the size of the existing parameters)
179  virtual bool SetVariableValues(const double * x) {
180  bool ret = true;
181  unsigned int i = 0;
182  while ( i <= NDim() && ret) {
183  ret &= SetVariableValue(i,x[i] ); i++;
184  }
185  return ret;
186  }
187  /// set the step size of an already existing variable
188  virtual bool SetVariableStepSize(unsigned int ivar, double value ) {
189  MATH_ERROR_MSG("Minimizer::SetVariableStepSize","Setting an existing variable step size not implemented");
190  MATH_UNUSED(ivar); MATH_UNUSED(value);
191  return false;
192  }
193  /// set the lower-limit of an already existing variable
194  virtual bool SetVariableLowerLimit(unsigned int ivar, double lower) {
195  MATH_ERROR_MSG("Minimizer::SetVariableLowerLimit","Setting an existing variable limit not implemented");
196  MATH_UNUSED(ivar); MATH_UNUSED(lower);
197  return false;
198  }
199  /// set the upper-limit of an already existing variable
200  virtual bool SetVariableUpperLimit(unsigned int ivar, double upper) {
201  MATH_ERROR_MSG("Minimizer::SetVariableUpperLimit","Setting an existing variable limit not implemented");
202  MATH_UNUSED(ivar); MATH_UNUSED(upper);
203  return false;
204  }
205  /// set the limits of an already existing variable
206  virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper) {
207  return SetVariableLowerLimit(ivar,lower) && SetVariableUpperLimit(ivar,upper);
208  }
209  /// fix an existing variable
210  virtual bool FixVariable(unsigned int ivar) {
211  MATH_ERROR_MSG("Minimizer::FixVariable","Fixing an existing variable not implemented");
212  MATH_UNUSED(ivar);
213  return false;
214  }
215  /// release an existing variable
216  virtual bool ReleaseVariable(unsigned int ivar) {
217  MATH_ERROR_MSG("Minimizer::ReleaseVariable","Releasing an existing variable not implemented");
218  MATH_UNUSED(ivar);
219  return false;
220  }
221  /// query if an existing variable is fixed (i.e. considered constant in the minimization)
222  /// note that by default all variables are not fixed
223  virtual bool IsFixedVariable(unsigned int ivar) const {
224  MATH_ERROR_MSG("Minimizer::IsFixedVariable","Quering an existing variable not implemented");
225  MATH_UNUSED(ivar);
226  return false;
227  }
228  /// get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
229  virtual bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings & pars) const {
230  MATH_ERROR_MSG("Minimizer::GetVariableSettings","Quering an existing variable not implemented");
231  MATH_UNUSED(ivar); MATH_UNUSED(pars);
232  return false;
233  }
234 
235 
236  /// set the initial range of an existing variable
237  virtual bool SetVariableInitialRange(unsigned int /* ivar */, double /* mininitial */, double /* maxinitial */) {
238  return false;
239  }
240 
241  /// method to perform the minimization
242  virtual bool Minimize() = 0;
243 
244  /// return minimum function value
245  virtual double MinValue() const = 0;
246 
247  /// return pointer to X values at the minimum
248  virtual const double * X() const = 0;
249 
250  /// return expected distance reached from the minimum (re-implement if minimizer provides it
251  virtual double Edm() const { return -1; }
252 
253  /// return pointer to gradient values at the minimum
254  virtual const double * MinGradient() const { return NULL; }
255 
256  /// number of function calls to reach the minimum
257  virtual unsigned int NCalls() const { return 0; }
258 
259  /// number of iterations to reach the minimum
260  virtual unsigned int NIterations() const { return NCalls(); }
261 
262  /// this is <= Function().NDim() which is the total
263  /// number of variables (free+ constrained ones)
264  virtual unsigned int NDim() const = 0;
265 
266  /// number of free variables (real dimension of the problem)
267  /// this is <= Function().NDim() which is the total
268  /// (re-implement if minimizer supports bounded parameters)
269  virtual unsigned int NFree() const { return NDim(); }
270 
271  /// minimizer provides error and error matrix
272  virtual bool ProvidesError() const { return false; }
273 
274  /// return errors at the minimum
275  virtual const double * Errors() const { return NULL; }
276 
277  /** return covariance matrices element for variables ivar,jvar
278  if the variable is fixed the return value is zero
279  The ordering of the variables is the same as in the parameter and errors vectors
280  */
281  virtual double CovMatrix(unsigned int ivar , unsigned int jvar ) const {
282  MATH_UNUSED(ivar); MATH_UNUSED(jvar);
283  return 0;
284  }
285 
286  /**
287  Fill the passed array with the covariance matrix elements
288  if the variable is fixed or const the value is zero.
289  The array will be filled as cov[i *ndim + j]
290  The ordering of the variables is the same as in errors and parameter value.
291  This is different from the direct interface of Minuit2 or TMinuit where the
292  values were obtained only to variable parameters
293  */
294  virtual bool GetCovMatrix(double * covMat) const {
295  MATH_UNUSED(covMat);
296  return false;
297  }
298 
299  /**
300  Fill the passed array with the Hessian matrix elements
301  The Hessian matrix is the matrix of the second derivatives
302  and is the inverse of the covariance matrix
303  If the variable is fixed or const the values for that variables are zero.
304  The array will be filled as h[i *ndim + j]
305  */
306  virtual bool GetHessianMatrix(double * hMat) const {
307  MATH_UNUSED(hMat);
308  return false;
309  }
310 
311 
312  ///return status of covariance matrix
313  /// using Minuit convention {0 not calculated 1 approximated 2 made pos def , 3 accurate}
314  /// Minimizer who implements covariance matrix calculation will re-implement the method
315  virtual int CovMatrixStatus() const {
316  return 0;
317  }
318 
319  /**
320  return correlation coefficient between variable i and j.
321  If the variable is fixed or const the return value is zero
322  */
323  virtual double Correlation(unsigned int i, unsigned int j ) const {
324  double tmp = CovMatrix(i,i) * CovMatrix(j,j);
325  return ( tmp < 0) ? 0 : CovMatrix(i,j) / std::sqrt( tmp );
326  }
327 
328  /**
329  return global correlation coefficient for variable i
330  This is a number between zero and one which gives
331  the correlation between the i-th parameter and that linear combination of all
332  other parameters which is most strongly correlated with i.
333  Minimizer must overload method if implemented
334  */
335  virtual double GlobalCC(unsigned int ivar) const {
336  MATH_UNUSED(ivar);
337  return -1;
338  }
339 
340  /**
341  minos error for variable i, return false if Minos failed or not supported
342  and the lower and upper errors are returned in errLow and errUp
343  An extra flag specifies if only the lower (option=-1) or the upper (option=+1) error calculation is run
344  (This feature is not yet implemented)
345  */
346  virtual bool GetMinosError(unsigned int ivar , double & errLow, double & errUp, int option = 0) {
347  MATH_ERROR_MSG("Minimizer::GetMinosError","Minos Error not implemented");
348  MATH_UNUSED(ivar); MATH_UNUSED(errLow); MATH_UNUSED(errUp); MATH_UNUSED(option);
349  return false;
350  }
351 
352  /**
353  perform a full calculation of the Hessian matrix for error calculation
354  */
355  virtual bool Hesse() {
356  MATH_ERROR_MSG("Minimizer::Hesse","Hesse not implemented");
357  return false;
358  }
359 
360  /**
361  scan function minimum for variable i. Variable and function must be set before using Scan
362  Return false if an error or if minimizer does not support this functionality
363  */
364  virtual bool Scan(unsigned int ivar , unsigned int & nstep , double * x , double * y ,
365  double xmin = 0, double xmax = 0) {
366  MATH_ERROR_MSG("Minimizer::Scan","Scan not implemented");
367  MATH_UNUSED(ivar); MATH_UNUSED(nstep); MATH_UNUSED(x); MATH_UNUSED(y);
369  return false;
370  }
371 
372  /**
373  find the contour points (xi, xj) of the function for parameter ivar and jvar around the minimum
374  The contour will be find for value of the function = Min + ErrorUp();
375  */
376  virtual bool Contour(unsigned int ivar , unsigned int jvar, unsigned int & npoints,
377  double * xi , double * xj ) {
378  MATH_ERROR_MSG("Minimizer::Contour","Contour not implemented");
379  MATH_UNUSED(ivar); MATH_UNUSED(jvar); MATH_UNUSED(npoints);
380  MATH_UNUSED(xi); MATH_UNUSED(xj);
381  return false;
382  }
383 
384  /// return reference to the objective function
385  ///virtual const ROOT::Math::IGenFunction & Function() const = 0;
386 
387  /// print the result according to set level (implemented for TMinuit for mantaining Minuit-style printing)
388  virtual void PrintResults() {}
389 
390  /// get name of variables (override if minimizer support storing of variable names)
391  /// return an empty string if variable is not found
392  virtual std::string VariableName(unsigned int ivar) const {
393  MATH_UNUSED(ivar);
394  return std::string(); // return empty string
395  }
396 
397  /// get index of variable given a variable given a name
398  /// return -1 if variable is not found
399  virtual int VariableIndex(const std::string & name) const {
400  MATH_ERROR_MSG("Minimizer::VariableIndex","Getting variable index from name not implemented");
401  MATH_UNUSED(name);
402  return -1;
403  }
404 
405  /** minimizer configuration parameters **/
406 
407  /// set print level
408  int PrintLevel() const { return fOptions.PrintLevel(); }
409 
410  /// max number of function calls
411  unsigned int MaxFunctionCalls() const { return fOptions.MaxFunctionCalls(); }
412 
413  /// max iterations
414  unsigned int MaxIterations() const { return fOptions.MaxIterations(); }
415 
416  /// absolute tolerance
417  double Tolerance() const { return fOptions.Tolerance(); }
418 
419  /// precision of minimizer in the evaluation of the objective function
420  /// ( a value <=0 corresponds to the let the minimizer choose its default one)
421  double Precision() const { return fOptions.Precision(); }
422 
423  /// strategy
424  int Strategy() const { return fOptions.Strategy(); }
425 
426  /// status code of minimizer
427  int Status() const { return fStatus; }
428 
429  /// return the statistical scale used for calculate the error
430  /// is typically 1 for Chi2 and 0.5 for likelihood minimization
431  double ErrorDef() const { return fOptions.ErrorDef(); }
432 
433  ///return true if Minimizer has performed a detailed error validation (e.g. run Hesse for Minuit)
434  bool IsValidError() const { return fValidError; }
435 
436  /// retrieve the minimizer options (implement derived class if needed)
437  virtual MinimizerOptions Options() const {
438  return fOptions;
439  }
440 
441  /// set print level
442  void SetPrintLevel(int level) { fOptions.SetPrintLevel(level); }
443 
444  ///set maximum of function calls
445  void SetMaxFunctionCalls(unsigned int maxfcn) { if (maxfcn > 0) fOptions.SetMaxFunctionCalls(maxfcn); }
446 
447  /// set maximum iterations (one iteration can have many function calls)
448  void SetMaxIterations(unsigned int maxiter) { if (maxiter > 0) fOptions.SetMaxIterations(maxiter); }
449 
450  /// set the tolerance
451  void SetTolerance(double tol) { fOptions.SetTolerance(tol); }
452 
453  /// set in the minimizer the objective function evaluation precision
454  /// ( a value <=0 means the minimizer will choose its optimal value automatically, i.e. default case)
455  void SetPrecision(double prec) { fOptions.SetPrecision(prec); }
456 
457  ///set the strategy
458  void SetStrategy(int strategyLevel) { fOptions.SetStrategy(strategyLevel); }
459 
460  /// set scale for calculating the errors
461  void SetErrorDef(double up) { fOptions.SetErrorDef(up); }
462 
463  /// flag to check if minimizer needs to perform accurate error analysis (e.g. run Hesse for Minuit)
464  void SetValidError(bool on) { fValidError = on; }
465 
466  /// set all options in one go
467  void SetOptions(const MinimizerOptions & opt) {
468  fOptions = opt;
469  }
470 
471  /// reset the defaut options (defined in MinimizerOptions)
474  }
475 
476 protected:
477 
478 
479 //private:
480 
481 
482  // keep protected to be accessible by the derived classes
483 
484 
485  bool fValidError; // flag to control if errors have been validated (Hesse has been run in case of Minuit)
486  MinimizerOptions fOptions; // minimizer options
487  int fStatus; // status of minimizer
488 };
489 
490  } // end namespace Math
491 
492 } // end namespace ROOT
493 
494 
495 #endif /* ROOT_Math_Minimizer */
Util.h
ROOT::Math::MinimizerOptions::SetPrecision
void SetPrecision(double prec)
set the precision
Definition: MinimizerOptions.h:143
ROOT::Math::Minimizer::SetLimitedVariable
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:165
HFit::Fit
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:133
ROOT::Math::Minimizer::Contour
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...
Definition: Minimizer.h:381
ROOT::Math::Minimizer::ProvidesError
virtual bool ProvidesError() const
minimizer provides error and error matrix
Definition: Minimizer.h:277
IFunction.h
ROOT::Math::Minimizer::X
virtual const double * X() const =0
return pointer to X values at the minimum
MATH_UNUSED
#define MATH_UNUSED(var)
Definition: Util.h:34
ROOT::Math::Minimizer::NIterations
virtual unsigned int NIterations() const
number of iterations to reach the minimum
Definition: Minimizer.h:265
ROOT::Math::Minimizer::ReleaseVariable
virtual bool ReleaseVariable(unsigned int ivar)
release an existing variable
Definition: Minimizer.h:221
ROOT::Math::Minimizer::Strategy
int Strategy() const
strategy
Definition: Minimizer.h:429
ROOT::Math::Minimizer::PrintLevel
int PrintLevel() const
minimizer configuration parameters
Definition: Minimizer.h:413
ROOT::Math::Minimizer::Minimize
virtual bool Minimize()=0
method to perform the minimization
ROOT::Math::Minimizer::ErrorDef
double ErrorDef() const
return the statistical scale used for calculate the error is typically 1 for Chi2 and 0....
Definition: Minimizer.h:436
xmax
float xmax
Definition: THbookFile.cxx:95
ROOT::Math::Minimizer::SetErrorDef
void SetErrorDef(double up)
set scale for calculating the errors
Definition: Minimizer.h:466
ROOT::Math::Minimizer::MaxIterations
unsigned int MaxIterations() const
max iterations
Definition: Minimizer.h:419
ROOT::Math::Minimizer::SetMaxIterations
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
Definition: Minimizer.h:453
ROOT::Math::Minimizer::SetPrintLevel
void SetPrintLevel(int level)
set print level
Definition: Minimizer.h:447
ROOT::Math::Minimizer::Options
virtual MinimizerOptions Options() const
retrieve the minimizer options (implement derived class if needed)
Definition: Minimizer.h:442
ROOT::Math::Minimizer::NFree
virtual unsigned int NFree() const
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the to...
Definition: Minimizer.h:274
x
Double_t x[n]
Definition: legend1.C:17
ROOT::Math::IGradientFunctionMultiDimTempl
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition: IFunction.h:326
ROOT::Math::Minimizer::SetVariables
int SetVariables(const VariableIterator &begin, const VariableIterator &end)
add variables . Return number of variables successfully added
Definition: Minimizer.h:133
ROOT::Math::Minimizer::MaxFunctionCalls
unsigned int MaxFunctionCalls() const
max number of function calls
Definition: Minimizer.h:416
ROOT::Math::Minimizer::SetDefaultOptions
void SetDefaultOptions()
reset the defaut options (defined in MinimizerOptions)
Definition: Minimizer.h:477
ROOT::Math::Minimizer::fValidError
bool fValidError
Definition: Minimizer.h:490
MATH_ERROR_MSG
#define MATH_ERROR_MSG(loc, str)
Definition: Error.h:83
MinimizerOptions.h
ROOT::Math::Minimizer::MinValue
virtual double MinValue() const =0
return minimum function value
ROOT::Math::MinimizerOptions::MaxFunctionCalls
unsigned int MaxFunctionCalls() const
max number of function calls
Definition: MinimizerOptions.h:98
ROOT::Math::Minimizer::Minimizer
Minimizer()
Default constructor.
Definition: Minimizer.h:87
ROOT::Math::MinimizerOptions::SetPrintLevel
void SetPrintLevel(int level)
set print level
Definition: MinimizerOptions.h:131
ROOT::Math::Minimizer::Errors
virtual const double * Errors() const
return errors at the minimum
Definition: Minimizer.h:280
ROOT::Math::Minimizer::NCalls
virtual unsigned int NCalls() const
number of function calls to reach the minimum
Definition: Minimizer.h:262
ROOT::Math::Minimizer::CovMatrix
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 ...
Definition: Minimizer.h:286
ROOT::Math::Minimizer::operator=
Minimizer & operator=(const Minimizer &rhs)
Assignment operator.
Definition: Minimizer.h:111
ROOT::Math::MinimizerOptions::Precision
double Precision() const
precision in the objective funciton calculation (value <=0 means left to default)
Definition: MinimizerOptions.h:110
ROOT::Math::Minimizer::SetStrategy
void SetStrategy(int strategyLevel)
set the strategy
Definition: Minimizer.h:463
MATH_WARN_MSG
#define MATH_WARN_MSG(loc, str)
Definition: Error.h:80
ROOT::Math::MinimizerOptions::SetErrorDef
void SetErrorDef(double err)
set error def
Definition: MinimizerOptions.h:149
ROOT::Math::Minimizer::SetVariableUpperLimit
virtual bool SetVariableUpperLimit(unsigned int ivar, double upper)
set the upper-limit of an already existing variable
Definition: Minimizer.h:205
ROOT::Math::Minimizer::GetHessianMatrix
virtual bool GetHessianMatrix(double *hMat) const
Fill the passed array with the Hessian matrix elements The Hessian matrix is the matrix of the second...
Definition: Minimizer.h:311
ROOT::Math::Minimizer::SetOptions
void SetOptions(const MinimizerOptions &opt)
set all options in one go
Definition: Minimizer.h:472
ROOT::Math::Minimizer::GetMinosError
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...
Definition: Minimizer.h:351
ROOT::Math::MinimizerOptions::ResetToDefaultOptions
void ResetToDefaultOptions()
non-static methods for setting options
Definition: MinimizerOptions.cxx:172
ROOT::Math::MinimizerOptions::SetMaxFunctionCalls
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
Definition: MinimizerOptions.h:134
ROOT::Math::Minimizer::SetVariableLowerLimit
virtual bool SetVariableLowerLimit(unsigned int ivar, double lower)
set the lower-limit of an already existing variable
Definition: Minimizer.h:199
xmin
float xmin
Definition: THbookFile.cxx:95
ROOT::Math::Minimizer::fOptions
MinimizerOptions fOptions
Definition: Minimizer.h:491
ROOT::Math::Minimizer::PrintResults
virtual void PrintResults()
return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const ...
Definition: Minimizer.h:393
Error.h
ROOT::Math::Minimizer::SetValidError
void SetValidError(bool on)
flag to check if minimizer needs to perform accurate error analysis (e.g. run Hesse for Minuit)
Definition: Minimizer.h:469
ROOT::Math::MinimizerOptions::SetMaxIterations
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
Definition: MinimizerOptions.h:137
ROOT::Math::Minimizer::GetCovMatrix
virtual bool GetCovMatrix(double *covMat) const
Fill the passed array with the covariance matrix elements if the variable is fixed or const the value...
Definition: Minimizer.h:299
ROOT::Math::Minimizer::SetVariableValues
virtual bool SetVariableValues(const double *x)
set the values of all existing variables (array must be dimensioned to the size of the existing param...
Definition: Minimizer.h:184
ROOT::Math::Minimizer::SetLowerLimitedVariable
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:157
ROOT::Math::Minimizer::Tolerance
double Tolerance() const
absolute tolerance
Definition: Minimizer.h:422
ROOT::Math::Minimizer::CovMatrixStatus
virtual int CovMatrixStatus() const
return status of covariance matrix using Minuit convention {0 not calculated 1 approximated 2 made po...
Definition: Minimizer.h:320
ROOT::Math::Minimizer::SetPrecision
void SetPrecision(double prec)
set in the minimizer the objective function evaluation precision ( a value <=0 means the minimizer wi...
Definition: Minimizer.h:460
ROOT::Math::Minimizer::SetFunction
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)=0
set the function to minimize
ROOT::Math::MinimizerOptions
Minimizer options.
Definition: MinimizerOptions.h:42
ROOT::Math::Minimizer::fStatus
int fStatus
Definition: Minimizer.h:492
ROOT::Math::Minimizer::SetTolerance
void SetTolerance(double tol)
set the tolerance
Definition: Minimizer.h:456
ROOT::Math::Minimizer::SetVariableValue
virtual bool SetVariableValue(unsigned int ivar, double value)
set the value of an already existing variable
Definition: Minimizer.h:178
ROOT::Math::MinimizerOptions::MaxIterations
unsigned int MaxIterations() const
max iterations
Definition: MinimizerOptions.h:101
y
Double_t y[n]
Definition: legend1.C:17
sqrt
double sqrt(double)
ROOT::Math::Minimizer::Hesse
virtual bool Hesse()
perform a full calculation of the Hessian matrix for error calculation
Definition: Minimizer.h:360
ROOT::Math::MinimizerOptions::SetTolerance
void SetTolerance(double tol)
set the tolerance
Definition: MinimizerOptions.h:140
ROOT::Math::Minimizer::SetMaxFunctionCalls
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
Definition: Minimizer.h:450
ROOT::Math::Minimizer::VariableIndex
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
Definition: Minimizer.h:404
ROOT::Math::Minimizer::Scan
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.
Definition: Minimizer.h:369
ROOT::Fit::ParameterSettings
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
Definition: ParameterSettings.h:46
ROOT::Math::Minimizer::IsValidError
bool IsValidError() const
return true if Minimizer has performed a detailed error validation (e.g. run Hesse for Minuit)
Definition: Minimizer.h:439
RooFit::Minimizer
RooCmdArg Minimizer(const char *type, const char *alg=0)
Definition: RooGlobalFunc.cxx:211
ROOT::Math::Minimizer::VariableName
virtual std::string VariableName(unsigned int ivar) const
get name of variables (override if minimizer support storing of variable names) return an empty strin...
Definition: Minimizer.h:397
ROOT::Math::Minimizer::FixVariable
virtual bool FixVariable(unsigned int ivar)
fix an existing variable
Definition: Minimizer.h:215
ROOT::Math::Minimizer::GlobalCC
virtual double GlobalCC(unsigned int ivar) const
return global correlation coefficient for variable i This is a number between zero and one which give...
Definition: Minimizer.h:340
ROOT::Math::Minimizer::SetUpperLimitedVariable
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:161
ROOT::Math::Minimizer
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
Definition: Minimizer.h:80
ROOT::Math::Minimizer::Correlation
virtual double Correlation(unsigned int i, unsigned int j) const
return correlation coefficient between variable i and j.
Definition: Minimizer.h:328
ROOT::Math::Minimizer::~Minimizer
virtual ~Minimizer()
Destructor (no operations)
Definition: Minimizer.h:95
ROOT::Math::MinimizerOptions::Tolerance
double Tolerance() const
absolute tolerance
Definition: MinimizerOptions.h:107
ROOT::Math::MinimizerOptions::SetStrategy
void SetStrategy(int stra)
set the strategy
Definition: MinimizerOptions.h:146
ROOT::Math::Minimizer::Clear
virtual void Clear()
reset for consecutive minimizations - implement if needed
Definition: Minimizer.h:119
ROOT::Math::Minimizer::SetVariable
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)=0
set a new free variable
ROOT::Math::Minimizer::MinGradient
virtual const double * MinGradient() const
return pointer to gradient values at the minimum
Definition: Minimizer.h:259
ROOT::Math::Minimizer::SetFixedVariable
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:172
ROOT::Math::Minimizer::Edm
virtual double Edm() const
return expected distance reached from the minimum (re-implement if minimizer provides it
Definition: Minimizer.h:256
name
char name[80]
Definition: TGX11.cxx:110
ROOT::Math::MinimizerOptions::PrintLevel
int PrintLevel() const
non-static methods for retrieving options
Definition: MinimizerOptions.h:95
ROOT::Math::Minimizer::SetVariableInitialRange
virtual bool SetVariableInitialRange(unsigned int, double, double)
set the initial range of an existing variable
Definition: Minimizer.h:242
ROOT::Math::Minimizer::IsFixedVariable
virtual bool IsFixedVariable(unsigned int ivar) const
query if an existing variable is fixed (i.e.
Definition: Minimizer.h:228
ROOT::Math::Minimizer::NDim
virtual unsigned int NDim() const =0
this is <= Function().NDim() which is the total number of variables (free+ constrained ones)
ROOT::Math::Minimizer::SetVariableStepSize
virtual bool SetVariableStepSize(unsigned int ivar, double value)
set the step size of an already existing variable
Definition: Minimizer.h:193
ROOT::Math::IBaseFunctionMultiDimTempl
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:62
ROOT::Math::MinimizerOptions::Strategy
int Strategy() const
strategy
Definition: MinimizerOptions.h:104
ROOT::Math::MinimizerOptions::ErrorDef
double ErrorDef() const
error definition
Definition: MinimizerOptions.h:113
ROOT::Math::Minimizer::Precision
double Precision() const
precision of minimizer in the evaluation of the objective function ( a value <=0 corresponds to the l...
Definition: Minimizer.h:426
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::Math::Minimizer::Status
int Status() const
status code of minimizer
Definition: Minimizer.h:432
ROOT::Math::Minimizer::GetVariableSettings
virtual bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings &pars) const
get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
Definition: Minimizer.h:234
Math
ROOT::Math::Minimizer::SetVariableLimits
virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper)
set the limits of an already existing variable
Definition: Minimizer.h:211