Mantid
Loading...
Searching...
No Matches
DerivMinimizer.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2009 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
13#include "MantidCurveFitting/DllConfig.h"
14
15#include <gsl/gsl_multifit_nlin.h>
16#include <gsl/gsl_multimin.h>
17
18namespace Mantid {
19namespace CurveFitting {
20namespace FuncMinimisers {
27class MANTID_CURVEFITTING_DLL DerivMinimizer : public API::IFuncMinimizer {
28public:
31 DerivMinimizer(const double stepSize, const double tolerance);
33 ~DerivMinimizer() override;
34
36 bool iterate(size_t) override;
38 double costFunctionVal() override;
40 void calCovarianceMatrix(gsl_matrix *covar, double epsrel = 0.0001);
42 void initialize(API::ICostFunction_sptr function, size_t maxIterations = 0) override;
44 void setStopGradient(const double value);
45
46protected:
48 virtual const gsl_multimin_fdfminimizer_type *getGSLMinimizerType() = 0;
49
52
54 gsl_multimin_fdfminimizer *m_gslSolver;
55
57 gsl_multimin_function_fdf m_gslMultiminContainer;
58
60 gsl_vector *m_x;
61
65 double m_stepSize;
69 static double fun(const gsl_vector *x, void *params);
71 static void dfun(const gsl_vector *x, void *params, gsl_vector *g);
73 static void fundfun(const gsl_vector *x, void *params, double *f, gsl_vector *g);
74
75private:
77 void initGSLMMin();
78};
79
80} // namespace FuncMinimisers
81} // namespace CurveFitting
82} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
double tolerance
An interface for function minimizers.
A wrapper around the GSL functions implementing a minimizer using derivatives.
gsl_multimin_function_fdf m_gslMultiminContainer
GSL container.
double m_stopGradient
the norm of the gradient at which iterations stop
void calCovarianceMatrix(gsl_matrix *covar, double epsrel=0.0001)
Calculate the covariance matrix.
gsl_multimin_fdfminimizer * m_gslSolver
pointer to the GSL solver doing the work
virtual const gsl_multimin_fdfminimizer_type * getGSLMinimizerType()=0
Return a concrete type to initialize m_gslSolver with.
API::ICostFunction_sptr m_costFunction
Function to minimize.
gsl_vector * m_x
GSL vector with function parameters.
std::shared_ptr< ICostFunction > ICostFunction_sptr
define a shared pointer to a cost function
Definition: ICostFunction.h:60
Helper class which provides the Collimation Length for SANS instruments.