27 #ifndef ROOT_Math_GSLMultiMinimizer
28 #define ROOT_Math_GSLMultiMinimizer
30 #include "gsl/gsl_vector.h"
31 #include "gsl/gsl_multimin.h"
32 #include "gsl/gsl_version.h"
68 fType = gsl_multimin_fdfminimizer_conjugate_fr;
71 fType = gsl_multimin_fdfminimizer_conjugate_pr;
74 fType = gsl_multimin_fdfminimizer_vector_bfgs;
77 #if (GSL_MAJOR_VERSION > 1) || ((GSL_MAJOR_VERSION == 1) && (GSL_MINOR_VERSION >= 9))
79 fType = gsl_multimin_fdfminimizer_vector_bfgs2;
81 MATH_INFO_MSG(
"GSLMultiMinimizer",
"minimizer BFSG2 does not exist with this GSL version , use BFGS");
82 fType = gsl_multimin_fdfminimizer_vector_bfgs;
86 fType = gsl_multimin_fdfminimizer_steepest_descent;
89 fType = gsl_multimin_fdfminimizer_conjugate_fr;
101 if (
fVec != 0) gsl_vector_free(
fVec);
116 if (
this == &rhs)
return *
this;
130 unsigned int ndim = func.
NDim();
133 if (
fVec != 0) gsl_vector_free(
fVec);
134 fVec = gsl_vector_alloc( ndim );
135 std::copy(x,x+ndim,
fVec->data);
148 return std::string(gsl_multimin_fdfminimizer_name(
fMinimizer) );
153 return gsl_multimin_fdfminimizer_iterate(
fMinimizer);
159 gsl_vector *
x = gsl_multimin_fdfminimizer_x(
fMinimizer);
166 return gsl_multimin_fdfminimizer_minimum(
fMinimizer);
172 gsl_vector *
g = gsl_multimin_fdfminimizer_gradient(
fMinimizer);
179 return gsl_multimin_fdfminimizer_restart(
fMinimizer);
185 gsl_vector *
g = gsl_multimin_fdfminimizer_gradient(
fMinimizer);
186 return gsl_multimin_test_gradient( g, absTol);
191 if (
fVec == 0 )
return -1;
192 unsigned int n =
fVec->size;
193 if (n == 0 )
return -1;
194 std::copy(g,g+n,
fVec->data);
195 return gsl_multimin_test_gradient(
fVec, absTol);
203 const gsl_multimin_fdfminimizer_type *
fType;
GSLMultiMinimizer(ROOT::Math::EGSLMinimizerType type)
Default constructor.
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
void SetFunction(const FuncType &f)
Fill gsl function structure from a C++ Function class.
Namespace for new ROOT classes and functions.
const gsl_multimin_fdfminimizer_type * fType
void CreateMinimizer(unsigned int n)
create the minimizer from the type and size
EGSLMinimizerType
enumeration specifying the types of GSL minimizers
GSLMultiMinDerivFunctionWrapper fFunc
gsl_multimin_fdfminimizer * fMinimizer
~GSLMultiMinimizer()
Destructor.
GSLMultiMinimizer(const GSLMultiMinimizer &)
Copy constructor.
int TestGradient(const double *g, double absTol) const
test gradient (require a vector gradient)
#define MATH_INFO_MSG(loc, str)
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
gsl_multimin_function_fdf * GetFunc()
int Set(const ROOT::Math::IMultiGradFunction &func, const double *x, double stepSize, double tol)
set the function to be minimize the initial minimizer parameters, step size and tolerance in the line...
double * Gradient() const
gradient value at the minimum
int Restart()
restart minimization from current point
double * X() const
x values at the minimum
double func(double *x, double *p)
GSLMultiMinimizer class , for minimizing multi-dimensional function using derivatives.
Namespace for new Math classes and functions.
Wrapper for a multi-dimensional function with derivatives used in GSL multidim minimization algorithm...
double Minimum() const
function value at the minimum
GSLMultiMinimizer & operator=(const GSLMultiMinimizer &rhs)
Assignment operator.
int TestGradient(double absTol) const
test gradient (ask from minimizer gradient vector)