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)
input : minimizer name + algorithm name randomSeed: = <0 : fixed value: 0 random with seed 0; >0 random with given seed
#include <iostream>
{
}
{
std::cerr <<
"Error: cannot create minimizer \"" <<
minName
<< "\". Maybe the required library was not built?" << std::endl;
return 1;
}
minimum->SetMaxFunctionCalls(1000000);
double step[2] = {0.01,0.01};
double variable[2] = { -1.,1.2};
variable[0] =
r.Uniform(-20,20);
variable[1] =
r.Uniform(-20,20);
}
minimum->SetVariable(0,
"x",variable[0], step[0]);
minimum->SetVariable(1,
"y",variable[1], step[1]);
std::cout <<
"Minimum: f(" <<
xs[0] <<
"," <<
xs[1] <<
"): "
<<
minimum->MinValue() << std::endl;
<< " converged to the right minimum" << std::endl;
else {
<< " failed to converge !!!" << std::endl;
Error(
"NumericalMinimization",
"fail to converge");
}
return 0;
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
static ROOT::Math::Minimizer * CreateMinimizer(const std::string &minimizerType="", const std::string &algoType="")
static method to create the corresponding Minimizer given the string Supported Minimizers types are: ...
Documentation for class Functor class.
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...
- Author
- Lorenzo Moneta
Definition in file NumericalMinimization.C.