ROOT   Reference Guide
TFumiliMinimizer.h
Go to the documentation of this file.
1 // @(#)root/fumili:$Id$
2 // Author: L. Moneta Wed Oct 25 16:28:55 2006
3
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10
11 // Header file for class TFumiliMinimizer
12
13 #ifndef ROOT_TFumiliMinimizer
14 #define ROOT_TFumiliMinimizer
15
16 #include "Math/Minimizer.h"
17
18 #include "Math/FitMethodFunction.h"
19
20 #include "Rtypes.h"
21 #include <vector>
22 #include <string>
23
24 class TFumili;
25
26
27
28 // namespace ROOT {
29
30 // namespace Math {
31
32 // class BasicFitMethodFunction<ROOT::Math::IMultiGenFunction>;
34
35 // }
36 // }
37
38
39
40 /**
41  TFumiliMinimizer class: minimizer implementation based on TFumili.
42 */
44
45 public:
46
47  /**
48  Default constructor (an argument is needed by plug-in manager)
49  */
50  TFumiliMinimizer (int dummy=0 );
51
52
53  /**
54  Destructor (no operations)
55  */
57
58 private:
59  // usually copying is non trivial, so we make this unaccessible
60
61  /**
62  Copy constructor
63  */
65
66  /**
67  Assignment operator
68  */
70
71 public:
72
73  /// set the function to minimize
74  virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func);
75
76  /// set the function to minimize
77  virtual void SetFunction(const ROOT::Math::IMultiGradFunction & func);
78
79  /// set free variable
80  virtual bool SetVariable(unsigned int ivar, const std::string & name, double val, double step);
81
82  /// set upper/lower limited variable (override if minimizer supports them )
83  virtual bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double /* lower */, double /* upper */);
84
85 #ifdef LATER
86  /// set lower limit variable (override if minimizer supports them )
87  virtual bool SetLowerLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double lower );
88  /// set upper limit variable (override if minimizer supports them )
89  virtual bool SetUpperLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double upper );
90 #endif
91
92  /// set fixed variable (override if minimizer supports them )
93  virtual bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */);
94
95  /// set the value of an existing variable
96  virtual bool SetVariableValue(unsigned int ivar, double val );
97
98  /// method to perform the minimization
99  virtual bool Minimize();
100
101  /// return minimum function value
102  virtual double MinValue() const { return fMinVal; }
103
104  /// return expected distance reached from the minimum
105  virtual double Edm() const { return fEdm; }
106
107  /// return pointer to X values at the minimum
108  virtual const double * X() const { return &fParams.front(); }
109
110  /// return pointer to gradient values at the minimum
111  virtual const double * MinGradient() const { return 0; } // not available
112
113  /// number of function calls to reach the minimum
114  virtual unsigned int NCalls() const { return 0; }
115
116  /// this is <= Function().NDim() which is the total
117  /// number of variables (free+ constrained ones)
118  virtual unsigned int NDim() const { return fDim; }
119
120  /// number of free variables (real dimension of the problem)
121  /// this is <= Function().NDim() which is the total
122  virtual unsigned int NFree() const { return fNFree; }
123
124  /// minimizer provides error and error matrix
125  virtual bool ProvidesError() const { return true; }
126
127  /// return errors at the minimum
128  virtual const double * Errors() const { return &fErrors.front(); }
129
130  /** return covariance matrices elements
131  if the variable is fixed the matrix is zero
132  The ordering of the variables is the same as in errors
133  */
134  virtual double CovMatrix(unsigned int i, unsigned int j) const {
135  return fCovar[i + fDim* j];
136  }
137
138  /*
139  return covariance matrix status
140  */
141  virtual int CovMatrixStatus() const {
142  if (fCovar.size() == 0) return 0;
143  return (fStatus ==0) ? 3 : 1;
144  }
145
146
147
148
149
150 protected:
151
152  /// implementation of FCN for Fumili
153  static void Fcn( int &, double * , double & f, double * , int);
154  /// implementation of FCN for Fumili when user provided gradient is used
155  //static void FcnGrad( int &, double * g, double & f, double * , int);
156
157  /// static function implementing the evaluation of the FCN (it uses static instance fgFumili)
158  static double EvaluateFCN(const double * x, double * g);
159
160 private:
161
162
163  unsigned int fDim;
164  unsigned int fNFree;
165  double fMinVal;
166  double fEdm;
167  std::vector<double> fParams;
168  std::vector<double> fErrors;
169  std::vector<double> fCovar;
170
172
173  // need to have a static copy of the function
174  //NOTE: This is NOT thread safe.
177
178  static TFumili * fgFumili; // static instance (used by fcn function)
179
180  ClassDef(TFumiliMinimizer,1) //Implementation of Minimizer interface using TFumili
181
182 };
183
184
185
186 #endif /* ROOT_TFumiliMinimizer */
TFumiliMinimizer::SetVariable
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)
set free variable
Definition: TFumiliMinimizer.cxx:412
Minimizer.h
f
#define f(i)
Definition: RSha256.hxx:122
TFumiliMinimizer::CovMatrix
virtual double CovMatrix(unsigned int i, unsigned int j) const
return covariance matrices elements if the variable is fixed the matrix is zero The ordering of the v...
Definition: TFumiliMinimizer.h:134
TFumiliMinimizer::NDim
virtual unsigned int NDim() const
this is <= Function().NDim() which is the total number of variables (free+ constrained ones)
Definition: TFumiliMinimizer.h:118
TFumiliMinimizer::fgFumili
static TFumili * fgFumili
Definition: TFumiliMinimizer.h:178
TFumiliMinimizer::CovMatrixStatus
virtual int CovMatrixStatus() const
return status of covariance matrix using Minuit convention {0 not calculated 1 approximated 2 made po...
Definition: TFumiliMinimizer.h:141
TFumiliMinimizer::fFumili
TFumili * fFumili
Definition: TFumiliMinimizer.h:171
TFumiliMinimizer::fDim
unsigned int fDim
Definition: TFumiliMinimizer.h:163
TFumiliMinimizer::SetFunction
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the function to minimize
Definition: TFumiliMinimizer.cxx:186
TFumiliMinimizer::fEdm
double fEdm
Definition: TFumiliMinimizer.h:166
TFumiliMinimizer::fgFunc
static ROOT::Math::FitMethodFunction * fgFunc
Definition: TFumiliMinimizer.h:175
x
Double_t x[n]
Definition: legend1.C:17
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition: IFunction.h:326
FitMethodFunction.h
TFumiliMinimizer::fMinVal
double fMinVal
Definition: TFumiliMinimizer.h:165
Definition: TFumiliMinimizer.h:176
TFumiliMinimizer::TFumiliMinimizer
TFumiliMinimizer(int dummy=0)
Default constructor (an argument is needed by plug-in manager)
Definition: TFumiliMinimizer.cxx:142
TFumiliMinimizer::fErrors
std::vector< double > fErrors
Definition: TFumiliMinimizer.h:168
TFumiliMinimizer::X
virtual const double * X() const
return pointer to X values at the minimum
Definition: TFumiliMinimizer.h:108
TFumiliMinimizer::Fcn
static void Fcn(int &, double *, double &f, double *, int)
implementation of FCN for Fumili
Definition: TFumiliMinimizer.cxx:239
TFumili
Definition: TFumili.h:11
TFumiliMinimizer::MinValue
virtual double MinValue() const
return minimum function value
Definition: TFumiliMinimizer.h:102
TFumiliMinimizer::Errors
virtual const double * Errors() const
return errors at the minimum
Definition: TFumiliMinimizer.h:128
TFumiliMinimizer::ProvidesError
virtual bool ProvidesError() const
minimizer provides error and error matrix
Definition: TFumiliMinimizer.h:125
TFumiliMinimizer::Minimize
virtual bool Minimize()
method to perform the minimization
Definition: TFumiliMinimizer.cxx:505
virtual const double * MinGradient() const
return pointer to gradient values at the minimum
Definition: TFumiliMinimizer.h:111
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::fStatus
int fStatus
Definition: Minimizer.h:494
TFumiliMinimizer::SetFixedVariable
virtual bool SetFixedVariable(unsigned int, const std::string &, double)
set fixed variable (override if minimizer supports them )
Definition: TFumiliMinimizer.cxx:457
TFumiliMinimizer::SetLimitedVariable
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double, double)
set upper/lower limited variable (override if minimizer supports them )
Definition: TFumiliMinimizer.cxx:430
TFumiliMinimizer::EvaluateFCN
static double EvaluateFCN(const double *x, double *g)
implementation of FCN for Fumili when user provided gradient is used
Definition: TFumiliMinimizer.cxx:258
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
dummy
static RooMathCoreReg dummy
Definition: RooMathCoreReg.cxx:27
TFumiliMinimizer
TFumiliMinimizer class: minimizer implementation based on TFumili.
Definition: TFumiliMinimizer.h:43
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
TFumiliMinimizer::fNFree
unsigned int fNFree
Definition: TFumiliMinimizer.h:164
ROOT::Math::BasicFitMethodFunction
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
Definition: Fitter.h:40
TFumiliMinimizer::fCovar
std::vector< double > fCovar
Definition: TFumiliMinimizer.h:169
ROOT::Math::IBaseFunctionMultiDimTempl
Documentation for the abstract class IBaseFunctionMultiDim.
Definition: IFunction.h:62
TFumiliMinimizer::Edm
virtual double Edm() const
return expected distance reached from the minimum
Definition: TFumiliMinimizer.h:105
TFumiliMinimizer::operator=
TFumiliMinimizer & operator=(const TFumiliMinimizer &rhs)
Assignment operator.
Definition: TFumiliMinimizer.cxx:177
TFumiliMinimizer::~TFumiliMinimizer
~TFumiliMinimizer()
Destructor (no operations)
Definition: TFumiliMinimizer.cxx:165
TFumiliMinimizer::NCalls
virtual unsigned int NCalls() const
number of function calls to reach the minimum
Definition: TFumiliMinimizer.h:114
TFumiliMinimizer::fParams
std::vector< double > fParams
Definition: TFumiliMinimizer.h:167
Rtypes.h
TFumiliMinimizer::SetVariableValue
virtual bool SetVariableValue(unsigned int ivar, double val)
set the value of an existing variable
Definition: TFumiliMinimizer.cxx:479
TFumiliMinimizer::NFree
virtual unsigned int NFree() const
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the to...
Definition: TFumiliMinimizer.h:122
g
#define g(i)
Definition: RSha256.hxx:123