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 free variable
77 bool SetVariable(unsigned int ivar, const std::string & name, double val, double step) override;
78
79 /// set upper/lower limited variable (override if minimizer supports them )
80 bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double /* lower */, double /* upper */) override;
81
82#ifdef LATER
83 /// set lower limit variable (override if minimizer supports them )
84 virtual bool SetLowerLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double lower );
85 /// set upper limit variable (override if minimizer supports them )
86 virtual bool SetUpperLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double upper );
87#endif
88
89 /// set fixed variable (override if minimizer supports them )
90 bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */) override;
91
92 /// set the value of an existing variable
93 bool SetVariableValue(unsigned int ivar, double val ) override;
94
95 /// method to perform the minimization
96 bool Minimize() override;
97
98 /// return minimum function value
99 double MinValue() const override { return fMinVal; }
100
101 /// return expected distance reached from the minimum
102 double Edm() const override { return fEdm; }
103
104 /// return pointer to X values at the minimum
105 const double * X() const override { return &fParams.front(); }
106
107 /// return pointer to gradient values at the minimum
108 const double * MinGradient() const override { return nullptr; } // not available
109
110 /// number of function calls to reach the minimum
111 unsigned int NCalls() const override { return 0; }
112
113 /// this is <= Function().NDim() which is the total
114 /// number of variables (free+ constrained ones)
115 unsigned int NDim() const override { return fDim; }
116
117 /// number of free variables (real dimension of the problem)
118 /// this is <= Function().NDim() which is the total
119 unsigned int NFree() const override { return fNFree; }
120
121 /// minimizer provides error and error matrix
122 bool ProvidesError() const override { return true; }
123
124 /// return errors at the minimum
125 const double * Errors() const override { return &fErrors.front(); }
126
127 /** return covariance matrices elements
128 if the variable is fixed the matrix is zero
129 The ordering of the variables is the same as in errors
130 */
131 double CovMatrix(unsigned int i, unsigned int j) const override {
132 return fCovar[i + fDim* j];
133 }
134
135 /*
136 return covariance matrix status
137 */
138 int CovMatrixStatus() const override {
139 if (fCovar.empty()) return 0;
140 return (fStatus ==0) ? 3 : 1;
141 }
142
143
144
145
146
147protected:
148
149 /// implementation of FCN for Fumili
150 static void Fcn( int &, double * , double & f, double * , int);
151 /// implementation of FCN for Fumili when user provided gradient is used
152 //static void FcnGrad( int &, double * g, double & f, double * , int);
153
154 /// static function implementing the evaluation of the FCN (it uses static instance fgFumili)
155 static double EvaluateFCN(const double * x, double * g);
156
157private:
158
159
160 unsigned int fDim;
161 unsigned int fNFree;
162 double fMinVal;
163 double fEdm;
164 std::vector<double> fParams;
165 std::vector<double> fErrors;
166 std::vector<double> fCovar;
167
169
170 // need to have a static copy of the function
171 //NOTE: This is NOT thread safe.
174
175 static TFumili * fgFumili; // static instance (used by fcn function)
176
177 ClassDef(TFumiliMinimizer,1) //Implementation of Minimizer interface using TFumili
178
179};
180
181
182
183#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:61
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
Definition Minimizer.h:117
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:190
int fStatus
status of minimizer
Definition Minimizer.h:391
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:194
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