40#include "gsl/gsl_min.h"
41#include "gsl/gsl_errno.h"
58 const gsl_min_fminimizer_type* T = nullptr ;
62 T = gsl_min_fminimizer_goldensection;
65 T = gsl_min_fminimizer_brent;
69 T = gsl_min_fminimizer_brent;
97 std::cout <<
" [ "<< xlow <<
" , " << xup <<
" ]" << std::endl;
102 std::cerr <<
"GSLMinimizer1D: Error: Interval [ "<< xlow <<
" , " << xup <<
" ] does not contain a minimum" << std::endl;
113 std::cerr <<
"GSLMinimizer1D- Error: Function has not been set in Minimizer" << std::endl;
117 int status = gsl_min_fminimizer_iterate(
fMinimizer->Get());
161 return gsl_min_fminimizer_name(
fMinimizer->Get() );
174 MATH_ERROR_MSG(
"GSLMinimizer1D::Minimize",
"error returned when performing an iteration");
180 std::cout <<
"Min1D - iteration " << iter <<
" interval : [ " <<
fXlow <<
" , " <<
fXup <<
" ] min = " <<
fXmin
181 <<
" fmin " <<
fMin <<
" f(a) " <<
fLow <<
" f(b) " <<
fUp << std::endl;
192 while (status == GSL_CONTINUE && iter < maxIter);
193 if (status == GSL_CONTINUE) {
195 MATH_INFO_MSGVAL(
"GSLMinimizer1D::Minimize",
"exceeded max iterations, reached tolerance is not sufficient",tol);
204 return gsl_min_test_interval(xlow, xup, epsAbs, epsRel);
#define MATH_INFO_MSGVAL(loc, txt, x)
#define MATH_ERROR_MSG(loc, str)
wrapper class for gsl_min_fminimizer structure
Wrapper class to the gsl_function C structure.
double FValMinimum() const override
Return function value at current estimate of the minimum.
const char * Name() const override
Return name of minimization algorithm.
int Iterate()
Perform a minimizer iteration and if an unexpected problem occurs then an error code will be returned...
GSL1DMinimizerWrapper * fMinimizer
double XLower() const override
Return current lower bound of the minimization interval.
static int TestInterval(double xlow, double xup, double epsAbs, double epsRel)
Test convergence of the interval.
GSLMinimizer1D(Minim1D::Type type=Minim1D::kBRENT)
Construct the minimizer passing the minimizer type using the Minim1D::Algorithm enumeration.
void SetFunction(const UserFunc &f, double xmin, double xlow, double xup)
Set, or reset, minimizer to use the function f and the initial search interval [xlow,...
double XUpper() const override
Return current upper bound of the minimization interval.
double FValUpper() const override
Return function value at current upper bound of the minimization interval.
~GSLMinimizer1D() override
Destructor: free allocated resources.
double FValLower() const override
Return function value at current lower bound of the minimization interval.
GSLFunctionWrapper * fFunction
double XMinimum() const override
Return current estimate of the position of the minimum.
bool Minimize(int maxIter, double absTol, double relTol) override
Find minimum position iterating until convergence specified by the absolute and relative tolerance or...
Type
Enumeration with One Dimensional Minimizer Algorithms.
double(* GSLFuncPointer)(double, void *)
Function pointer corresponding to gsl_function signature.