Logo ROOT  
Reference Guide
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"
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 // Minimize using Fumili. Create seed and Fumili gradient calculator.
38 // The FCNBase passed must be a FumiliFCNBase type otherwise method will fail !
39
40 MnPrint print("FumiliMinimizer");
41
42 MnUserFcn mfcn(fcn, st.Trafo());
43 Numerical2PGradientCalculator gc(mfcn, st.Trafo(), strategy);
44
45 unsigned int npar = st.VariableParameters();
46 if (maxfcn == 0)
47 maxfcn = 200 + 100 * npar + 5 * npar * npar;
48 // FUMILI needs much less function calls
49 maxfcn = int(0.1 * maxfcn);
50
51 MinimumSeed mnseeds = SeedGenerator()(mfcn, gc, st, strategy);
52
53 // downcast fcn
54
55 // std::cout << "FCN type " << typeid(&fcn).Name() << std::endl;
56
57 FumiliFCNBase *fumiliFcn = dynamic_cast<FumiliFCNBase *>(const_cast<FCNBase *>(&fcn));
58 if (!fumiliFcn) {
59 print.Error("Wrong FCN type; try to use default minimizer");
60 return FunctionMinimum(mnseeds, fcn.Up());
61 }
62
63 FumiliGradientCalculator fgc(*fumiliFcn, st.Trafo(), npar);
64 print.Debug("Using FumiliMinimizer");
65
66 return ModularFunctionMinimizer::Minimize(mfcn, fgc, mnseeds, strategy, maxfcn, toler);
67}
68
70 const MnStrategy &strategy, unsigned int maxfcn, double toler) const
71{
72
73 MnPrint print("FumiliMinimizer::Minimize");
74
75 // Minimize using Fumili. Case of interface is a FCNGradientBase.
76 // Normally other method is used - probably this could be removed (t.b.i.)
77
78 // need MnUserFcn
79 MnUserFcn mfcn(fcn, st.Trafo());
81
82 unsigned int npar = st.VariableParameters();
83 if (maxfcn == 0)
84 maxfcn = 200 + 100 * npar + 5 * npar * npar;
85
86 MinimumSeed mnseeds = SeedGenerator()(mfcn, gc, st, strategy);
87
88 // downcast fcn
89
90 FumiliFCNBase *fumiliFcn = dynamic_cast<FumiliFCNBase *>(const_cast<FCNGradientBase *>(&fcn));
91 if (!fumiliFcn) {
92 print.Error("Wrong FCN type; try to use default minimizer");
93 return FunctionMinimum(mnseeds, fcn.Up());
94 }
95
96 FumiliGradientCalculator fgc(*fumiliFcn, st.Trafo(), npar);
97 print.Debug("Using FumiliMinimizer");
98
99 return ModularFunctionMinimizer::Minimize(mfcn, fgc, mnseeds, strategy, maxfcn, toler);
100}
101
102} // namespace Minuit2
103
104} // 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:45
virtual double Up() const =0
Error definition of the function.
Extension of the FCNBase for the Fumili method.
Definition: FumiliFCNBase.h:46
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:138
void Error(const Ts &... args)
Definition: MnPrint.h:120
API class for defining three levels of strategies: low (0), medium (1), high (>=2); acts on: Migrad (...
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
FunctionMinimum Minimize(const FCNBase &, const std::vector< double > &, const std::vector< double > &, unsigned int stra=1, unsigned int maxfcn=0, double toler=0.1) const override
class performing the numerical gradient calculation
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.