Example on how to use the new Minimizer class in ROOT Show usage with all the possible minimizers.
Minimize the Rosenbrock function (a 2D -function) This example is described also in http://root.cern.ch/drupal/content/numerical-minimization#multidim_minim input : minimizer name + algorithm name randomSeed: = <0 : fixed value: 0 random with seed 0; >0 random with given seed
#include <iostream>
{
return 100*tmp1*tmp1+tmp2*tmp2;
}
int NumericalMinimization(const char * minName = "Minuit2",
const char *algoName = "" ,
int randomSeed = -1)
{
double step[2] = {0.01,0.01};
double variable[2] = { -1.,1.2};
if (randomSeed >= 0) {
}
const double *xs = minimum->
X();
std::cout << "Minimum: f(" << xs[0] << "," << xs[1] << "): "
if ( minimum->
MinValue() < 1.E-4 &&
f(xs) < 1.E-4)
std::cout << "Minimizer " << minName << " - " << algoName
<< " converged to the right minimum" << std::endl;
else {
std::cout << "Minimizer " << minName << " - " << algoName
<< " failed to converge !!!" << std::endl;
Error(
"NumericalMinimization",
"fail to converge");
}
return 0;
}
- Author
- Lorenzo Moneta
Definition in file NumericalMinimization.C.