Logo ROOT  
Reference Guide
Minimizer.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: L. Moneta Fri Sep 22 15:06:47 2006
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10
11// Header file for class Minimizer
12
13#ifndef ROOT_Math_Minimizer
14#define ROOT_Math_Minimizer
15
16#include "Math/IFunction.h"
17
19
20#include "Math/Util.h"
21
22#include "Math/Error.h"
23
24
25#include <string>
26#include <limits>
27#include <cmath>
28#include <vector>
29#include <functional>
30
31
32
33namespace ROOT {
34
35 namespace Fit {
36 class ParameterSettings;
37 }
38
39
40 namespace Math {
41
42/**
43 @defgroup MultiMin Multi-dimensional Minimization
44 @ingroup NumAlgo
45
46 Classes implementing algorithms for multi-dimensional minimization
47 */
48
49
50
51//_______________________________________________________________________________
52/**
53 Abstract Minimizer class, defining the interface for the various minimizer
54 (like Minuit2, Minuit, GSL, etc..)
55 Plug-in's exist in ROOT to be able to instantiate the derived classes like
56 ROOT::Math::GSLMinimizer or ROOT::Math::Minuit2Minimizer via the
57 plug-in manager.
58
59 Provides interface for setting the function to be minimized.
60 The function must implemente the multi-dimensional generic interface
61 ROOT::Math::IBaseFunctionMultiDim.
62 If the function provides gradient calculation
63 (implements the ROOT::Math::IGradientFunctionMultiDim interface) this will be
64 used by the Minimizer.
65
66 It Defines also interface for setting the initial values for the function variables (which are the parameters in
67 of the model function in case of solving for fitting) and specifying their limits.
68
69 It defines the interface to set and retrieve basic minimization parameters
70 (for specific Minimizer parameters one must use the derived classes).
71
72 Then it defines the interface to retrieve the result of minimization ( minimum X values, function value,
73 gradient, error on the minimum, etc...)
74
75 @ingroup MultiMin
76*/
77
78class Minimizer {
79
80public:
81
82 /**
83 Default constructor
84 */
86 fValidError(false),
87 fStatus(-1)
88 {}
89
90 /**
91 Destructor (no operations)
92 */
93 virtual ~Minimizer () {}
94
95
96
97
98private:
99 // usually copying is non trivial, so we make this unaccessible
100
101 /**
102 Copy constructor
103 */
105
106 /**
107 Assignment operator
108 */
110 if (this == &rhs) return *this; // time saving self-test
111 return *this;
112 }
113
114public:
115
116 /// reset for consecutive minimization - implement if needed
117 virtual void Clear() {}
118
119 /// set the function to minimize
120 virtual void SetFunction(const ROOT::Math::IMultiGenFunction & func) = 0;
121
122 /// set a function to minimize using gradient
124 {
125 SetFunction(static_cast<const ::ROOT::Math::IMultiGenFunction &> (func));
126 }
127
128 /// set the function implementing Hessian computation (re-implemented by Minimizer using it)
129 virtual void SetHessianFunction(std::function<bool(const std::vector<double> &, double *)> ) {}
130
131 /// add variables . Return number of variables successfully added
132 template<class VariableIterator>
133 int SetVariables(const VariableIterator & begin, const VariableIterator & end) {
134 unsigned int ivar = 0;
135 for ( VariableIterator vitr = begin; vitr != end; ++vitr) {
136 bool iret = false;
137 if (vitr->IsFixed() )
138 iret = SetFixedVariable(ivar, vitr->Name(), vitr->Value() );
139 else if (vitr->IsDoubleBound() )
140 iret = SetLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->LowerLimit(), vitr->UpperLimit() );
141 else if (vitr->HasLowerLimit() )
142 iret = SetLowerLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->LowerLimit() );
143 else if (vitr->HasUpperLimit() )
144 iret = SetUpperLimitedVariable(ivar, vitr->Name(), vitr->Value(), vitr->StepSize(), vitr->UpperLimit() );
145 else
146 iret = SetVariable( ivar, vitr->Name(), vitr->Value(), vitr->StepSize() );
147
148 if (iret) ivar++;
149
150 // an error message should be eventually be reported in the virtual single SetVariable methods
151 }
152 return ivar;
153 }
154 /// set a new free variable
155 virtual bool SetVariable(unsigned int ivar, const std::string & name, double val, double step) = 0;
156 /// set a new lower limit variable (override if minimizer supports them )
157 virtual bool SetLowerLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double lower ) {
158 return SetLimitedVariable(ivar, name, val, step, lower, std::numeric_limits<double>::infinity() );
159 }
160 /// set a new upper limit variable (override if minimizer supports them )
161 virtual bool SetUpperLimitedVariable(unsigned int ivar , const std::string & name , double val , double step , double upper ) {
162 return SetLimitedVariable(ivar, name, val, step, - std::numeric_limits<double>::infinity(), upper );
163 }
164 /// set a new upper/lower limited variable (override if minimizer supports them ) otherwise as default set an unlimited variable
165 virtual bool SetLimitedVariable(unsigned int ivar , const std::string & name , double val , double step ,
166 double lower , double upper ) {
167 MATH_WARN_MSG("Minimizer::SetLimitedVariable","Setting of limited variable not implemented - set as unlimited");
168 MATH_UNUSED(lower); MATH_UNUSED(upper);
169 return SetVariable(ivar, name, val, step);
170 }
171 /// set a new fixed variable (override if minimizer supports them )
172 virtual bool SetFixedVariable(unsigned int ivar , const std::string & name , double val ) {
173 MATH_ERROR_MSG("Minimizer::SetFixedVariable","Setting of fixed variable not implemented");
175 return false;
176 }
177 /// set the value of an already existing variable
178 virtual bool SetVariableValue(unsigned int ivar , double value) {
179 MATH_ERROR_MSG("Minimizer::SetVariableValue","Set of a variable value not implemented");
181 return false;
182 }
183 /// set the values of all existing variables (array must be dimensioned to the size of the existing parameters)
184 virtual bool SetVariableValues(const double * x) {
185 bool ret = true;
186 unsigned int i = 0;
187 while ( i <= NDim() && ret) {
188 ret &= SetVariableValue(i,x[i] ); i++;
189 }
190 return ret;
191 }
192 /// set the step size of an already existing variable
193 virtual bool SetVariableStepSize(unsigned int ivar, double value ) {
194 MATH_ERROR_MSG("Minimizer::SetVariableStepSize","Setting an existing variable step size not implemented");
196 return false;
197 }
198 /// set the lower-limit of an already existing variable
199 virtual bool SetVariableLowerLimit(unsigned int ivar, double lower) {
200 MATH_ERROR_MSG("Minimizer::SetVariableLowerLimit","Setting an existing variable limit not implemented");
201 MATH_UNUSED(ivar); MATH_UNUSED(lower);
202 return false;
203 }
204 /// set the upper-limit of an already existing variable
205 virtual bool SetVariableUpperLimit(unsigned int ivar, double upper) {
206 MATH_ERROR_MSG("Minimizer::SetVariableUpperLimit","Setting an existing variable limit not implemented");
207 MATH_UNUSED(ivar); MATH_UNUSED(upper);
208 return false;
209 }
210 /// set the limits of an already existing variable
211 virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper) {
212 return SetVariableLowerLimit(ivar,lower) && SetVariableUpperLimit(ivar,upper);
213 }
214 /// fix an existing variable
215 virtual bool FixVariable(unsigned int ivar) {
216 MATH_ERROR_MSG("Minimizer::FixVariable","Fixing an existing variable not implemented");
217 MATH_UNUSED(ivar);
218 return false;
219 }
220 /// release an existing variable
221 virtual bool ReleaseVariable(unsigned int ivar) {
222 MATH_ERROR_MSG("Minimizer::ReleaseVariable","Releasing an existing variable not implemented");
223 MATH_UNUSED(ivar);
224 return false;
225 }
226 /// query if an existing variable is fixed (i.e. considered constant in the minimization)
227 /// note that by default all variables are not fixed
228 virtual bool IsFixedVariable(unsigned int ivar) const {
229 MATH_ERROR_MSG("Minimizer::IsFixedVariable","Querying an existing variable not implemented");
230 MATH_UNUSED(ivar);
231 return false;
232 }
233 /// get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
234 virtual bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings & pars) const {
235 MATH_ERROR_MSG("Minimizer::GetVariableSettings","Querying an existing variable not implemented");
236 MATH_UNUSED(ivar); MATH_UNUSED(pars);
237 return false;
238 }
239
240
241 /// set the initial range of an existing variable
242 virtual bool SetVariableInitialRange(unsigned int /* ivar */, double /* mininitial */, double /* maxinitial */) {
243 return false;
244 }
245
246 /// method to perform the minimization
247 virtual bool Minimize() = 0;
248
249 /// return minimum function value
250 virtual double MinValue() const = 0;
251
252 /// return pointer to X values at the minimum
253 virtual const double * X() const = 0;
254
255 /// return expected distance reached from the minimum (re-implement if minimizer provides it
256 virtual double Edm() const { return -1; }
257
258 /// return pointer to gradient values at the minimum
259 virtual const double * MinGradient() const { return nullptr; }
260
261 /// number of function calls to reach the minimum
262 virtual unsigned int NCalls() const { return 0; }
263
264 /// number of iterations to reach the minimum
265 virtual unsigned int NIterations() const { return NCalls(); }
266
267 /// this is <= Function().NDim() which is the total
268 /// number of variables (free+ constrained ones)
269 virtual unsigned int NDim() const = 0;
270
271 /// number of free variables (real dimension of the problem)
272 /// this is <= Function().NDim() which is the total
273 /// (re-implement if minimizer supports bounded parameters)
274 virtual unsigned int NFree() const { return NDim(); }
275
276 /// minimizer provides error and error matrix
277 virtual bool ProvidesError() const { return false; }
278
279 /// return errors at the minimum
280 virtual const double * Errors() const { return nullptr; }
281
282 /** return covariance matrices element for variables ivar,jvar
283 if the variable is fixed the return value is zero
284 The ordering of the variables is the same as in the parameter and errors vectors
285 */
286 virtual double CovMatrix(unsigned int ivar , unsigned int jvar ) const {
287 MATH_UNUSED(ivar); MATH_UNUSED(jvar);
288 return 0;
289 }
290
291 /**
292 Fill the passed array with the covariance matrix elements
293 if the variable is fixed or const the value is zero.
294 The array will be filled as cov[i *ndim + j]
295 The ordering of the variables is the same as in errors and parameter value.
296 This is different from the direct interface of Minuit2 or TMinuit where the
297 values were obtained only to variable parameters
298 */
299 virtual bool GetCovMatrix(double * covMat) const {
300 MATH_UNUSED(covMat);
301 return false;
302 }
303
304 /**
305 Fill the passed array with the Hessian matrix elements
306 The Hessian matrix is the matrix of the second derivatives
307 and is the inverse of the covariance matrix
308 If the variable is fixed or const the values for that variables are zero.
309 The array will be filled as h[i *ndim + j]
310 */
311 virtual bool GetHessianMatrix(double * hMat) const {
312 MATH_UNUSED(hMat);
313 return false;
314 }
315
316
317 ///return status of covariance matrix
318 /// using Minuit convention {0 not calculated 1 approximated 2 made pos def , 3 accurate}
319 /// Minimizer who implements covariance matrix calculation will re-implement the method
320 virtual int CovMatrixStatus() const {
321 return 0;
322 }
323
324 /**
325 return correlation coefficient between variable i and j.
326 If the variable is fixed or const the return value is zero
327 */
328 virtual double Correlation(unsigned int i, unsigned int j ) const {
329 double tmp = CovMatrix(i,i) * CovMatrix(j,j);
330 return ( tmp < 0) ? 0 : CovMatrix(i,j) / std::sqrt( tmp );
331 }
332
333 /**
334 return global correlation coefficient for variable i
335 This is a number between zero and one which gives
336 the correlation between the i-th parameter and that linear combination of all
337 other parameters which is most strongly correlated with i.
338 Minimizer must overload method if implemented
339 */
340 virtual double GlobalCC(unsigned int ivar) const {
341 MATH_UNUSED(ivar);
342 return -1;
343 }
344
345 /**
346 minos error for variable i, return false if Minos failed or not supported
347 and the lower and upper errors are returned in errLow and errUp
348 An extra flag specifies if only the lower (option=-1) or the upper (option=+1) error calculation is run
349 */
350 virtual bool GetMinosError(unsigned int ivar , double & errLow, double & errUp, int option = 0) {
351 MATH_ERROR_MSG("Minimizer::GetMinosError","Minos Error not implemented");
352 MATH_UNUSED(ivar); MATH_UNUSED(errLow); MATH_UNUSED(errUp); MATH_UNUSED(option);
353 return false;
354 }
355
356 /**
357 perform a full calculation of the Hessian matrix for error calculation
358 */
359 virtual bool Hesse() {
360 MATH_ERROR_MSG("Minimizer::Hesse","Hesse not implemented");
361 return false;
362 }
363
364 /**
365 scan function minimum for variable i. Variable and function must be set before using Scan
366 Return false if an error or if minimizer does not support this functionality
367 */
368 virtual bool Scan(unsigned int ivar , unsigned int & nstep , double * x , double * y ,
369 double xmin = 0, double xmax = 0) {
370 MATH_ERROR_MSG("Minimizer::Scan","Scan not implemented");
373 return false;
374 }
375
376 /**
377 find the contour points (xi, xj) of the function for parameter ivar and jvar around the minimum
378 The contour will be find for value of the function = Min + ErrorUp();
379 */
380 virtual bool Contour(unsigned int ivar , unsigned int jvar, unsigned int & npoints,
381 double * xi , double * xj ) {
382 MATH_ERROR_MSG("Minimizer::Contour","Contour not implemented");
383 MATH_UNUSED(ivar); MATH_UNUSED(jvar); MATH_UNUSED(npoints);
384 MATH_UNUSED(xi); MATH_UNUSED(xj);
385 return false;
386 }
387
388 /// return reference to the objective function
389 ///virtual const ROOT::Math::IGenFunction & Function() const = 0;
390
391 /// print the result according to set level (implemented for TMinuit for maintaining Minuit-style printing)
392 virtual void PrintResults() {}
393
394 /// get name of variables (override if minimizer support storing of variable names)
395 /// return an empty string if variable is not found
396 virtual std::string VariableName(unsigned int ivar) const {
397 MATH_UNUSED(ivar);
398 return std::string(); // return empty string
399 }
400
401 /// get index of variable given a variable given a name
402 /// return -1 if variable is not found
403 virtual int VariableIndex(const std::string & name) const {
404 MATH_ERROR_MSG("Minimizer::VariableIndex","Getting variable index from name not implemented");
406 return -1;
407 }
408
409 /** minimizer configuration parameters **/
410
411 /// set print level
412 int PrintLevel() const { return fOptions.PrintLevel(); }
413
414 /// max number of function calls
415 unsigned int MaxFunctionCalls() const { return fOptions.MaxFunctionCalls(); }
416
417 /// max iterations
418 unsigned int MaxIterations() const { return fOptions.MaxIterations(); }
419
420 /// absolute tolerance
421 double Tolerance() const { return fOptions.Tolerance(); }
422
423 /// precision of minimizer in the evaluation of the objective function
424 /// ( a value <=0 corresponds to the let the minimizer choose its default one)
425 double Precision() const { return fOptions.Precision(); }
426
427 /// strategy
428 int Strategy() const { return fOptions.Strategy(); }
429
430 /// status code of minimizer
431 int Status() const { return fStatus; }
432
433 /// status code of Minos (to be re-implemented by the minimizers supporting Minos)
434 virtual int MinosStatus() const { return -1; }
435
436 /// return the statistical scale used for calculate the error
437 /// is typically 1 for Chi2 and 0.5 for likelihood minimization
438 double ErrorDef() const { return fOptions.ErrorDef(); }
439
440 ///return true if Minimizer has performed a detailed error validation (e.g. run Hesse for Minuit)
441 bool IsValidError() const { return fValidError; }
442
443 /// retrieve the minimizer options (implement derived class if needed)
444 virtual MinimizerOptions Options() const {
445 return fOptions;
446 }
447
448 /// set print level
449 void SetPrintLevel(int level) { fOptions.SetPrintLevel(level); }
450
451 ///set maximum of function calls
452 void SetMaxFunctionCalls(unsigned int maxfcn) { if (maxfcn > 0) fOptions.SetMaxFunctionCalls(maxfcn); }
453
454 /// set maximum iterations (one iteration can have many function calls)
455 void SetMaxIterations(unsigned int maxiter) { if (maxiter > 0) fOptions.SetMaxIterations(maxiter); }
456
457 /// set the tolerance
458 void SetTolerance(double tol) { fOptions.SetTolerance(tol); }
459
460 /// set in the minimizer the objective function evaluation precision
461 /// ( a value <=0 means the minimizer will choose its optimal value automatically, i.e. default case)
462 void SetPrecision(double prec) { fOptions.SetPrecision(prec); }
463
464 ///set the strategy
465 void SetStrategy(int strategyLevel) { fOptions.SetStrategy(strategyLevel); }
466
467 /// set scale for calculating the errors
468 void SetErrorDef(double up) { fOptions.SetErrorDef(up); }
469
470 /// flag to check if minimizer needs to perform accurate error analysis (e.g. run Hesse for Minuit)
471 void SetValidError(bool on) { fValidError = on; }
472
473 /// set all options in one go
474 void SetOptions(const MinimizerOptions & opt) {
475 fOptions = opt;
476 }
477
478 /// set only the extra options
479 void SetExtraOptions(const IOptions & extraOptions) { fOptions.SetExtraOptions(extraOptions); }
480
481 /// reset the default options (defined in MinimizerOptions)
484 }
485
486protected:
487
488
489//private:
490
491
492 // keep protected to be accessible by the derived classes
493
494
495 bool fValidError; ///< flag to control if errors have been validated (Hesse has been run in case of Minuit)
496 MinimizerOptions fOptions; ///< minimizer options
497 int fStatus; ///< status of minimizer
498};
499
500 } // end namespace Math
501
502} // end namespace ROOT
503
504
505#endif /* ROOT_Math_Minimizer */
#define MATH_ERROR_MSG(loc, str)
Definition: Error.h:83
#define MATH_WARN_MSG(loc, str)
Definition: Error.h:80
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition: TGX11.cxx:110
float xmin
Definition: THbookFile.cxx:95
float xmax
Definition: THbookFile.cxx:95
#define MATH_UNUSED(var)
Definition: Util.h:34
Class, describing value, limits and step size of the parameters Provides functionality also to set/re...
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
Generic interface for defining configuration options of a numerical algorithm.
Definition: IOptions.h:31
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
void SetStrategy(int stra)
set the strategy
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
int Strategy() const
strategy
double Tolerance() const
absolute tolerance
double Precision() const
precision in the objective function calculation (value <=0 means left to default)
double ErrorDef() const
error definition
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
unsigned int MaxIterations() const
max iterations
void SetPrecision(double prec)
set the precision
unsigned int MaxFunctionCalls() const
max number of function calls
void ResetToDefaultOptions()
non-static methods for setting options
int PrintLevel() const
non-static methods for retrieving options
void SetErrorDef(double err)
set error def
void SetPrintLevel(int level)
set print level
void SetTolerance(double tol)
set the tolerance
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
Definition: Minimizer.h:78
double Tolerance() const
absolute tolerance
Definition: Minimizer.h:421
virtual const double * Errors() const
return errors at the minimum
Definition: Minimizer.h:280
virtual bool GetCovMatrix(double *covMat) const
Fill the passed array with the covariance matrix elements if the variable is fixed or const the value...
Definition: Minimizer.h:299
unsigned int MaxFunctionCalls() const
max number of function calls
Definition: Minimizer.h:415
virtual int VariableIndex(const std::string &name) const
get index of variable given a variable given a name return -1 if variable is not found
Definition: Minimizer.h:403
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
double Precision() const
precision of minimizer in the evaluation of the objective function ( a value <=0 corresponds to the l...
Definition: Minimizer.h:425
virtual const double * X() const =0
return pointer to X values at the minimum
virtual bool FixVariable(unsigned int ivar)
fix an existing variable
Definition: Minimizer.h:215
virtual unsigned int NIterations() const
number of iterations to reach the minimum
Definition: Minimizer.h:265
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
Definition: Minimizer.h:455
virtual void SetFunction(const ROOT::Math::IMultiGradFunction &func)
set a function to minimize using gradient
Definition: Minimizer.h:123
virtual bool SetVariableStepSize(unsigned int ivar, double value)
set the step size of an already existing variable
Definition: Minimizer.h:193
virtual bool SetVariableInitialRange(unsigned int, double, double)
set the initial range of an existing variable
Definition: Minimizer.h:242
void SetErrorDef(double up)
set scale for calculating the errors
Definition: Minimizer.h:468
virtual bool ReleaseVariable(unsigned int ivar)
release an existing variable
Definition: Minimizer.h:221
virtual bool SetVariableLowerLimit(unsigned int ivar, double lower)
set the lower-limit of an already existing variable
Definition: Minimizer.h:199
void SetValidError(bool on)
flag to check if minimizer needs to perform accurate error analysis (e.g. run Hesse for Minuit)
Definition: Minimizer.h:471
int SetVariables(const VariableIterator &begin, const VariableIterator &end)
add variables . Return number of variables successfully added
Definition: Minimizer.h:133
virtual const double * MinGradient() const
return pointer to gradient values at the minimum
Definition: Minimizer.h:259
int fStatus
status of minimizer
Definition: Minimizer.h:497
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)=0
set the function to minimize
unsigned int MaxIterations() const
max iterations
Definition: Minimizer.h:418
void SetDefaultOptions()
reset the default options (defined in MinimizerOptions)
Definition: Minimizer.h:482
bool fValidError
flag to control if errors have been validated (Hesse has been run in case of Minuit)
Definition: Minimizer.h:495
virtual bool GetVariableSettings(unsigned int ivar, ROOT::Fit::ParameterSettings &pars) const
get variable settings in a variable object (like ROOT::Fit::ParamsSettings)
Definition: Minimizer.h:234
virtual double GlobalCC(unsigned int ivar) const
return global correlation coefficient for variable i This is a number between zero and one which give...
Definition: Minimizer.h:340
virtual int MinosStatus() const
status code of Minos (to be re-implemented by the minimizers supporting Minos)
Definition: Minimizer.h:434
virtual bool SetVariableUpperLimit(unsigned int ivar, double upper)
set the upper-limit of an already existing variable
Definition: Minimizer.h:205
virtual bool SetVariableLimits(unsigned int ivar, double lower, double upper)
set the limits of an already existing variable
Definition: Minimizer.h:211
void SetTolerance(double tol)
set the tolerance
Definition: Minimizer.h:458
virtual int CovMatrixStatus() const
return status of covariance matrix using Minuit convention {0 not calculated 1 approximated 2 made po...
Definition: Minimizer.h:320
virtual bool Minimize()=0
method to perform the minimization
int Status() const
status code of minimizer
Definition: Minimizer.h:431
Minimizer(const Minimizer &)
Copy constructor.
Definition: Minimizer.h:104
Minimizer()
Default constructor.
Definition: Minimizer.h:85
virtual double CovMatrix(unsigned int ivar, unsigned int jvar) const
return covariance matrices element for variables ivar,jvar if the variable is fixed the return value ...
Definition: Minimizer.h:286
void SetPrintLevel(int level)
set print level
Definition: Minimizer.h:449
int Strategy() const
strategy
Definition: Minimizer.h:428
virtual unsigned int NCalls() const
number of function calls to reach the minimum
Definition: Minimizer.h:262
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
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)=0
set a new free variable
void SetStrategy(int strategyLevel)
set the strategy
Definition: Minimizer.h:465
virtual bool ProvidesError() const
minimizer provides error and error matrix
Definition: Minimizer.h:277
virtual bool IsFixedVariable(unsigned int ivar) const
query if an existing variable is fixed (i.e.
Definition: Minimizer.h:228
Minimizer & operator=(const Minimizer &rhs)
Assignment operator.
Definition: Minimizer.h:109
void SetPrecision(double prec)
set in the minimizer the objective function evaluation precision ( a value <=0 means the minimizer wi...
Definition: Minimizer.h:462
virtual MinimizerOptions Options() const
retrieve the minimizer options (implement derived class if needed)
Definition: Minimizer.h:444
virtual double Correlation(unsigned int i, unsigned int j) const
return correlation coefficient between variable i and j.
Definition: Minimizer.h:328
virtual ~Minimizer()
Destructor (no operations)
Definition: Minimizer.h:93
virtual std::string VariableName(unsigned int ivar) const
get name of variables (override if minimizer support storing of variable names) return an empty strin...
Definition: Minimizer.h:396
double ErrorDef() const
return the statistical scale used for calculate the error is typically 1 for Chi2 and 0....
Definition: Minimizer.h:438
MinimizerOptions fOptions
minimizer options
Definition: Minimizer.h:496
virtual bool SetFixedVariable(unsigned int ivar, const std::string &name, double val)
set a new fixed variable (override if minimizer supports them )
Definition: Minimizer.h:172
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
Definition: Minimizer.h:452
bool IsValidError() const
return true if Minimizer has performed a detailed error validation (e.g. run Hesse for Minuit)
Definition: Minimizer.h:441
virtual bool Contour(unsigned int ivar, unsigned int jvar, unsigned int &npoints, double *xi, double *xj)
find the contour points (xi, xj) of the function for parameter ivar and jvar around the minimum The c...
Definition: Minimizer.h:380
virtual double Edm() const
return expected distance reached from the minimum (re-implement if minimizer provides it
Definition: Minimizer.h:256
void SetOptions(const MinimizerOptions &opt)
set all options in one go
Definition: Minimizer.h:474
virtual void SetHessianFunction(std::function< bool(const std::vector< double > &, double *)>)
set the function implementing Hessian computation (re-implemented by Minimizer using it)
Definition: Minimizer.h:129
virtual bool SetVariableValues(const double *x)
set the values of all existing variables (array must be dimensioned to the size of the existing param...
Definition: Minimizer.h:184
virtual bool Scan(unsigned int ivar, unsigned int &nstep, double *x, double *y, double xmin=0, double xmax=0)
scan function minimum for variable i.
Definition: Minimizer.h:368
virtual bool SetVariableValue(unsigned int ivar, double value)
set the value of an already existing variable
Definition: Minimizer.h:178
virtual bool SetLimitedVariable(unsigned int ivar, const std::string &name, double val, double step, double lower, double upper)
set a new upper/lower limited variable (override if minimizer supports them ) otherwise as default se...
Definition: Minimizer.h:165
virtual void Clear()
reset for consecutive minimization - implement if needed
Definition: Minimizer.h:117
void SetExtraOptions(const IOptions &extraOptions)
set only the extra options
Definition: Minimizer.h:479
virtual double MinValue() const =0
return minimum function value
int PrintLevel() const
minimizer configuration parameters
Definition: Minimizer.h:412
virtual bool Hesse()
perform a full calculation of the Hessian matrix for error calculation
Definition: Minimizer.h:359
virtual void PrintResults()
return reference to the objective function virtual const ROOT::Math::IGenFunction & Function() const ...
Definition: Minimizer.h:392
virtual unsigned int NDim() const =0
this is <= Function().NDim() which is the total number of variables (free+ constrained ones)
virtual unsigned int NFree() const
number of free variables (real dimension of the problem) this is <= Function().NDim() which is the to...
Definition: Minimizer.h:274
virtual bool GetMinosError(unsigned int ivar, double &errLow, double &errUp, int option=0)
minos error for variable i, return false if Minos failed or not supported and the lower and upper err...
Definition: Minimizer.h:350
virtual bool GetHessianMatrix(double *hMat) const
Fill the passed array with the Hessian matrix elements The Hessian matrix is the matrix of the second...
Definition: Minimizer.h:311
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:133
Namespace for new Math classes and functions.
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:167
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.