17 double tmp1 = (x[1] - x[0]*x[0]);
18 double tmp2 = (1.-x[0]);
19 return 100.*tmp1*tmp1 + tmp2*tmp2;
36 double variable[2] = { -1.,1.2};
38 double step[2] = {0.01,0.01};
49 const double *xs = min->
X();
50 std::cout <<
"Minimum: f(" << xs[0] <<
"," << xs[1] <<
"): " 54 if ( min->
MinValue() < 1.E-4 &&
f(xs) < 1.E-4) {
55 std::cout <<
"Minuit2 - " << algoName
56 <<
" converged to the right minimum" << std::endl;
60 std::cerr <<
"ERROR: Minuit2 - " << algoName
61 <<
" failed to converge !!!" << std::endl;
66 int main(
int argc,
const char *argv[]) {
69 std::string algoName =
"";
72 for (
int i = 1 ; i < argc ; i++) {
73 std::string arg = argv[i] ;
78 else if (arg ==
"-vv") {
81 else if (arg ==
"-vvv") {
84 else if (arg ==
"-n") {
85 std::cout <<
"using method " << argv[i+1] <<
" to minimize" << std::endl;
88 else if (arg ==
"-h") {
89 std::cout <<
"usage: demoMinimize [ options ] " << std::endl;
90 std::cout <<
"" << std::endl;
91 std::cout <<
" -n <algorithm> : use given algorithm (possible names: simplex, minimize, scan, fumili)" << std::endl;
92 std::cout <<
" -v : set minimul verbose mode to show final result" << std::endl;
93 std::cout <<
" -vv : set medium verbose mode: show function value and edm at each minimization step" << std::endl;
94 std::cout <<
" -vvv : set very verbose mode: show full result at each minimization step" << std::endl;
int main(int argc, const char *argv[])
double Rosenbrock(const double *x)
test of a pure minimization passing a user function This is an example of running Minuit2 using the M...
Documentation for class Functor class.
int demoMinimizer(const char *algoName, int printlevel)
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2, Minuit, GSL, etc..) Plug-in's exist in ROOT to be able to instantiate the derived classes like ROOT::Math::GSLMinimizer or ROOT::Math::Minuit2Minimizer via the plug-in manager.
virtual double MinValue() const =0
return minimum function value
virtual bool Minimize()=0
method to perform the minimization
virtual const double * X() const =0
return pointer to X values at the minimum
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)=0
set the function to minimize
void SetMaxFunctionCalls(unsigned int maxfcn)
set maximum of function calls
Minuit2Minimizer class implementing the ROOT::Math::Minimizer interface for Minuit2 minimization algo...
void SetTolerance(double tol)
set the tolerance
virtual bool SetVariable(unsigned int ivar, const std::string &name, double val, double step)=0
set a new free variable
void SetPrintLevel(int level)
set print level