Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FumiliMinimizer.cxx
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#include "Minuit2/MnConfig.h"
17#include "Minuit2/MinimumSeed.h"
22#include "Minuit2/MnUserFcn.h"
24#include "Minuit2/FCNBase.h"
25#include "Minuit2/MnStrategy.h"
26#include "Minuit2/MnPrint.h"
27
28namespace ROOT {
29
30namespace Minuit2 {
31
32// for Fumili implement Minimize here because need downcast
33
35 const MnStrategy &strategy, unsigned int maxfcn, double toler) const
36{
37 MnPrint print("FumiliMinimizer::Minimize");
38
39 // Minimize using Fumili. Create seed and Fumili gradient calculator.
40 // The FCNBase passed must be a FumiliFCNBase type otherwise method will fail !
41
42 if (fcn.HasGradient()) {
43 MnUserFcn mfcn(fcn, st.Trafo());
44 Numerical2PGradientCalculator gc(mfcn, st.Trafo(), strategy);
45
46 unsigned int npar = st.VariableParameters();
47 if (maxfcn == 0)
48 maxfcn = 200 + 100 * npar + 5 * npar * npar;
49 // FUMILI needs much less function calls
50 maxfcn = int(0.1 * maxfcn);
51
52 MinimumSeed mnseeds = SeedGenerator()(mfcn, gc, st, strategy);
53
54 // downcast fcn
55
56 // std::cout << "FCN type " << typeid(&fcn).Name() << std::endl;
57
58 FumiliFCNBase *fumiliFcn = dynamic_cast<FumiliFCNBase *>(const_cast<FCNBase *>(&fcn));
59 if (!fumiliFcn) {
60 print.Error("Wrong FCN type; try to use default minimizer");
61 return FunctionMinimum(mnseeds, fcn.Up());
62 }
63
64 FumiliGradientCalculator fgc(*fumiliFcn, st.Trafo(), npar);
65 print.Debug("Using FumiliMinimizer");
66
67 return ModularFunctionMinimizer::Minimize(mfcn, fgc, mnseeds, strategy, maxfcn, toler);
68 }
69
70 // Minimize using Fumili. Case of interface is a function with gradient.
71 // Normally other method is used - probably this could be removed (t.b.i.)
72
73 // need MnUserFcn
74 MnUserFcn mfcn(fcn, st.Trafo());
76
77 unsigned int npar = st.VariableParameters();
78 if (maxfcn == 0)
79 maxfcn = 200 + 100 * npar + 5 * npar * npar;
80
81 MinimumSeed mnseeds = SeedGenerator()(mfcn, gc, st, strategy);
82
83 // downcast fcn
84
85 FumiliFCNBase *fumiliFcn = dynamic_cast<FumiliFCNBase *>(const_cast<FCNBase *>(&fcn));
86 if (!fumiliFcn) {
87 print.Error("Wrong FCN type; try to use default minimizer");
88 return FunctionMinimum(mnseeds, fcn.Up());
89 }
90
91 FumiliGradientCalculator fgc(*fumiliFcn, st.Trafo(), npar);
92 print.Debug("Using FumiliMinimizer");
93
94 return ModularFunctionMinimizer::Minimize(mfcn, fgc, mnseeds, strategy, maxfcn, toler);
95}
96
97} // namespace Minuit2
98
99} // namespace ROOT
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
Definition FCNBase.h:51
virtual double Up() const =0
Error definition of the function.
virtual bool HasGradient() const
Definition FCNBase.h:113
Extension of the FCNBase for the Fumili method.
Fumili gradient calculator using external gradient provided by FCN Note that the computed Hessian and...
FunctionMinimum Minimize(const FCNBase &, const MnUserParameterState &, const MnStrategy &, unsigned int maxfcn=0, double toler=0.1) const override
const MinimumSeedGenerator & SeedGenerator() const override
Accessor to the seed generator of the minimizer.
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
void Debug(const Ts &... args)
Definition MnPrint.h:147
void Error(const Ts &... args)
Definition MnPrint.h:129
API class for defining four levels of strategies: low (0), medium (1), high (2), very high (>=3); act...
Definition MnStrategy.h:27
Wrapper used by Minuit of FCN interface containing a reference to the transformation object.
Definition MnUserFcn.h:25
class which holds the external user and/or internal Minuit representation of the parameters and error...
const MnUserTransformation & Trafo() const
virtual FunctionMinimum Minimize(const FCNBase &, const MnUserParameterState &, const MnStrategy &=MnStrategy{1}, unsigned int maxfcn=0, double toler=0.1) const
class performing the numerical gradient calculation
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...