33 namespace ModelFitting {
38 return std::make_shared<LevmarEngine>(max_iterations);
44 double epsilon2,
double epsilon3,
double delta)
45 : m_itmax{itmax}, m_opts{tau, epsilon1, epsilon2, epsilon3, delta} {
46 #ifdef LINSOLVERS_RETAIN_MEMORY
47 logger.
warn() <<
"Using a non thread safe levmar! Parallelism will be reduced.";
54 #ifdef LINSOLVERS_RETAIN_MEMORY
65 auto adata =
std::tie(parameter_manager, residual_estimator);
68 auto levmar_res_func = [](
double *p,
double *hx, int, int,
void *extra) {
69 #ifdef LINSOLVERS_RETAIN_MEMORY
70 levmar_mutex.unlock();
72 auto* extra_ptr = (decltype(adata)*)extra;
78 #ifdef LINSOLVERS_RETAIN_MEMORY
93 #ifdef LINSOLVERS_RETAIN_MEMORY
97 auto res = dlevmar_dif(levmar_res_func,
106 covariance_matrix.data(),
109 #ifdef LINSOLVERS_RETAIN_MEMORY
110 levmar_mutex.unlock();
121 summary.success_flag = (res != -1);
122 summary.iteration_no = info[5];
123 summary.underlying_framework_info = info;
virtual ~LevmarEngine()
Destructor.
Class containing the summary information of solving a least square minimization problem.
void populateResiduals(DoubleIter output_iter) const
void getEngineValues(DoubleIter output_iter) const
Returns the engine values of the managed parameters.
static Elements::Logging logger
void updateEngineValues(DoubleIter new_values_iter)
Updates the managed parameters with the given engine values.
void warn(const std::string &logMessage)
static std::shared_ptr< LeastSquareEngine > createLevmarEngine(unsigned max_iterations)
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.
std::size_t numberOfResiduals() const
static LeastSquareEngineManager::StaticEngine levmar_engine
Class responsible for managing the parameters the least square engine minimizes.
std::vector< double > convertCovarianceMatrixToWorldSpace(std::vector< double > covariance_matrix) const
LeastSquareSummary solveProblem(EngineParameterManager ¶meter_manager, ResidualEstimator &residual_estimator) override
Provides to the LeastSquareEngine the residual values.
static Logging getLogger(const std::string &name="")
std::size_t numberOfParameters()
Returns the number of parameters managed by the manager.