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
30 namespace Minuit2 {
31
32
33// for Fumili implement Minimize here because need downcast
34
35
36FunctionMinimum FumiliMinimizer::Minimize(const FCNBase& fcn, const MnUserParameterState& st, const MnStrategy& strategy, unsigned int maxfcn, double toler) const {
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 MnUserFcn mfcn(fcn, st.Trafo());
41 Numerical2PGradientCalculator gc(mfcn, st.Trafo(), strategy);
42
43 unsigned int npar = st.VariableParameters();
44 if(maxfcn == 0) maxfcn = 200 + 100*npar + 5*npar*npar;
45 //FUMILI needs much less function calls
46 maxfcn = int(0.1*maxfcn);
47
48 MinimumSeed mnseeds = SeedGenerator()(mfcn, gc, st, strategy);
49
50 // downcast fcn
51
52 //std::cout << "FCN type " << typeid(&fcn).Name() << std::endl;
53
54 FumiliFCNBase * fumiliFcn = dynamic_cast< FumiliFCNBase *>( const_cast<FCNBase *>(&fcn) );
55 if ( !fumiliFcn ) {
56 MN_ERROR_MSG("FumiliMinimizer: Error : wrong FCN type. Try to use default minimizer");
57 return FunctionMinimum(mnseeds, fcn.Up() );
58 }
59
60
61 FumiliGradientCalculator fgc(*fumiliFcn, st.Trafo(), npar);
62#ifdef DEBUG
63 std::cout << "Minuit::Minimize using FumiliMinimizer" << std::endl;
64#endif
65 return ModularFunctionMinimizer::Minimize(mfcn, fgc, mnseeds, strategy, maxfcn, toler);
66}
67
68
69
70FunctionMinimum FumiliMinimizer::Minimize(const FCNGradientBase& fcn, const MnUserParameterState& st, const MnStrategy& strategy, unsigned int maxfcn, double toler) const {
71 // Minimize using Fumili. Case of interface is a FCNGradientBase.
72 // Normally other method is used - probably this could be removed (t.b.i.)
73
74 // need MnUserFcn
75 MnUserFcn mfcn(fcn, st.Trafo() );
77
78 unsigned int npar = st.VariableParameters();
79 if(maxfcn == 0) 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<FCNGradientBase *>(&fcn) );
86 if ( !fumiliFcn ) {
87 MN_ERROR_MSG("FumiliMinimizer: Error : wrong FCN type. Try to use default minimizer");
88 return FunctionMinimum(mnseeds, fcn.Up() );
89 }
90
91
92 FumiliGradientCalculator fgc(*fumiliFcn, st.Trafo(), npar);
93#ifdef DEBUG
94 std::cout << "Minuit::Minimize using FumiliMinimizer" << std::endl;
95#endif
96 return ModularFunctionMinimizer::Minimize(mfcn, fgc, mnseeds, strategy, maxfcn, toler);
97
98}
99
100 } // namespace Minuit2
101
102} // namespace ROOT
#define MN_ERROR_MSG(str)
Definition: MnPrint.h:113
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
Definition: FCNBase.h:47
virtual double Up() const =0
Error definition of the function.
Extension of the FCNBase for providing the analytical Gradient of the function.
Extension of the FCNBase for the Fumili method.
Definition: FumiliFCNBase.h:47
FunctionMinimum Minimize(const FCNBase &, const MnUserParameterState &, const MnStrategy &, unsigned int maxfcn=0, double toler=0.1) const
const MinimumSeedGenerator & SeedGenerator() const
Accessor to the seed generator of the minimizer.
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
MinimumSeed contains the starting values for the minimization produced by the SeedGenerator.
Definition: MinimumSeed.h:31
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:26
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 std::vector< double > &, const std::vector< double > &, unsigned int stra=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...
Definition: StringConv.hxx:21