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 */
56 ~TFumiliMinimizer () override;
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 void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
75
76 /// set the function to minimize
77 void SetFunction(const ROOT::Math::IMultiGradFunction & func) override;
78
79 /// set free variable
80 bool SetVariable(unsigned int ivar, const std::string & name, double val, double step) override;
81
82 /// set upper/lower limited variable (override if minimizer supports them )
83 bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double /* lower */, double /* upper */) override;
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 bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */) override;
94
95 /// set the value of an existing variable
96 bool SetVariableValue(unsigned int ivar, double val ) override;
97
98 /// method to perform the minimization
99 bool Minimize() override;
100
101 /// return minimum function value
102 double MinValue() const override { return fMinVal; }
103
104 /// return expected distance reached from the minimum
105 double Edm() const override { return fEdm; }
106
107 /// return pointer to X values at the minimum
108 const double * X() const override { return &fParams.front(); }
109
110 /// return pointer to gradient values at the minimum
111 const double * MinGradient() const override { return nullptr; } // not available
112
113 /// number of function calls to reach the minimum
114 unsigned int NCalls() const override { return 0; }
115
116 /// this is <= Function().NDim() which is the total
117 /// number of variables (free+ constrained ones)
118 unsigned int NDim() const override { return fDim; }
119
120 /// number of free variables (real dimension of the problem)
121 /// this is <= Function().NDim() which is the total
122 unsigned int NFree() const override { return fNFree; }
123
124 /// minimizer provides error and error matrix
125 bool ProvidesError() const override { return true; }
126
127 /// return errors at the minimum
128 const double * Errors() const override { 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 double CovMatrix(unsigned int i, unsigned int j) const override {
135 return fCovar[i + fDim* j];
136 }
137
138 /*
139 return covariance matrix status
140 */
141 int CovMatrixStatus() const override {
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:337
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:78
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
int fStatus
status of minimizer
Definition Minimizer.h:497
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
TFumiliMinimizer class: minimizer implementation based on TFumili.
static ROOT::Math::FitMethodFunction * fgFunc
bool SetFixedVariable(unsigned int, const std::string &, double) override
set fixed variable (override if minimizer supports them )
std::vector< double > fParams
const double * MinGradient() const override
return pointer to gradient values at the minimum
bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double, double) override
set upper/lower limited variable (override if minimizer supports them )
static double EvaluateFCN(const double *x, double *g)
implementation of FCN for Fumili when user provided gradient is used
~TFumiliMinimizer() override
Destructor (no operations)
bool Minimize() override
method to perform the minimization
static ROOT::Math::FitMethodGradFunction * fgGradFunc
const double * Errors() const override
return errors at the minimum
TFumiliMinimizer & operator=(const TFumiliMinimizer &rhs)
Assignment operator.
unsigned int NDim() const override
this is <= Function().NDim() which is the total number of variables (free+ constrained ones)
static TFumili * fgFumili
bool ProvidesError() const override
minimizer provides error and error matrix
int CovMatrixStatus() const override
return status of covariance matrix using Minuit convention {0 not calculated 1 approximated 2 made po...
unsigned int NCalls() const override
number of function calls to reach the minimum
unsigned int NFree() const override
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the to...
bool SetVariableValue(unsigned int ivar, double val) override
set the value of an existing variable
std::vector< double > fErrors
const double * X() const override
return pointer to X values at the minimum
double CovMatrix(unsigned int i, unsigned int j) const override
return covariance matrices elements if the variable is fixed the matrix is zero The ordering of the v...
std::vector< double > fCovar
void SetFunction(const ROOT::Math::IMultiGenFunction &func) override
set the function to minimize
bool SetVariable(unsigned int ivar, const std::string &name, double val, double step) override
set free variable
double Edm() const override
return expected distance reached from the minimum
static void Fcn(int &, double *, double &f, double *, int)
implementation of FCN for Fumili
double MinValue() const override
return minimum function value
Double_t x[n]
Definition legend1.C:17