Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer Class Reference

Trust Region minimizer class using the DTRS method of GALAHAD. More...

#include <TrustRegionMinimizer.h>

Inheritance diagram for Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer:
Mantid::API::IFuncMinimizer Mantid::Kernel::PropertyManager Mantid::Kernel::IPropertyManager

Public Member Functions

double costFunctionVal () override
 Return current value of the cost function.
 
void initialize (API::ICostFunction_sptr costFunction, size_t maxIterations=0) override
 Initialize minimizer, i.e. pass a function to minimize.
 
bool iterate (size_t) override
 Do one iteration.
 
std::string name () const override
 Name of the minimizer.
 
 TrustRegionMinimizer ()
 constructor and destructor
 
- Public Member Functions inherited from Mantid::API::IFuncMinimizer
virtual void finalize ()
 Finalize minimization, eg store additional outputs.
 
virtual std::string getError () const
 Get the error string.
 
virtual bool minimize (size_t maxIterations=1000)
 Perform iteration with minimizer and return true if successful.
 
- Public Member Functions inherited from Mantid::Kernel::PropertyManager
::Json::Value asJson (bool withDefaultValues=false) const override
 Return the property manager serialized as a json object.
 
std::string asString (bool withDefaultValues=false) const override
 Return the property manager serialized as a string.
 
void clear () override final
 Clears the whole property map.
 
PropertyManagercloneInTimeROI (const Kernel::TimeROI &timeROI)
 Create a partial copy of this object such that every time series property is cloned according to the input TimeROI.
 
void declareOrReplaceProperty (std::unique_ptr< Property > p, const std::string &doc="") override
 Add or replace a property in the list of managed properties.
 
void declareProperty (const std::string &name, const char *value, const std::string &doc, IValidator_sptr validator=std::make_shared< NullValidator >(), const unsigned int direction=Direction::Input)
 Specialised version of declareProperty template method to prevent the creation of a PropertyWithValue of type const char* if an argument in quotes is passed (it will be converted to a string).
 
void declareProperty (const std::string &name, const char *value, const unsigned int direction)
 Add a property of string type to the list of managed properties.
 
void declareProperty (const std::string &name, const char *value, IValidator_sptr validator=std::make_shared< NullValidator >(), const std::string &doc=std::string(), const unsigned int direction=Direction::Input)
 Specialised version of declareProperty template method to prevent the creation of a PropertyWithValue of type const char* if an argument in quotes is passed (it will be converted to a string).
 
template<typename T >
void declareProperty (const std::string &name, T value, const std::string &doc, const unsigned int direction=Direction::Input)
 Add a property to the list of managed properties with no validator.
 
template<typename T >
void declareProperty (const std::string &name, T value, const unsigned int direction)
 Add a property of the template type to the list of managed properties.
 
template<typename T >
void declareProperty (const std::string &name, T value, IValidator_sptr validator=std::make_shared< NullValidator >(), const std::string &doc="", const unsigned int direction=Direction::Input)
 Add a property of the template type to the list of managed properties.
 
void declareProperty (std::unique_ptr< Property > p, const std::string &doc="") override
 Add a property to the list of managed properties.
 
virtual void declareProperty (std::unique_ptr< Property > p, const std::string &doc="")=0
 Function to declare properties (i.e. store them)
 
bool existsProperty (const std::string &name) const override
 Checks whether the named property is already in the list of managed property.
 
void filterByProperty (Mantid::Kernel::LogFilter *logFilter, const std::vector< std::string > &excludedFromFiltering=std::vector< std::string >()) override
 Filter the managed properties by the given boolean property mask.
 
std::vector< std::string > getDeclaredPropertyNames () const noexcept override
 Return the list of declared property names.
 
PropertygetPointerToProperty (const std::string &name) const override
 Get a property by name.
 
const std::vector< Property * > & getProperties () const override
 Get the list of managed properties.
 
TypedValue getProperty (const std::string &name) const override
 Get the value of a property.
 
std::string getPropertyValue (const std::string &name) const override
 Get the value of a property as a string.
 
bool operator!= (const PropertyManager &other) const
 
PropertyManageroperator+= (const PropertyManager &rhs)
 Addition operator.
 
PropertyManageroperator= (const PropertyManager &)
 Assignment operator - performs a deep copy.
 
bool operator== (const PropertyManager &other) const
 
size_t propertyCount () const override
 Count the number of properties under management.
 
 PropertyManager ()
 Default constructor.
 
 PropertyManager (const PropertyManager &)
 copy constructor
 
void removeDataOutsideTimeROI (const Kernel::TimeROI &timeROI)
 For time series properties, remove time values outside of TimeROI regions, each defined as [roi_begin,roi_end].
 
void removeProperty (const std::string &name, const bool delproperty=true) override
 removes the property from properties map
 
void resetProperties () override
 Reset property values back to initial values (blank or default values)
 
void setProperties (const ::Json::Value &jsonValue, const std::unordered_set< std::string > &ignoreProperties=std::unordered_set< std::string >(), bool createMissing=false) override
 Set the ordered list of properties by a json value collection.
 
void setProperties (const ::Json::Value &jsonValue, IPropertyManager *targetPropertyManager, const std::unordered_set< std::string > &ignoreProperties=std::unordered_set< std::string >(), bool createMissing=false)
 Set the ordered list of properties by a json value collection.
 
void setProperties (const std::string &propertiesJson, const std::unordered_set< std::string > &ignoreProperties=std::unordered_set< std::string >(), bool createMissing=false) override
 Set the ordered list of properties by one string of values, separated by semicolons.
 
void setProperties (const std::string &propertiesJson, IPropertyManager *targetPropertyManager, const std::unordered_set< std::string > &ignoreProperties, bool createMissing=false)
 Set the ordered list of properties by one string of values, separated by semicolons.
 
void setPropertiesWithString (const std::string &propertiesString, const std::unordered_set< std::string > &ignoreProperties=std::unordered_set< std::string >()) override
 Sets all the declared properties from a string.
 
void setPropertyOrdinal (const int &index, const std::string &value) override
 Set the value of a property by an index N.B.
 
void setPropertyValue (const std::string &name, const std::string &value) override
 Set the value of a property by string N.B.
 
void setPropertyValueFromJson (const std::string &name, const Json::Value &value) override
 Set the value of a property by Json::Value.
 
std::unique_ptr< PropertytakeProperty (const size_t index) override
 removes the property from the properties map and returns a pointer to it
 
bool validateProperties () const override
 Validates all the properties in the collection.
 
virtual ~PropertyManager () override
 Virtual destructor.
 
- Public Member Functions inherited from Mantid::Kernel::IPropertyManager
void declareProperty (const std::string &name, const char *value, const std::string &doc, IValidator_sptr validator=std::make_shared< NullValidator >(), const unsigned int direction=Direction::Input)
 Specialised version of declareProperty template method to prevent the creation of a PropertyWithValue of type const char* if an argument in quotes is passed (it will be converted to a string).
 
void declareProperty (const std::string &name, const char *value, const unsigned int direction)
 Add a property of string type to the list of managed properties.
 
void declareProperty (const std::string &name, const char *value, IValidator_sptr validator=std::make_shared< NullValidator >(), const std::string &doc=std::string(), const unsigned int direction=Direction::Input)
 Specialised version of declareProperty template method to prevent the creation of a PropertyWithValue of type const char* if an argument in quotes is passed (it will be converted to a string).
 
template<typename T >
void declareProperty (const std::string &name, T value, const std::string &doc, const unsigned int direction=Direction::Input)
 Add a property to the list of managed properties with no validator.
 
template<typename T >
void declareProperty (const std::string &name, T value, const unsigned int direction)
 Add a property of the template type to the list of managed properties.
 
template<typename T >
void declareProperty (const std::string &name, T value, IValidator_sptr validator=std::make_shared< NullValidator >(), const std::string &doc="", const unsigned int direction=Direction::Input)
 Add a property of the template type to the list of managed properties.
 
std::vector< Property * > getPropertiesInGroup (const std::string &group) const
 Get the list of managed properties in a given group.
 
IPropertyManagersetProperty (const std::string &name, const char *value)
 Specialised version of setProperty template method to handle const char *.
 
IPropertyManagersetProperty (const std::string &name, const std::string &value)
 Specialised version of setProperty template method to handle std::string.
 
template<typename T >
IPropertyManagersetProperty (const std::string &name, const T &value)
 Templated method to set the value of a PropertyWithValue.
 
template<typename T >
IPropertyManagersetProperty (const std::string &name, std::unique_ptr< T > value)
 Templated method to set the value of a PropertyWithValue from a std::unique_ptr.
 
void setPropertyGroup (const std::string &name, const std::string &group)
 Set the group for a given property.
 
void setPropertySettings (const std::string &name, std::unique_ptr< IPropertySettings > settings)
 
void updatePropertyValues (const IPropertyManager &other)
 Update values of the existing properties.
 
virtual ~IPropertyManager ()=default
 

Private Member Functions

void calculateStep (const DoubleFortranMatrix &J, const DoubleFortranVector &f, const DoubleFortranMatrix &hf, double Delta, DoubleFortranVector &d, double &normd, const NLLS::nlls_options &options)
 Find a correction vector to the parameters.
 
void evalF (const DoubleFortranVector &x, DoubleFortranVector &f) const
 Evaluate the fitting function and calculate the residuals.
 
void evalHF (const DoubleFortranVector &x, const DoubleFortranVector &f, DoubleFortranMatrix &h) const
 Evaluate the Hessian.
 
void evalJ (const DoubleFortranVector &x, DoubleFortranMatrix &J) const
 Evaluate the Jacobian.
 

Private Attributes

DoubleFortranMatrix m_A
 
NLLS::all_eig_symm_work m_all_eig_symm_ws
 
DoubleFortranVector m_d_trans
 
DoubleFortranMatrix m_ev
 
DoubleFortranVector m_ew
 
API::IFunction_sptr m_function
 Stored to access IFunction interface in iterate()
 
NLLS::nlls_inform m_inform
 Information about the fitting.
 
JacobianImpl1< DoubleFortranMatrixm_J
 The Jacobian.
 
std::shared_ptr< CostFunctions::CostFuncLeastSquaresm_leastSquares
 Stored cost function.
 
NLLS::nlls_options m_options
 Options.
 
DoubleFortranVector m_scale
 
DoubleFortranVector m_v
 
DoubleFortranVector m_v_trans
 
DoubleFortranVector m_weights
 Fitting data weights.
 
NLLS::NLLS_workspace m_workspace
 Temporary and helper objects.
 
DoubleFortranVector m_x
 Fitting parameters.
 

Additional Inherited Members

- Static Public Member Functions inherited from Mantid::Kernel::PropertyManager
static std::string getInvalidValuesFilterLogName (const std::string &logName)
 Gets the correct log name for the matching invalid values log for a given log name.
 
static std::string getLogNameFromInvalidValuesFilter (const std::string &logName)
 
static bool isAnInvalidValuesFilterLog (const std::string &logName)
 Determine if the log's name has a substring indicating it should not be filtered.
 
- Static Public Attributes inherited from Mantid::Kernel::PropertyManager
static const std::string INVALID_VALUES_SUFFIX = "_invalid_values"
 
- Protected Member Functions inherited from Mantid::Kernel::PropertyManager
PropertygetPointerToPropertyOrdinal (const int &index) const override
 Get a property by an index.
 
PropertygetPointerToPropertyOrNull (const std::string &name) const
 Get a property by name.
 
- Protected Member Functions inherited from Mantid::Kernel::IPropertyManager
virtual void afterPropertySet (const std::string &)
 Override this method to perform a custom action right after a property was set.
 
template<typename T >
getValue (const std::string &name) const
 Templated method to get the value of a property.
 
template<>
MANTID_KERNEL_DLL PropertyManager_sptr getValue (const std::string &name) const
 
template<>
MANTID_KERNEL_DLL PropertyManager_const_sptr getValue (const std::string &name) const
 
- Protected Attributes inherited from Mantid::API::IFuncMinimizer
std::string m_errorString
 Error string.
 

Detailed Description

Trust Region minimizer class using the DTRS method of GALAHAD.

Definition at line 24 of file TrustRegionMinimizer.h.

Constructor & Destructor Documentation

◆ TrustRegionMinimizer()

Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::TrustRegionMinimizer ( )

constructor and destructor

Definition at line 31 of file TrustRegionMinimizer.cpp.

Member Function Documentation

◆ calculateStep()

void Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::calculateStep ( const DoubleFortranMatrix J,
const DoubleFortranVector f,
const DoubleFortranMatrix hf,
double  Delta,
DoubleFortranVector d,
double &  normd,
const NLLS::nlls_options options 
)
private

Find a correction vector to the parameters.

Solve the trust-region subproblem using the DTRS method from Galahad.

This method needs H to be diagonal, so we need to pre-process

main output d, the soln to the TR subproblem

Parameters
J:: The Jacobian.
f:: The residuals.
hf:: The Hessian (sort of).
Delta:: The raduis of the trust region.
d:: The output vector of corrections to the parameters giving the solution to the TR subproblem.
normd:: The 2-norm of d.
options:: The options.

Definition at line 1272 of file TrustRegionMinimizer.cpp.

References Mantid::CurveFitting::NLLS::allEigSymm(), Mantid::CurveFitting::FortranVector< VectorClass >::allocate(), Mantid::Geometry::d, fabs, Mantid::CurveFitting::FortranVector< VectorClass >::len(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len2(), m_A, m_d_trans, m_ev, m_ew, m_scale, m_v, m_v_trans, Mantid::CurveFitting::NLLS::matmultInner(), Mantid::CurveFitting::NLLS::multJ(), Mantid::CurveFitting::NLLS::multJt(), n, Mantid::CurveFitting::NLLS::norm2(), and Mantid::CurveFitting::NLLS::nlls_options::scale.

Referenced by iterate().

◆ costFunctionVal()

double Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::costFunctionVal ( )
overridevirtual

Return current value of the cost function.

Return the current value of the cost function.

Implements Mantid::API::IFuncMinimizer.

Definition at line 1354 of file TrustRegionMinimizer.cpp.

References m_leastSquares.

◆ evalF()

void Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::evalF ( const DoubleFortranVector x,
DoubleFortranVector f 
) const
private

Evaluate the fitting function and calculate the residuals.

Parameters
x:: The fitting parameters as a fortran 1d array.
f:: The output fortran vector with the weighted residuals.

Definition at line 78 of file TrustRegionMinimizer.cpp.

References Mantid::CurveFitting::FortranVector< VectorClass >::allocate(), Mantid::CurveFitting::FortranVector< VectorClass >::len(), Mantid::Geometry::m, m_function, m_leastSquares, Mantid::CurveFitting::EigenVector::set(), and Mantid::Geometry::x.

Referenced by iterate().

◆ evalHF()

void Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::evalHF ( const DoubleFortranVector x,
const DoubleFortranVector f,
DoubleFortranMatrix h 
) const
private

Evaluate the Hessian.

Parameters
x:: The fitting parameters as a fortran 1d array.
f:: The fortran vector with the weighted residuals.
h:: The fortran matrix with the Hessian.

Definition at line 122 of file TrustRegionMinimizer.cpp.

References Mantid::CurveFitting::FortranMatrix< MatrixClass >::allocate(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len1(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len2(), m_leastSquares, n, UNUSED_ARG, Mantid::Geometry::x, and Mantid::CurveFitting::EigenMatrix::zero().

Referenced by iterate().

◆ evalJ()

void Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::evalJ ( const DoubleFortranVector x,
DoubleFortranMatrix J 
) const
private

Evaluate the Jacobian.

Parameters
x:: The fitting parameters as a fortran 1d array.
J:: The output fortran matrix with the weighted Jacobian.

Definition at line 96 of file TrustRegionMinimizer.cpp.

References Mantid::CurveFitting::FortranMatrix< MatrixClass >::allocate(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len1(), Mantid::CurveFitting::FortranMatrix< MatrixClass >::len2(), Mantid::Geometry::m, m_function, m_J, m_leastSquares, n, and Mantid::Geometry::x.

Referenced by iterate().

◆ initialize()

void Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::initialize ( API::ICostFunction_sptr  costFunction,
size_t  maxIterations = 0 
)
overridevirtual

Initialize minimizer, i.e. pass a function to minimize.

Initialise the minimizer.

Parameters
costFunction:: The cost function to minimize. Must be the least squares.
maxIterations:: Maximum number of iterations that the minimiser will do.

Implements Mantid::API::IFuncMinimizer.

Definition at line 45 of file TrustRegionMinimizer.cpp.

References Mantid::CurveFitting::FortranVector< VectorClass >::allocate(), Mantid::Kernel::PropertyManager::getProperty(), Mantid::CurveFitting::NLLS::nlls_options::initial_radius, Mantid::CurveFitting::NLLS::NLLS_workspace::initialize(), Mantid::Geometry::m, m_function, m_J, m_leastSquares, m_options, m_workspace, m_x, Mantid::CurveFitting::NLLS::nlls_options::maxit, and n.

◆ iterate()

bool Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::iterate ( size_t  )
overridevirtual

◆ name()

std::string Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::name ( ) const
overridevirtual

Name of the minimizer.

Implements Mantid::API::IFuncMinimizer.

Definition at line 37 of file TrustRegionMinimizer.cpp.

Member Data Documentation

◆ m_A

DoubleFortranMatrix Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_A
private

Definition at line 66 of file TrustRegionMinimizer.h.

Referenced by calculateStep().

◆ m_all_eig_symm_ws

NLLS::all_eig_symm_work Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_all_eig_symm_ws
private

Definition at line 68 of file TrustRegionMinimizer.h.

◆ m_d_trans

DoubleFortranVector Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_d_trans
private

Definition at line 67 of file TrustRegionMinimizer.h.

Referenced by calculateStep().

◆ m_ev

DoubleFortranMatrix Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_ev
private

Definition at line 66 of file TrustRegionMinimizer.h.

Referenced by calculateStep().

◆ m_ew

DoubleFortranVector Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_ew
private

Definition at line 67 of file TrustRegionMinimizer.h.

Referenced by calculateStep().

◆ m_function

API::IFunction_sptr Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_function
private

Stored to access IFunction interface in iterate()

Definition at line 51 of file TrustRegionMinimizer.h.

Referenced by evalF(), evalJ(), and initialize().

◆ m_inform

NLLS::nlls_inform Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_inform
private

Information about the fitting.

Definition at line 61 of file TrustRegionMinimizer.h.

Referenced by iterate().

◆ m_J

JacobianImpl1<DoubleFortranMatrix> Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_J
mutableprivate

The Jacobian.

Definition at line 57 of file TrustRegionMinimizer.h.

Referenced by evalJ(), and initialize().

◆ m_leastSquares

std::shared_ptr<CostFunctions::CostFuncLeastSquares> Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_leastSquares
private

Stored cost function.

Definition at line 49 of file TrustRegionMinimizer.h.

Referenced by costFunctionVal(), evalF(), evalHF(), evalJ(), initialize(), and iterate().

◆ m_options

NLLS::nlls_options Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_options
private

Options.

Definition at line 59 of file TrustRegionMinimizer.h.

Referenced by initialize(), and iterate().

◆ m_scale

DoubleFortranVector Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_scale
private

Definition at line 69 of file TrustRegionMinimizer.h.

Referenced by calculateStep().

◆ m_v

DoubleFortranVector Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_v
private

Definition at line 67 of file TrustRegionMinimizer.h.

Referenced by calculateStep().

◆ m_v_trans

DoubleFortranVector Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_v_trans
private

Definition at line 67 of file TrustRegionMinimizer.h.

Referenced by calculateStep().

◆ m_weights

DoubleFortranVector Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_weights
private

Fitting data weights.

Definition at line 53 of file TrustRegionMinimizer.h.

◆ m_workspace

NLLS::NLLS_workspace Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_workspace
private

Temporary and helper objects.

Definition at line 63 of file TrustRegionMinimizer.h.

Referenced by initialize(), and iterate().

◆ m_x

DoubleFortranVector Mantid::CurveFitting::FuncMinimisers::TrustRegionMinimizer::m_x
private

Fitting parameters.

Definition at line 55 of file TrustRegionMinimizer.h.

Referenced by initialize(), and iterate().


The documentation for this class was generated from the following files: