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;
195 return gsl_multimin_test_gradient(
fVec, absTol);
203 const gsl_multimin_fdfminimizer_type *
fType;
#define MATH_INFO_MSG(loc, str)
Pre-processor macro to report messages which can be configured to use ROOT error or simply an std::io...
Wrapper for a multi-dimensional function with derivatives used in GSL multidim minimization algorithm...
gsl_multimin_function_fdf * GetFunc()
void SetFunction(const FuncType &f)
Fill gsl function structure from a C++ Function class.
GSLMultiMinimizer class , for minimizing multi-dimensional function using derivatives.
GSLMultiMinimizer & operator=(const GSLMultiMinimizer &rhs)
Assignment operator.
GSLMultiMinDerivFunctionWrapper fFunc
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...
const gsl_multimin_fdfminimizer_type * fType
gsl_multimin_fdfminimizer * fMinimizer
double Minimum() const
function value at the minimum
double * Gradient() const
gradient value at the minimum
int Restart()
restart minimization from current point
int TestGradient(const double *g, double absTol) const
test gradient (require a vector gradient)
GSLMultiMinimizer(ROOT::Math::EGSLMinimizerType type)
Default constructor.
GSLMultiMinimizer(const GSLMultiMinimizer &)
Copy constructor.
double * X() const
x values at the minimum
~GSLMultiMinimizer()
Destructor.
void CreateMinimizer(unsigned int n)
create the minimizer from the type and size
int TestGradient(double absTol) const
test gradient (ask from minimizer gradient vector)
Interface (abstract class) for multi-dimensional functions providing a gradient calculation.
virtual unsigned int NDim() const=0
Retrieve the dimension of the function.
EGSLMinimizerType
enumeration specifying the types of GSL minimizers
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...