|
Mantid
|
A wrapper around the GSL functions implementing a minimizer using derivatives. More...
#include <DerivMinimizer.h>
Public Member Functions | |
| void | calCovarianceMatrix (gsl_matrix *covar, double epsrel=0.0001) |
| Calculate the covariance matrix. | |
| double | costFunctionVal () override |
| Return current value of the cost function. | |
| DerivMinimizer () | |
| Constructor. | |
| DerivMinimizer (const double stepSize, const double tolerance) | |
| Constructor. | |
| void | initialize (API::ICostFunction_sptr function, size_t maxIterations=0) override |
| Initialize minimizer, i.e. pass a function to minimize. | |
| bool | iterate (size_t) override |
| Do one iteration. | |
| void | setStopGradient (const double value) |
| Set maximum value of the gradient at which iterations can stop. | |
| ~DerivMinimizer () override | |
| 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. | |
| virtual std::string | name () const =0 |
| Get name of minimizer. | |
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. | |
| PropertyManager * | cloneInTimeROI (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. | |
| Property * | getPointerToProperty (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 |
| PropertyManager & | operator+= (const PropertyManager &rhs) |
| Addition operator. | |
| PropertyManager & | operator= (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< Property > | takeProperty (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. | |
| IPropertyManager * | setProperty (const std::string &name, const char *value) |
| Specialised version of setProperty template method to handle const char *. | |
| IPropertyManager * | setProperty (const std::string &name, const std::string &value) |
| Specialised version of setProperty template method to handle std::string. | |
| template<typename T > | |
| IPropertyManager * | setProperty (const std::string &name, const T &value) |
| Templated method to set the value of a PropertyWithValue. | |
| template<typename T > | |
| IPropertyManager * | setProperty (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 |
Protected Member Functions | |
| virtual const gsl_multimin_fdfminimizer_type * | getGSLMinimizerType ()=0 |
| Return a concrete type to initialize m_gslSolver with. | |
Protected Member Functions inherited from Mantid::Kernel::PropertyManager | |
| Property * | getPointerToPropertyOrdinal (const int &index) const override |
| Get a property by an index. | |
| Property * | getPointerToPropertyOrNull (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 > | |
| 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 |
Static Protected Member Functions | |
| static void | dfun (const gsl_vector *x, void *params, gsl_vector *g) |
| Used by the GSL. | |
| static double | fun (const gsl_vector *x, void *params) |
| Used by the GSL. | |
| static void | fundfun (const gsl_vector *x, void *params, double *f, gsl_vector *g) |
| Used by the GSL. | |
Protected Attributes | |
| API::ICostFunction_sptr | m_costFunction |
| Function to minimize. | |
| gsl_multimin_function_fdf | m_gslMultiminContainer |
| GSL container. | |
| gsl_multimin_fdfminimizer * | m_gslSolver |
| pointer to the GSL solver doing the work | |
| double | m_stepSize |
| First trial step size. | |
| double | m_stopGradient |
| the norm of the gradient at which iterations stop | |
| double | m_tolerance |
| Tolerance. | |
| gsl_vector * | m_x |
| GSL vector with function parameters. | |
Protected Attributes inherited from Mantid::API::IFuncMinimizer | |
| std::string | m_errorString |
| Error string. | |
Private Member Functions | |
| void | initGSLMMin () |
| simply init the values for the gsl minimizer | |
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" |
A wrapper around the GSL functions implementing a minimizer using derivatives.
Concrete classes must implement the getGSLMinimizerType() method.
Definition at line 27 of file DerivMinimizer.h.
| Mantid::CurveFitting::FuncMinimisers::DerivMinimizer::DerivMinimizer | ( | ) |
| Mantid::CurveFitting::FuncMinimisers::DerivMinimizer::DerivMinimizer | ( | const double | stepSize, |
| const double | tolerance | ||
| ) |
Constructor.
| stepSize | :: Initial step size. |
| tolerance | :: Tolerance. |
Definition at line 91 of file DerivMinimizer.cpp.
References initGSLMMin().
|
override |
| void Mantid::CurveFitting::FuncMinimisers::DerivMinimizer::calCovarianceMatrix | ( | gsl_matrix * | covar, |
| double | epsrel = 0.0001 |
||
| ) |
Calculate the covariance matrix.
|
overridevirtual |
Return current value of the cost function.
Implements Mantid::API::IFuncMinimizer.
Definition at line 172 of file DerivMinimizer.cpp.
References m_gslSolver.
|
staticprotected |
Used by the GSL.
Used by the GSL to calculate the derivatives.
| x | :: Vector with parameters |
| params | :: Pointer to a DerivMinimizer |
| g | :: Buffer for the derivatives |
Definition at line 38 of file DerivMinimizer.cpp.
References m_costFunction, n, and Mantid::Geometry::x.
Referenced by initialize().
|
staticprotected |
Used by the GSL.
Used by the GSL to calculate the cost function.
| x | :: Vector with parameters |
| params | :: Pointer to a DerivMinimizer |
Definition at line 19 of file DerivMinimizer.cpp.
References m_costFunction, n, and Mantid::Geometry::x.
Referenced by initialize().
|
staticprotected |
Used by the GSL.
Used by the GSL to calculate the cost function and the derivatives.
| x | :: Vector with parameters |
| params | :: Pointer to a DerivMinimizer |
| f | :: Buffer for the fanction value |
| g | :: Buffer for the derivatives |
Definition at line 62 of file DerivMinimizer.cpp.
References m_costFunction, n, and Mantid::Geometry::x.
Referenced by initialize().
|
protectedpure virtual |
Return a concrete type to initialize m_gslSolver with.
Implemented in Mantid::CurveFitting::FuncMinimisers::BFGS_Minimizer, Mantid::CurveFitting::FuncMinimisers::FRConjugateGradientMinimizer, Mantid::CurveFitting::FuncMinimisers::PRConjugateGradientMinimizer, and Mantid::CurveFitting::FuncMinimisers::SteepestDescentMinimizer.
Referenced by initialize().
|
private |
simply init the values for the gsl minimizer
Definition at line 96 of file DerivMinimizer.cpp.
References m_gslMultiminContainer.
Referenced by DerivMinimizer(), and DerivMinimizer().
|
overridevirtual |
Initialize minimizer, i.e. pass a function to minimize.
Initialize the minimizer.
| function | :: A cost function to minimize. |
| maxIterations | :: Maximum number of iterations. |
Implements Mantid::API::IFuncMinimizer.
Definition at line 119 of file DerivMinimizer.cpp.
References dfun(), fun(), fundfun(), getGSLMinimizerType(), m_costFunction, m_gslMultiminContainer, m_gslSolver, m_stepSize, m_tolerance, m_x, and UNUSED_ARG.
|
overridevirtual |
Do one iteration.
Perform one iteration.
Implements Mantid::API::IFuncMinimizer.
Definition at line 144 of file DerivMinimizer.cpp.
References Mantid::API::IFuncMinimizer::m_errorString, m_gslSolver, m_stopGradient, and Mantid::API::IFuncMinimizer::name().
| void Mantid::CurveFitting::FuncMinimisers::DerivMinimizer::setStopGradient | ( | const double | value | ) |
Set maximum value of the gradient at which iterations can stop.
| value | :: New value for the gradient, must be positive. |
Definition at line 165 of file DerivMinimizer.cpp.
References m_stopGradient, and value.
|
protected |
Function to minimize.
Definition at line 51 of file DerivMinimizer.h.
Referenced by dfun(), fun(), fundfun(), and initialize().
|
protected |
GSL container.
Definition at line 57 of file DerivMinimizer.h.
Referenced by initGSLMMin(), and initialize().
|
protected |
pointer to the GSL solver doing the work
Definition at line 54 of file DerivMinimizer.h.
Referenced by costFunctionVal(), initialize(), iterate(), and ~DerivMinimizer().
|
protected |
|
protected |
the norm of the gradient at which iterations stop
Definition at line 63 of file DerivMinimizer.h.
Referenced by iterate(), and setStopGradient().
|
protected |
|
protected |
GSL vector with function parameters.
Definition at line 60 of file DerivMinimizer.h.
Referenced by initialize(), and ~DerivMinimizer().