23double RosenBrock(
const double *xx )
29 return 100*tmp1*tmp1+tmp2*tmp2;
32int NumericalMinimization(
const char * minName =
"Minuit2",
33 const char *algoName =
"" ,
60 double step[2] = {0.01,0.01};
63 double variable[2] = { -1.,1.2};
64 if (randomSeed >= 0) {
66 variable[0] =
r.Uniform(-20,20);
67 variable[1] =
r.Uniform(-20,20);
79 const double *xs = minimum->
X();
80 std::cout <<
"Minimum: f(" << xs[0] <<
"," << xs[1] <<
"): "
84 if ( minimum->
MinValue() < 1.E-4 &&
f(xs) < 1.E-4)
85 std::cout <<
"Minimizer " << minName <<
" - " << algoName
86 <<
" converged to the right minimum" << std::endl;
88 std::cout <<
"Minimizer " << minName <<
" - " << algoName
89 <<
" failed to converge !!!" << std::endl;
90 Error(
"NumericalMinimization",
"fail to converge");
void Error(const char *location, const char *msgfmt,...)
static ROOT::Math::Minimizer * CreateMinimizer(const std::string &minimizerType="", const std::string &algoType="")
static method to create the corrisponding 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,...
virtual const double * X() const =0
return pointer to X values at the minimum
void SetMaxIterations(unsigned int maxiter)
set maximum iterations (one iteration can have many function calls)
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)=0
set the function to minimize
void SetTolerance(double tol)
set the tolerance
virtual bool Minimize()=0
method to perform the minimization
void SetPrintLevel(int level)
set print level
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)=0
set a new free variable
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
virtual double MinValue() const =0
return minimum function value
Random number generator class based on the maximally quidistributed combined Tausworthe generator by ...