Hello,
I am trying to understand the examples given here:
https://root.cern.ch/numerical-minimization#multidim_minim
The problem is that the examples use a Functor which only takes in one argument. I want to use a function which has multiple parameters like:
double RosenBrock(double xx ,double A, double B)
{
const Double_t x = xx[0];
const Double_t y = xx[1];
const Double_t tmp1 = y-xx;
const Double_t tmp2 = 1-x;
return 100tmp1tmp1+Btmp2tmp2+A;
}
OR
how would I minimise a TF2 which is like A+Bx+Cx*y where A,B and C are all paramters which are assigned values by me before the minimisation process?
Would I do something like:
TF2 *f2=new TF2(“f2”,"[0]+[1]*x+[2]xy",0,10);
f2->SetParamters(1,2,3);
ROOT::Math::GSLMinimizer min( ROOT::Math::kVectorBFGS );
min.SetMaxFunctionCalls(1000000);
min.SetMaxIterations(100000);
min.SetTolerance(0.001);
min.SetFunction(f2);
double step[2] = {0.01,0.01};
double variable[2] = { -1.,1.2};
// 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();
ROOT Version: 6.14.04
Platform: Ubuntu 18.04
Compiler: 7.4.0