28#include <ElementsKernel/Exception.h>
29#include <ElementsKernel/Logging.h>
33#ifndef LEVMAR_WORKAREA_MAX_SIZE
34#define LEVMAR_WORKAREA_MAX_SIZE size_t(2ul<<30)
39__attribute__((unused))
42 std::cerr <<
" ||e||_2 at initial p: " << info[0] <<
'\n';
43 std::cerr <<
" ||e||_2: " << info[1] <<
'\n';
44 std::cerr <<
" ||J^T e||_inf: " << info[2] <<
'\n';
45 std::cerr <<
" ||Dp||_2: " << info[3] <<
'\n';
46 std::cerr <<
" mu/max[J^T J]_ii: " << info[4] <<
'\n';
47 std::cerr <<
" # iterations: " << info[5] <<
'\n';
48 switch ((
int) info[6]) {
50 std::cerr <<
" stopped by small gradient J^T e\n";
59 std::cerr <<
" singular matrix. Restart from current p with increased mu\n";
62 std::cerr <<
" no further error reduction is possible. Restart with increased mu\n";
65 std::cerr <<
" stopped by small ||e||_2\n";
68 std::cerr <<
" stopped by invalid (i.e. NaN or Inf) func values; a user error\n";
71 std::cerr <<
" # function evaluations: " << info[7] <<
'\n';
72 std::cerr <<
" # Jacobian evaluations: " << info[8] <<
'\n';
73 std::cerr <<
" # linear systems solved: " << info[9] <<
"\n\n";
92 switch (
static_cast<int>(info[6])) {
106#ifdef LINSOLVERS_RETAIN_MEMORY
107 logger.warn() <<
"Using a non thread safe levmar! Parallelism will be reduced.";
114#ifdef LINSOLVERS_RETAIN_MEMORY
129#ifdef LINSOLVERS_RETAIN_MEMORY
135 pm.updateEngineValues(p);
137 re.populateResiduals(
hx);
139#ifdef LINSOLVERS_RETAIN_MEMORY
154#ifdef LINSOLVERS_RETAIN_MEMORY
194#ifdef LINSOLVERS_RETAIN_MEMORY
207 summary.engine_stop_reason =
static_cast<int>(info[6]);
208 summary.iteration_no =
static_cast<int>(info[5]);
209 summary.underlying_framework_info = info;
#define LEVMAR_WORKAREA_MAX_SIZE
static Logging getLogger(const std::string &name="")
Class responsible for managing the parameters the least square engine minimizes.
LeastSquareSummary solveProblem(EngineParameterManager ¶meter_manager, ResidualEstimator &residual_estimator) override
virtual ~LevmarEngine()
Destructor.
std::vector< double > m_opts
LevmarEngine(size_t itmax=1000, double tau=1E-3, double epsilon1=1E-8, double epsilon2=1E-8, double epsilon3=1E-8, double delta=1E-4)
Constructs a new instance of the engine.
Provides to the LeastSquareEngine the residual values.
static LeastSquareSummary::StatusFlag getStatusFlag(int ret)
static std::shared_ptr< LeastSquareEngine > createLevmarEngine(unsigned max_iterations)
static LeastSquareEngineManager::StaticEngine levmar_engine
static Elements::Logging logger
Class containing the summary information of solving a least square minimization problem.