Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FumiliFCNBase.h
Go to the documentation of this file.
1// @(#)root/minuit2:$Id$
2// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
10#ifndef ROOT_Minuit2_FumiliFCNBase
11#define ROOT_Minuit2_FumiliFCNBase
12
13#include "Minuit2/FCNBase.h"
14#include <cassert>
15#include <vector>
16
17namespace ROOT {
18
19namespace Minuit2 {
20
21//____________________________________________________________________________________________
22/**
23
24Extension of the FCNBase for the Fumili method. Fumili applies only to
25minimization problems used for fitting. The method is based on a
26linearization of the model function negleting second derivatives.
27User needs to provide the model function. The figure-of-merit describing
28the difference between the model function and the actual measurements
29has to be implemented by the user in a subclass of FumiliFCNBase.
30For an example see the FumiliChi2FCN and FumiliStandardChi2FCN classes.
31
32
33@author Andras Zsenei and Lorenzo Moneta, Creation date: 23 Aug 2004
34
35@see <A HREF="http://www.cern.ch/winkler/minuit/tutorial/mntutorial.pdf">MINUIT Tutorial</A> on function minimization,
36section 5
37
38@see FumiliChi2FCN
39
40@see FumiliStandardChi2FCN
41
42@ingroup Minuit
43
44 */
45
46class FumiliFCNBase : public FCNBase {
47
48public:
49 /**
50 Default Constructor. Need in this case to create when implementing EvaluateAll the Gradient and Hessian vectors
51 with the right size
52 */
53
55
56 bool HasGradient() const override { return true; }
57
58 /**
59
60 Constructor which initializes the class with the function provided by the
61 user for modeling the data.
62
63 @param npar the number of parameters
64
65 */
66
67 FumiliFCNBase(unsigned int npar)
68 : fNumberOfParameters(npar), fValue(0), fGradient(std::vector<double>(npar)),
69 fHessian(std::vector<double>(static_cast<int>(0.5 * npar * (npar + 1))))
70 {
71 }
72
73 // FumiliFCNBase(const ParametricFunction& modelFCN) { fModelFunction = &modelFCN; }
74
75 ~FumiliFCNBase() override {}
76
77 /**
78
79 Evaluate function Value, Gradient and Hessian using Fumili approximation, for values of parameters p
80 The result is cached inside and is return from the FumiliFCNBase::Value , FumiliFCNBase::Gradient and
81 FumiliFCNBase::Hessian methods
82
83 @param par vector of parameters
84
85 **/
86
87 virtual void EvaluateAll(std::vector<double> const& par) = 0;
88
89 /**
90 Return cached Value of objective function estimated previously using the FumiliFCNBase::EvaluateAll method
91
92 **/
93
94 virtual double Value() const { return fValue; }
95
96 /**
97 Return cached Value of function Gradient estimated previously using the FumiliFCNBase::EvaluateAll method
98 **/
99
100 virtual const std::vector<double> &Gradient() const { return fGradient; }
101 std::vector<double> Gradient(std::vector<double> const&) const override { return fGradient;}
102
103 /**
104 Return Value of the i-th j-th element of the Hessian matrix estimated previously using the
105 FumiliFCNBase::EvaluateAll method
106 @param row row Index of the matrix
107 @param col col Index of the matrix
108 **/
109
110 std::vector<double> Hessian(std::vector<double> const&) const override { return fHessian;}
111 virtual double Hessian(unsigned int row, unsigned int col) const
112 {
113 assert(row < fGradient.size() && col < fGradient.size());
114 if (row > col)
115 return fHessian[col + row * (row + 1) / 2];
116 else
117 return fHessian[row + col * (col + 1) / 2];
118 }
119
120 /**
121 return number of function variable (parameters) , i.e. function dimension
122 */
123
124 virtual unsigned int Dimension() { return fNumberOfParameters; }
125
126protected:
127 /**
128 initialize and reset values of gradien and Hessian
129 */
130
131 virtual void InitAndReset(unsigned int npar)
132 {
133 fNumberOfParameters = npar;
134 fGradient = std::vector<double>(npar);
135 fHessian = std::vector<double>(static_cast<int>(0.5 * npar * (npar + 1)));
136 }
137
138 // methods to be used by the derived classes to set the values
139 void SetFCNValue(double value) { fValue = value; }
140
141 std::vector<double> &Gradient() { return fGradient; }
142
143 std::vector<double> &Hessian() { return fHessian; }
144
145private:
147 double fValue;
148 std::vector<double> fGradient;
149 std::vector<double> fHessian;
150};
151
152} // namespace Minuit2
153
154} // namespace ROOT
155
156#endif // ROOT_Minuit2_FumiliFCNBase
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
Definition FCNBase.h:51
Extension of the FCNBase for the Fumili method.
FumiliFCNBase()
Default Constructor.
bool HasGradient() const override
std::vector< double > Gradient(std::vector< double > const &) const override
std::vector< double > & Hessian()
virtual double Value() const
Return cached Value of objective function estimated previously using the FumiliFCNBase::EvaluateAll m...
std::vector< double > fGradient
std::vector< double > Hessian(std::vector< double > const &) const override
Return Value of the i-th j-th element of the Hessian matrix estimated previously using the FumiliFCNB...
virtual const std::vector< double > & Gradient() const
Return cached Value of function Gradient estimated previously using the FumiliFCNBase::EvaluateAll me...
std::vector< double > fHessian
virtual void InitAndReset(unsigned int npar)
initialize and reset values of gradien and Hessian
void SetFCNValue(double value)
virtual void EvaluateAll(std::vector< double > const &par)=0
Evaluate function Value, Gradient and Hessian using Fumili approximation, for values of parameters p ...
virtual unsigned int Dimension()
return number of function variable (parameters) , i.e.
FumiliFCNBase(unsigned int npar)
Constructor which initializes the class with the function provided by the user for modeling the data.
virtual double Hessian(unsigned int row, unsigned int col) const
std::vector< double > & Gradient()
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...