21#include <gsl/gsl_blas.h>
27Kernel::Logger
g_log(
"DampedGaussNewtonMinimizer");
34 declareProperty(
"Damping", 0.0,
"The damping parameter.");
35 declareProperty(
"Verbose",
false,
"Make output more verbose.");
40 m_leastSquares = std::dynamic_pointer_cast<CostFunctions::CostFuncLeastSquares>(function);
42 throw std::invalid_argument(
"Damped Gauss-Newton minimizer works only with least "
43 "squares. Different function was given.");
53 throw std::runtime_error(
"Cost function isn't set up.");
69 for (
size_t i = 0; i <
n; ++i) {
70 double tmp = H.get(i, i) + damping;
81 for (
size_t j = 0; j <
n; ++j) {
93 }
catch (std::runtime_error &e) {
99 for (
size_t j = 0; j <
n; ++j) {
106 for (
size_t i = 0; i <
n; ++i) {
107 if (!std::isfinite(dx[i])) {
125 double dx_norm = gsl_blas_dnrm2(&dx_gsl.vector);
132 throw std::runtime_error(
"Cost function isn't set up.");
#define DECLARE_FUNCMINIMIZER(classname, username)
Macro for declaring a new type of minimizers to be used with the FuncMinimizerFactory.
An interface for function minimizers.
std::string m_errorString
Error string.
A wrapper around Eigen::Matrix.
A wrapper around Eigen::Vector.
double get(const size_t i) const
Get an element.
vec_map_type & mutator()
Get the map of the eigen vector.
Implements a Gauss-Newton minimization algorithm with damping for use with least squares cost functio...
std::shared_ptr< CostFunctions::CostFuncLeastSquares > m_leastSquares
Pointer to the cost function. Must be the least squares.
double m_relTol
Relative tolerance.
bool iterate(size_t) override
Do one iteration.
void initialize(API::ICostFunction_sptr function, size_t maxIterations=0) override
Initialize minimizer, i.e. pass a function to minimize.
double costFunctionVal() override
Return current value of the cost function.
void warning(const std::string &msg)
Logs at warning level.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< ICostFunction > ICostFunction_sptr
define a shared pointer to a cost function
gsl_vector_view getGSLVectorView(vec_map_type &v)
take data from Eigen Vector and take a gsl view