Skip to content

Commit

Permalink
Re #5851. Added DampingMinimizer. Added properties to minimizers.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Sep 14, 2012
1 parent a506d66 commit 0522bd2
Show file tree
Hide file tree
Showing 16 changed files with 265 additions and 51 deletions.
4 changes: 4 additions & 0 deletions Code/Mantid/Framework/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set ( SRC_FILES
src/FileFinder.cpp
src/FileProperty.cpp
src/FrameworkManager.cpp
src/FuncMinimizerFactory.cpp
src/FunctionDomain1D.cpp
src/FunctionDomainMD.cpp
src/FunctionFactory.cpp
Expand All @@ -45,6 +46,7 @@ set ( SRC_FILES
src/IDomainCreator.cpp
src/IEventList.cpp
src/IEventWorkspace.cpp
src/IFuncMinimizer.cpp
src/IFunction.cpp
src/IFunction1D.cpp
src/IFunctionMD.cpp
Expand Down Expand Up @@ -156,6 +158,7 @@ set ( INC_FILES
inc/MantidAPI/FileFinder.h
inc/MantidAPI/FileProperty.h
inc/MantidAPI/FrameworkManager.h
inc/MantidAPI/FuncMinimizerFactory.h
inc/MantidAPI/FunctionDomain.h
inc/MantidAPI/FunctionDomain1D.h
inc/MantidAPI/FunctionDomainMD.h
Expand All @@ -173,6 +176,7 @@ set ( INC_FILES
inc/MantidAPI/IDomainCreator.h
inc/MantidAPI/IEventList.h
inc/MantidAPI/IEventWorkspace.h
inc/MantidAPI/IFuncMinimizer.h
inc/MantidAPI/IFunction.h
inc/MantidAPI/IFunction1D.h
inc/MantidAPI/IFunctionMD.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#ifndef MANTID_CURVEFITTING_FUNCMINIMIZERFACTORY_H_
#define MANTID_CURVEFITTING_FUNCMINIMIZERFACTORY_H_
#ifndef MANTID_API_FUNCMINIMIZERFACTORY_H_
#define MANTID_API_FUNCMINIMIZERFACTORY_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include <vector>
#include "MantidCurveFitting/DllConfig.h"
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/DynamicFactory.h"
#include "MantidKernel/SingletonHolder.h"

namespace Mantid
{
namespace CurveFitting
namespace API
{

//----------------------------------------------------------------------
Expand Down Expand Up @@ -49,7 +49,7 @@ namespace CurveFitting
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
*/

class DLLExport FuncMinimizerFactoryImpl : public Kernel::DynamicFactory<IFuncMinimizer>
class MANTID_API_DLL FuncMinimizerFactoryImpl : public Kernel::DynamicFactory<IFuncMinimizer>
{
public:
/**Creates an instance of a function
Expand Down Expand Up @@ -78,4 +78,4 @@ namespace CurveFitting
} // namespace API
} // namespace Mantid

#endif /*MANTID_CURVEFITTING_FUNCMINIMIZERFACTORY_H_*/
#endif /*MANTID_API_FUNCMINIMIZERFACTORY_H_*/
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#ifndef MANTID_CURVEFITTING_IFUNCMINIMIZER_H_
#define MANTID_CURVEFITTING_IFUNCMINIMIZER_H_
#ifndef MANTID_API_IFUNCMINIMIZER_H_
#define MANTID_API_IFUNCMINIMIZER_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidKernel/System.h"
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/PropertyManager.h"
#include "MantidAPI/ICostFunction.h"
#include "MantidCurveFitting/FuncMinimizerFactory.h"
#include "MantidAPI/FuncMinimizerFactory.h"

namespace Mantid
{
namespace API
{
class IFitFunction;
}
namespace CurveFitting
{
// Forward declaration
class IFitFunction;

/** An interface for function minimizers. Minimizers minimize cost functions.
@author Anders Markvardsen, ISIS, RAL
Expand All @@ -41,7 +41,7 @@ namespace CurveFitting
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport IFuncMinimizer
class MANTID_API_DLL IFuncMinimizer: public Kernel::PropertyManager
{
public:
/// Virtual destructor
Expand Down Expand Up @@ -73,7 +73,7 @@ class DLLExport IFuncMinimizer

typedef boost::shared_ptr<IFuncMinimizer> IFuncMinimizer_sptr;

} // namespace CurveFitting
} // namespace API
} // namespace Mantid

/**
Expand All @@ -82,8 +82,8 @@ typedef boost::shared_ptr<IFuncMinimizer> IFuncMinimizer_sptr;
#define DECLARE_FUNCMINIMIZER(classname,username) \
namespace { \
Mantid::Kernel::RegistrationHelper register_funcminimizer_##classname( \
((Mantid::CurveFitting::FuncMinimizerFactory::Instance().subscribe<classname>(#username)) \
((Mantid::API::FuncMinimizerFactory::Instance().subscribe<classname>(#username)) \
, 0)); \
}

#endif /*MANTID_CURVEFITTING_IFUNCMINIMIZER_H_*/
#endif /*MANTID_API_IFUNCMINIMIZER_H_*/
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "MantidCurveFitting/FuncMinimizerFactory.h"
#include "MantidCurveFitting/IFuncMinimizer.h"
#include "MantidAPI/FuncMinimizerFactory.h"
#include "MantidAPI/IFuncMinimizer.h"
#include "MantidKernel/Logger.h"
#include "MantidKernel/LibraryManager.h"

namespace Mantid
{
namespace CurveFitting
namespace API
{

FuncMinimizerFactoryImpl::FuncMinimizerFactoryImpl() : Kernel::DynamicFactory<IFuncMinimizer>(), g_log(Kernel::Logger::get("FuncMinimizerFactory"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidCurveFitting/IFuncMinimizer.h"
#include "MantidAPI/IFuncMinimizer.h"

#include <boost/lexical_cast.hpp>

namespace Mantid
{
namespace CurveFitting
namespace API
{

/**
Expand Down Expand Up @@ -46,5 +46,5 @@ bool IFuncMinimizer::minimize(size_t maxIterations)

}

} // namespace CurveFitting
} // namespace API
} // namespace Mantid
6 changes: 2 additions & 4 deletions Code/Mantid/Framework/CurveFitting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set ( SRC_FILES
src/Convolution.cpp
src/CostFuncFitting.cpp
src/CostFuncLeastSquares.cpp
src/DampingMinimizer.cpp
src/DeltaFunction.cpp
src/DerivMinimizer.cpp
src/DiffSphere.cpp
Expand All @@ -26,14 +27,12 @@ set ( SRC_FILES
src/Fit1D.cpp
src/FitMW.cpp
src/FlatBackground.cpp
src/FuncMinimizerFactory.cpp
src/GSLFunctions.cpp
src/GausDecay.cpp
src/GausOsc.cpp
src/Gaussian.cpp
src/Gaussian1D.cpp
src/GaussianLinearBG1D.cpp
src/IFuncMinimizer.cpp
src/IkedaCarpenterPV.cpp
src/LeBailFit.cpp
src/LeBailFunction.cpp
Expand Down Expand Up @@ -89,6 +88,7 @@ set ( INC_FILES
inc/MantidCurveFitting/Convolution.h
inc/MantidCurveFitting/CostFuncFitting.h
inc/MantidCurveFitting/CostFuncLeastSquares.h
inc/MantidCurveFitting/DampingMinimizer.h
inc/MantidCurveFitting/DeltaFunction.h
inc/MantidCurveFitting/DerivMinimizer.h
inc/MantidCurveFitting/DiffSphere.h
Expand All @@ -103,7 +103,6 @@ set ( INC_FILES
inc/MantidCurveFitting/Fit1D.h
inc/MantidCurveFitting/FitMW.h
inc/MantidCurveFitting/FlatBackground.h
inc/MantidCurveFitting/FuncMinimizerFactory.h
inc/MantidCurveFitting/GSLFunctions.h
inc/MantidCurveFitting/GSLJacobian.h
inc/MantidCurveFitting/GSLMatrix.h
Expand All @@ -113,7 +112,6 @@ set ( INC_FILES
inc/MantidCurveFitting/Gaussian.h
inc/MantidCurveFitting/Gaussian1D.h
inc/MantidCurveFitting/GaussianLinearBG1D.h
inc/MantidCurveFitting/IFuncMinimizer.h
inc/MantidCurveFitting/IkedaCarpenterPV.h
inc/MantidCurveFitting/Jacobian.h
inc/MantidCurveFitting/LeBailFit.h
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#ifndef MANTID_CURVEFITTING_DAMPINGMINIMIZER_H_
#define MANTID_CURVEFITTING_DAMPINGMINIMIZER_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/IFuncMinimizer.h"
#include "MantidCurveFitting/GSLVector.h"
#include "MantidCurveFitting/GSLMatrix.h"

namespace Mantid
{
namespace CurveFitting
{

class CostFuncLeastSquares;

/**
Implements a least squares minimization algorithm with damping.
@author Roman Tolchenov, Tessella plc
Copyright &copy; 2009 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport DampingMinimizer : public API::IFuncMinimizer
{
public:
/// Constructor
DampingMinimizer();
/// Name of the minimizer.
std::string name() const {return "DampingMinimizer";}

/// Initialize minimizer, i.e. pass a function to minimize.
virtual void initialize(API::ICostFunction_sptr function);
/// Do one iteration.
virtual bool iterate();
/// Return current value of the cost function
virtual double costFunctionVal();

private:
/// Pointer to the cost function. Must be the least squares.
boost::shared_ptr<CostFuncLeastSquares> m_leastSquares;
/// Relative tolerance.
double m_relTol;
/// The damping mu parameter in the Levenberg-Marquardt method.
//double m_damping;
/// Static reference to the logger class
static Kernel::Logger& g_log;
};


} // namespace CurveFitting
} // namespace Mantid

#endif /*MANTID_CURVEFITTING_DAMPINGMINIMIZER_H_*/
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// Includes
//----------------------------------------------------------------------
#include "MantidCurveFitting/DllConfig.h"
#include "MantidCurveFitting/IFuncMinimizer.h"
#include "MantidAPI/IFuncMinimizer.h"

#include <gsl/gsl_multimin.h>
#include <gsl/gsl_multifit_nlin.h>

Expand Down Expand Up @@ -38,7 +39,7 @@ namespace CurveFitting
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport DerivMinimizer : public IFuncMinimizer
class DLLExport DerivMinimizer : public API::IFuncMinimizer
{
public:
/// Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidCurveFitting/IFuncMinimizer.h"
#include "MantidAPI/IFuncMinimizer.h"
#include "MantidCurveFitting/GSLVector.h"
#include "MantidCurveFitting/GSLMatrix.h"

Expand Down Expand Up @@ -41,7 +41,7 @@ class CostFuncLeastSquares;
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LevenbergMarquardtMDMinimizer : public IFuncMinimizer
class DLLExport LevenbergMarquardtMDMinimizer : public API::IFuncMinimizer
{
public:
/// Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidCurveFitting/IFuncMinimizer.h"
#include "MantidAPI/IFuncMinimizer.h"
#include <gsl/gsl_multifit_nlin.h>
#include "MantidAPI/IFunction.h"
//#include "MantidCurveFitting/Fit.h"
#include "MantidCurveFitting/GSLFunctions.h"

namespace Mantid
Expand Down Expand Up @@ -40,7 +39,7 @@ namespace CurveFitting
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LevenbergMarquardtMinimizer : public IFuncMinimizer
class DLLExport LevenbergMarquardtMinimizer : public API::IFuncMinimizer
{
public:
/// constructor and destructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidCurveFitting/IFuncMinimizer.h"
#include "MantidAPI/IFuncMinimizer.h"

#include <gsl/gsl_multimin.h>

namespace Mantid
Expand Down Expand Up @@ -37,7 +38,7 @@ namespace CurveFitting
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport SimplexMinimizer : public IFuncMinimizer
class DLLExport SimplexMinimizer : public API::IFuncMinimizer
{
public:
/// constructor and destructor
Expand Down

0 comments on commit 0522bd2

Please sign in to comment.