Mantid
Loading...
Searching...
No Matches
IFuncMinimizer.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//----------------------------------------------------------------------
12#include "MantidAPI/DllConfig.h"
15
16#include <string>
17
18namespace Mantid {
19namespace API {
20// Forward declaration
21class IFitFunction;
22
26namespace MinimizerStatus {
28inline const std::string SUCCESS = "success";
31inline const std::string CHANGES_IN_FUNCTION_TOO_SMALL = "Changes in function value are too small";
34inline const std::string CHANGES_IN_PARAMETER_TOO_SMALL = "Changes in parameter value are too small";
35} // namespace MinimizerStatus
36
42class MANTID_API_DLL IFuncMinimizer : public Kernel::PropertyManager {
43public:
47 virtual void initialize(API::ICostFunction_sptr function, size_t maxIterations = 1000) = 0;
48
50 virtual std::string name() const = 0;
51
56 virtual bool iterate(size_t iteration) = 0;
57
59 virtual bool minimize(size_t maxIterations = 1000);
60
62 virtual std::string getError() const { return m_errorString; }
63
65 virtual double costFunctionVal() = 0;
66
68 virtual void finalize() {}
69
70protected:
72 std::string m_errorString;
73};
74
75using IFuncMinimizer_sptr = std::shared_ptr<IFuncMinimizer>;
76
77} // namespace API
78} // namespace Mantid
An interface for function minimizers.
virtual bool iterate(size_t iteration)=0
Do one iteration.
virtual void initialize(API::ICostFunction_sptr function, size_t maxIterations=1000)=0
Initialize minimizer.
virtual std::string getError() const
Get the error string.
std::string m_errorString
Error string.
virtual void finalize()
Finalize minimization, eg store additional outputs.
virtual double costFunctionVal()=0
Get value of cost function.
virtual std::string name() const =0
Get name of minimizer.
Property manager helper class.
const std::string CHANGES_IN_FUNCTION_TOO_SMALL
Reported by Levenberg-Marquardt when the change in the cost function between iterations has fallen be...
const std::string CHANGES_IN_PARAMETER_TOO_SMALL
Reported by Levenberg-Marquardt when the change in the parameter values between iterations has fallen...
const std::string SUCCESS
Reported when a minimizer has fully converged.
std::shared_ptr< IFuncMinimizer > IFuncMinimizer_sptr
std::shared_ptr< ICostFunction > ICostFunction_sptr
define a shared pointer to a cost function
Helper class which provides the Collimation Length for SANS instruments.