Mantid
Loading...
Searching...
No Matches
ICostFunction.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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 "MantidKernel/System.h"
14
15namespace Mantid {
16namespace API {
24class MANTID_API_DLL ICostFunction {
25public:
27 virtual ~ICostFunction() = default;
28
30 virtual std::string name() const = 0;
31
33 virtual std::string shortName() const { return "Quality"; }
34
38 virtual double getParameter(size_t i) const = 0;
42 virtual void setParameter(size_t i, const double &value) = 0;
44 virtual size_t nParams() const = 0;
45
47 virtual double val() const = 0;
48
51 virtual void deriv(std::vector<double> &der) const = 0;
52
56 virtual double valAndDeriv(std::vector<double> &der) const = 0;
57};
58
60using ICostFunction_sptr = std::shared_ptr<ICostFunction>;
61
66#define DECLARE_COSTFUNCTION(classname, username) \
67 namespace { \
68 Mantid::Kernel::RegistrationHelper register_costfunction_##classname( \
69 ((Mantid::API::CostFunctionFactory::Instance().subscribe<classname>(#username)), 0)); \
70 }
71
72} // namespace API
73} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
An interface for specifying the cost function to be used with Fit algorithm or minimizers,...
Definition: ICostFunction.h:24
virtual double getParameter(size_t i) const =0
Get i-th parameter.
virtual ~ICostFunction()=default
Virtual destructor.
virtual std::string shortName() const
Get short name of minimizer - useful for say labels in guis.
Definition: ICostFunction.h:33
virtual void setParameter(size_t i, const double &value)=0
Set i-th parameter.
virtual void deriv(std::vector< double > &der) const =0
Calculate the derivatives of the cost function.
virtual size_t nParams() const =0
Number of parameters.
virtual double val() const =0
Calculate value of cost function.
virtual std::string name() const =0
Get name of minimizer.
virtual double valAndDeriv(std::vector< double > &der) const =0
Calculate the value and the derivatives of the cost function.
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.