Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
19
20#include "Rtypes.h"
21#include <vector>
22#include <string>
23
24class TFumili;
25
26
27
28// namespace ROOT {
29
30// namespace Math {
31
32// class BasicFitMethodFunction<ROOT::Math::IMultiGenFunction>;
33// class BasicFitMethodFunction<ROOT::Math::IMultiGradFunction>;
34
35// }
36// }
37
38
39
40/**
41 TFumiliMinimizer class: minimizer implementation based on TFumili.
42*/
44
45public:
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
58private:
59 // usually copying is non trivial, so we make this unaccessible
60
61 /**
62 Copy constructor
63 */
65
66 /**
67 Assignment operator
68 */
70
71public:
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
150protected:
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
160private:
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 */
#define f(i)
Definition RSha256.hxx:104
#define g(i)
Definition RSha256.hxx:105
#define ClassDef(name, id)
Definition Rtypes.h:325
char name[80]
Definition TGX11.cxx:110
FitMethodFunction class Interface for objective functions (like chi2 and likelihood used in the fit) ...
Documentation for the abstract class IBaseFunctionMultiDim.
Definition IFunction.h:62
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
Definition IFunction.h:343
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
Definition Minimizer.h:75
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:152
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:156
TFumiliMinimizer class: minimizer implementation based on TFumili.
~TFumiliMinimizer()
Destructor (no operations)
virtual bool Minimize()
method to perform the minimization
static ROOT::Math::FitMethodFunction * fgFunc
virtual bool SetVariableValue(unsigned int ivar, double val)
set the value of an existing variable
std::vector< double > fParams
virtual bool SetFixedVariable(unsigned int, const std::string &, double)
set fixed variable (override if minimizer supports them )
virtual const double * MinGradient() const
return pointer to gradient values at the minimum
virtual const double * Errors() const
return errors at the minimum
static double EvaluateFCN(const double *x, double *g)
implementation of FCN for Fumili when user provided gradient is used
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)
set free variable
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 )
static ROOT::Math::FitMethodGradFunction * fgGradFunc
virtual double Edm() const
return expected distance reached from the minimum
virtual unsigned int NCalls() const
number of function calls to reach the minimum
virtual double MinValue() const
return minimum function value
TFumiliMinimizer & operator=(const TFumiliMinimizer &rhs)
Assignment operator.
virtual bool ProvidesError() const
minimizer provides error and error matrix
static TFumili * fgFumili
virtual unsigned int NFree() const
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the to...
virtual const double * X() const
return pointer to X values at the minimum
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the function to minimize
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...
virtual int CovMatrixStatus() const
return status of covariance matrix using Minuit convention {0 not calculated 1 approximated 2 made po...
std::vector< double > fErrors
std::vector< double > fCovar
virtual unsigned int NDim() const
this is <= Function().NDim() which is the total number of variables (free+ constrained ones)
static void Fcn(int &, double *, double &f, double *, int)
implementation of FCN for Fumili
Double_t x[n]
Definition legend1.C:17