23double RosenBrock(
const double *xx )
25 const double x = xx[0];
26 const double y = xx[1];
27 const double tmp1 =
y-
x*
x;
28 const double tmp2 = 1-
x;
29 return 100*tmp1*tmp1+tmp2*tmp2;
32int NumericalMinimization(
const char * minName =
"Minuit2",
33 const char *algoName =
"" ,
51 std::cerr <<
"Error: cannot create minimizer \"" << minName
52 <<
"\". Maybe the required library was not built?" << std::endl;
65 double step[2] = {0.01,0.01};
68 double variable[2] = { -1.,1.2};
69 if (randomSeed >= 0) {
71 variable[0] =
r.Uniform(-20,20);
72 variable[1] =
r.Uniform(-20,20);
84 const double *xs = minimum->
X();
85 std::cout <<
"Minimum: f(" << xs[0] <<
"," << xs[1] <<
"): "
90 std::cout <<
"Minimizer " << minName <<
" - " << algoName
91 <<
" converged to the right minimum" << std::endl;
93 std::cout <<
"Minimizer " << minName <<
" - " << algoName
94 <<
" failed to converge !!!" << std::endl;
95 Error(
"NumericalMinimization",
"fail to converge");
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
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,...
virtual const double * X() const =0
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
Random number generator class based on the maximally equidistributed combined Tausworthe generator by...