|
Mantid
|
Cost function for least squares. More...
#include <CostFuncLeastSquares.h>
Public Member Functions | |
| CostFuncLeastSquares () | |
| Constructor. More... | |
| std::string | name () const override |
| Get name of minimizer. More... | |
| std::string | shortName () const override |
| Get short name of minimizer - useful for say labels in guis. More... | |
Public Member Functions inherited from Mantid::CurveFitting::CostFunctions::CostFuncFitting | |
| void | applyTies () |
| Apply ties in the fitting function. More... | |
| virtual void | calCovarianceMatrix (EigenMatrix &covar, double epsrel=1e-8) |
| Calculates covariance matrix. More... | |
| virtual void | calFittingErrors (const EigenMatrix &covar, double chi2) |
| Calculate fitting errors. More... | |
| CostFuncFitting () | |
| Constructor. More... | |
| virtual void | deriv (std::vector< double > &der) const override |
| Calculate the derivatives of the cost function. More... | |
| void | drop () |
| Discard saved parameters, derivatives and hessian. More... | |
| const EigenVector & | getDeriv () const |
| Return cached or calculate the drivatives. More... | |
| API::FunctionDomain_sptr | getDomain () const |
| Get the domain the fitting function is applied to. More... | |
| virtual API::IFunction_sptr | getFittingFunction () const |
| Get fitting function. More... | |
| const EigenMatrix & | getHessian () const |
| Return cached or calculate the Hessian. More... | |
| double | getParameter (size_t i) const override |
| Get i-th parameter. More... | |
| void | getParameters (EigenVector ¶ms) const |
| Get all parameters into a GSLVector. More... | |
| API::FunctionValues_sptr | getValues () const |
| Get FunctionValues where function values are stored. More... | |
| size_t | nParams () const override |
| Number of parameters. More... | |
| std::string | parameterName (size_t i) const |
| Get name of i-th parameter. More... | |
| void | pop () |
| Restore saved parameters, derivatives and hessian. More... | |
| void | push () |
| Save current parameters, derivatives and hessian. More... | |
| void | reset () const |
| Reset the fitting function (neccessary if parameters get fixed/unfixed) More... | |
| virtual void | setFittingFunction (API::IFunction_sptr function, API::FunctionDomain_sptr domain, API::FunctionValues_sptr values) |
| Set fitting function. More... | |
| void | setParameter (size_t i, const double &value) override |
| Set i-th parameter. More... | |
| void | setParameters (const EigenVector ¶ms) |
| Set all parameters. More... | |
| virtual double | val () const override |
| Calculate value of cost function. More... | |
| virtual double | valAndDeriv (std::vector< double > &der) const override |
| Calculate the value and the derivatives of the cost function. More... | |
| virtual double | valDerivHessian (bool evalDeriv=true, bool evalHessian=true) const |
| Calculate the value, the first and the second derivatives of the cost function. More... | |
Public Member Functions inherited from Mantid::API::ICostFunction | |
| virtual void | deriv (std::vector< double > &der) const =0 |
| Calculate the derivatives of the cost function. More... | |
| virtual double | getParameter (size_t i) const =0 |
| Get i-th parameter. More... | |
| virtual std::string | name () const =0 |
| Get name of minimizer. More... | |
| virtual size_t | nParams () const =0 |
| Number of parameters. More... | |
| virtual void | setParameter (size_t i, const double &value)=0 |
| Set i-th parameter. More... | |
| virtual std::string | shortName () const |
| Get short name of minimizer - useful for say labels in guis. More... | |
| virtual double | val () const =0 |
| Calculate value of cost function. More... | |
| virtual double | valAndDeriv (std::vector< double > &der) const =0 |
| Calculate the value and the derivatives of the cost function. More... | |
| virtual | ~ICostFunction ()=default |
| Virtual destructor. More... | |
Protected Member Functions | |
| void | addVal (API::FunctionDomain_sptr domain, API::FunctionValues_sptr values) const override |
| Add a contribution to the cost function value from the fitting function evaluated on a particular domain. More... | |
| void | addValDerivHessian (API::IFunction_sptr function, API::FunctionDomain_sptr domain, API::FunctionValues_sptr values, bool evalDeriv=true, bool evalHessian=true) const override |
| Update the cost function, derivatives and hessian by adding values calculated on a domain. More... | |
| void | calActiveCovarianceMatrix (EigenMatrix &covar, double epsrel=1e-8) override |
| Calculates covariance matrix for fitting function's active parameters. More... | |
| virtual std::vector< double > | getFitWeights (API::FunctionValues_sptr values) const |
| Get mapped weights from FunctionValues. More... | |
Protected Member Functions inherited from Mantid::CurveFitting::CostFunctions::CostFuncFitting | |
| virtual void | addVal (API::FunctionDomain_sptr domain, API::FunctionValues_sptr values) const =0 |
| Increment to the cost function by evaluating it on a domain. More... | |
| virtual void | addValDerivHessian (API::IFunction_sptr function, API::FunctionDomain_sptr domain, API::FunctionValues_sptr values, bool evalDeriv=true, bool evalHessian=true) const =0 |
| Increments the cost function and its derivatives by evaluating them on a domain. More... | |
| virtual void | calActiveCovarianceMatrix (EigenMatrix &covar, double epsrel=1e-8) |
| Calculates covariance matrix for fitting function's active parameters. More... | |
| void | calTransformationMatrixNumerically (EigenMatrix &tm) |
| Calculate the transformation matrix T by numeric differentiation. More... | |
| void | checkValidity () const |
| Throw a runtime_error if function is invalid. More... | |
| bool | isValid () const |
| Is the function set and valid? More... | |
| void | setDirty () |
| Set all dirty flags. More... | |
Protected Attributes | |
| double | m_factor |
Protected Attributes inherited from Mantid::CurveFitting::CostFunctions::CostFuncFitting | |
| EigenVector | m_der |
| bool | m_dirtyDeriv |
| dirty derivatives flag More... | |
| bool | m_dirtyHessian |
| dirty hessian flag More... | |
| bool | m_dirtyVal |
| dirty value flag More... | |
| API::FunctionDomain_sptr | m_domain |
| Shared pointer to the function domain. More... | |
| API::IFunction_sptr | m_function |
| Shared pointer to the fitting function. More... | |
| EigenMatrix | m_hessian |
| bool | m_includePenalty |
| Flag to include constraint in cost function value. More... | |
| std::vector< size_t > | m_indexMap |
| maps the cost function's parameters to the ones of the fitting function. More... | |
| size_t | m_numberFunParams |
| Number of all parameters in the fitting function. More... | |
| bool | m_pushed |
| EigenVector | m_pushedParams |
| double | m_pushedValue |
| double | m_value |
| API::FunctionValues_sptr | m_values |
| Shared poinetr to the function values. More... | |
Cost function for least squares.
Definition at line 24 of file CostFuncLeastSquares.h.
| Mantid::CurveFitting::CostFunctions::CostFuncLeastSquares::CostFuncLeastSquares | ( | ) |
Constructor.
Definition at line 32 of file CostFuncLeastSquares.cpp.
|
overrideprotectedvirtual |
Add a contribution to the cost function value from the fitting function evaluated on a particular domain.
| domain | :: A domain |
| values | :: Values |
Implements Mantid::CurveFitting::CostFunctions::CostFuncFitting.
Definition at line 39 of file CostFuncLeastSquares.cpp.
References getFitWeights(), m_factor, Mantid::CurveFitting::CostFunctions::CostFuncFitting::m_function, Mantid::CurveFitting::CostFunctions::CostFuncFitting::m_value, PARALLEL_ATOMIC, and Mantid::CurveFitting::CostFunctions::CostFuncFitting::val().
Referenced by Mantid::CurveFitting::SeqDomain::rwpVal().
|
overrideprotectedvirtual |
Update the cost function, derivatives and hessian by adding values calculated on a domain.
| function | :: Function to use to calculate the value and the derivatives |
| domain | :: The domain. |
| values | :: The fit function values |
| evalDeriv | :: Flag to evaluate the derivatives |
| evalHessian | :: Flag to evaluate the Hessian |
Implements Mantid::CurveFitting::CostFunctions::CostFuncFitting.
Definition at line 65 of file CostFuncLeastSquares.cpp.
References Mantid::Geometry::d, Mantid::CurveFitting::EigenVector::get(), Mantid::CurveFitting::EigenMatrix::get(), Mantid::API::Jacobian::get(), getFitWeights(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::m_der, Mantid::CurveFitting::CostFunctions::CostFuncFitting::m_hessian, Mantid::CurveFitting::CostFunctions::CostFuncFitting::m_value, PARALLEL_ATOMIC, PARALLEL_CRITICAL, Mantid::CurveFitting::EigenVector::set(), Mantid::CurveFitting::EigenMatrix::set(), Mantid::CurveFitting::EigenVector::size(), Mantid::CurveFitting::EigenMatrix::size1(), Mantid::CurveFitting::EigenMatrix::size2(), UNUSED_ARG, and Mantid::Geometry::y.
Referenced by Mantid::CurveFitting::SeqDomain::rwpValDerivHessian().
|
overrideprotectedvirtual |
Calculates covariance matrix for fitting function's active parameters.
| covar | :: Output cavariance matrix. |
| epsrel | :: Tolerance. |
Reimplemented from Mantid::CurveFitting::CostFunctions::CostFuncFitting.
Reimplemented in Mantid::CurveFitting::CostFunctions::CostFuncUnweightedLeastSquares.
Definition at line 158 of file CostFuncLeastSquares.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, Mantid::CurveFitting::EigenMatrix::get(), Mantid::CurveFitting::EigenMatrix::invert(), Mantid::Kernel::Logger::is(), Mantid::CurveFitting::EigenMatrix::isEmpty(), Mantid::CurveFitting::CostFunctions::CostFuncFitting::m_hessian, Mantid::CurveFitting::EigenMatrix::size1(), Mantid::CurveFitting::EigenMatrix::size2(), UNUSED_ARG, and Mantid::CurveFitting::CostFunctions::CostFuncFitting::valDerivHessian().
Referenced by Mantid::CurveFitting::CostFunctions::CostFuncUnweightedLeastSquares::calActiveCovarianceMatrix().
|
protectedvirtual |
Get mapped weights from FunctionValues.
Reimplemented in Mantid::CurveFitting::CostFunctions::CostFuncRwp, and Mantid::CurveFitting::CostFunctions::CostFuncUnweightedLeastSquares.
Definition at line 144 of file CostFuncLeastSquares.cpp.
Referenced by addVal(), and addValDerivHessian().
|
inlineoverridevirtual |
Get name of minimizer.
Implements Mantid::API::ICostFunction.
Reimplemented in Mantid::CurveFitting::CostFunctions::CostFuncRwp, and Mantid::CurveFitting::CostFunctions::CostFuncUnweightedLeastSquares.
Definition at line 30 of file CostFuncLeastSquares.h.
|
inlineoverridevirtual |
Get short name of minimizer - useful for say labels in guis.
Reimplemented from Mantid::API::ICostFunction.
Reimplemented in Mantid::CurveFitting::CostFunctions::CostFuncRwp, and Mantid::CurveFitting::CostFunctions::CostFuncUnweightedLeastSquares.
Definition at line 33 of file CostFuncLeastSquares.h.
|
protected |
Definition at line 46 of file CostFuncLeastSquares.h.
Referenced by addVal().