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