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