Problem of Minuit2

Hi all,
I try to run Minuit2 Minimizer within the Minimizer interface in ROOT. (the “Minuit2Minimizer” example on http://root.cern.ch/drupal/content/numerical-minimization#multidim_minim) Minuit version is 5.20.00.

It comes that:

Processing NumericalMinimization.cpp…
Limitation: Reference member not supported. Please use pointer Minuit2/ABObj.h:98:
*** Interpreter error recovered ***

What does it mean? Thanks a lot for any help!

Best Regards,
Yi

It seems to me that you must (pre)compile that example with ACLiC in order to use it (i.e. you get this error when you try to run it as “interpreted code”, i.e. without “++”). Try:
root [0] .x NumericalMinimization.cxx++
or:
root [0] .L NumericalMinimization.cxx++
root [1] NumericalMinimization();

[quote=“Pepe Le Pew”]It seems to me that you must (pre)compile that example with ACLiC in order to use it (i.e. you get this error when you try to run it as “interpreted code”, i.e. without “++”). Try:
root [0] .x NumericalMinimization.cxx++
or:
root [0] .L NumericalMinimization.cxx++
root [1] NumericalMinimization();[/quote]

Thanks Pepe Le Pew!
Unfortunately, it doesn’t work. If I input either one of what you say:

Info in TUnixSystem::ACLiC: creating shared library
Minuit2-5.20.00/inc/./NumericalMinimization_cpp.so
In file included from Minuit2-5.20.00/inc/./NumericalMinimization.cpp:3,
from Minuit2-5.20.00/inc/./fileCAYI7U.h:32,
from Minuit2-5.20.00/inc/./fileCAYI7U.cxx:16:
Minuit2-5.20.00/inc/./Math/Functor.h:340: error: expected class-name before ‘{’ token
Minuit2-5.20.00/inc/./Math/Functor.h:345: error: IBaseFunctionMultiDim' does not name a type Minuit2-5.20.00/inc/./Math/Functor.h:346: error:IBaseFunctionMultiDim’ has not been declared
Minuit2-5.20.00/inc/./Math/Functor.h:346: error: ISO C++ forbids declaration of BaseFunc' with no type Minuit2-5.20.00/inc/./Math/Functor.h:346: error: expected;’ before "ImplBase"
Minuit2-5.20.00/inc/./Math/Functor.h:413: error: ISO C++ forbids declaration of ImplBase' with no type ... ... ... Minuit2-5.20.00/inc/./Math/Functor.h: In constructorROOT::Math::Functor::Functor(const Func&, unsigned int) [with Func = double ()(const double)]’:
Minuit2-5.20.00/inc/./NumericalMinimization.cpp:25: instantiated from here
Minuit2-5.20.00/inc/./Math/Functor.h:371: error: invalid conversion from ROOT::Math::FunctorHandler<ROOT::Math::Functor, double (*)(const double*)>*' toint’
g++: Minuit2-5.20.00/inc/./fileCAYI7U.o: No such file or directory
Error in : Compilation failed!
Error: Function NumericalMinimization() is not defined in current scope :0:
*** Interpreter error recovered ***

Here is NumericalMinimization.cpp:

#include<iostream>
#include "Minuit2/Minuit2Minimizer.h"
#include "Math/Functor.h"

double RosenBrock(const double *xx )
{
  const Double_t x = xx[0];
  const Double_t y = xx[1];
  const Double_t tmp1 = y-x*x;
  const Double_t tmp2 = 1-x;
  return 100*tmp1*tmp1+tmp2*tmp2;
}

int NumericalMinimization()
{
   // Choose method upon creation between:
   // kMigrad, kSimplex, kCombined, 
   // kScan, kFumili
   ROOT::Minuit2::Minuit2Minimizer min ( ROOT::Minuit2::kMigrad );

   min.SetMaxFunctionCalls(1000000);
   min.SetMaxIterations(100000);
   min.SetTolerance(0.001);

   ROOT::Math::Functor f(&RosenBrock,2);
   double step[2] = {0.01,0.01};
   double variable[2] = { -1.,1.2};

   min.SetFunction(f);

   // Set the free variables to be minimized!
   min.SetVariable(0,"x",variable[0], step[0]);
   min.SetVariable(1,"y",variable[1], step[1]);

   min.Minimize();

   const double *xs = min.X();
   cout << "Minimum: f(" << xs[0] << "," << xs[1] << "): "
        << RosenBrock(xs) << endl;

   return 0;
}

Hi,

It looks to me you are missing some header files. Are you using a standalone version, Minuit2-5.22 with a separate ROOT ? If you are using ROOT, you should use the Minuit2 version budge within ROOT, which you can enable by configure ROOT by doing ./configure --enable-minuit2

Best Regards
Lorenzo

[quote=“moneta”]Hi,

It looks to me you are missing some header files. Are you using a standalone version, Minuit2-5.22 with a separate ROOT ? If you are using ROOT, you should use the Minuit2 version budge within ROOT, which you can enable by configure ROOT by doing ./configure --enable-minuit2

Best Regards
Lorenzo[/quote]

Hi,
I think that’s the key. Besides, I wonder what the difference between classes TMinuit and ROOT::Math::Minimizer is. Thanks!

Regards,
Yi