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"
16 #include "Minuit2/MinimumBuilder.h"
17 #include "Minuit2/MinimumSeed.h"
22 #include "Minuit2/MnUserFcn.h"
23 #include "Minuit2/FumiliFCNBase.h"
25 #include "Minuit2/MnStrategy.h"
26 #include "Minuit2/MnPrint.h"
27 
28 namespace ROOT {
29 
30 namespace 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());
80  AnalyticalGradientCalculator gc(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
ROOT::Minuit2::MnPrint::Debug
void Debug(const Ts &... args)
Definition: MnPrint.h:138
ROOT::Minuit2::FumiliFCNBase
Extension of the FCNBase for the Fumili method.
Definition: FumiliFCNBase.h:46
MnStrategy.h
MnUserTransformation.h
FunctionMinimum.h
MinimumSeed.h
ROOT::Minuit2::FCNBase
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
Definition: FCNBase.h:45
ROOT::Minuit2::FumiliMinimizer::Minimize
FunctionMinimum Minimize(const FCNBase &, const MnUserParameterState &, const MnStrategy &, unsigned int maxfcn=0, double toler=0.1) const
Definition: FumiliMinimizer.cxx:34
MnUserParameterState.h
ROOT::Minuit2::MnUserParameterState::VariableParameters
unsigned int VariableParameters() const
Definition: MnUserParameterState.cxx:506
ROOT::Minuit2::MnPrint::Error
void Error(const Ts &... args)
Definition: MnPrint.h:120
MnUserParameters.h
Numerical2PGradientCalculator.h
ROOT::Minuit2::Numerical2PGradientCalculator
class performing the numerical gradient calculation
Definition: Numerical2PGradientCalculator.h:32
FCNGradientBase.h
ROOT::Minuit2::MnUserParameterState::Trafo
const MnUserTransformation & Trafo() const
Definition: MnUserParameterState.h:104
ROOT::Minuit2::FCNBase::Up
virtual double Up() const =0
Error definition of the function.
ROOT::Minuit2::FumiliGradientCalculator
Definition: FumiliGradientCalculator.h:23
FumiliGradientCalculator.h
ROOT::Minuit2::MnUserFcn
Wrapper used by Minuit of FCN interface containing a reference to the transformation object.
Definition: MnUserFcn.h:25
AnalyticalGradientCalculator.h
ROOT::Minuit2::FunctionMinimum
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
Definition: FunctionMinimum.h:33
ROOT::Minuit2::AnalyticalGradientCalculator
Definition: AnalyticalGradientCalculator.h:22
ROOT::Minuit2::FCNGradientBase
Extension of the FCNBase for providing the analytical Gradient of the function.
Definition: FCNGradientBase.h:34
ROOT::Minuit2::MnUserParameterState
class which holds the external user and/or internal Minuit representation of the parameters and error...
Definition: MnUserParameterState.h:33
ROOT::Minuit2::MnStrategy
API class for defining three levels of strategies: low (0), medium (1), high (>=2); acts on: Migrad (...
Definition: MnStrategy.h:27
FumiliMinimizer.h
MinimumSeedGenerator.h
MnUserFcn.h
MinimumBuilder.h
ROOT::Minuit2::FumiliMinimizer::SeedGenerator
const MinimumSeedGenerator & SeedGenerator() const
Accessor to the seed generator of the minimizer.
Definition: FumiliMinimizer.h:73
FumiliFCNBase.h
MnPrint.h
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4
ROOT::Minuit2::MinimumSeed
MinimumSeed contains the starting values for the minimization produced by the SeedGenerator.
Definition: MinimumSeed.h:31
MnConfig.h
ROOT::Minuit2::MnPrint
Definition: MnPrint.h:73
int
ROOT::Minuit2::ModularFunctionMinimizer::Minimize
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
Definition: ModularFunctionMinimizer.cxx:36