From 280c07a9c182b791d23a44c7c82337e0b2efd775 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 30 Jun 2015 15:00:16 +0200 Subject: [PATCH] Add opt() method. --- pyext/ctulimit.i | 1 + src/ctulimit/ctulimit.cpp | 17 ++++++++++++----- src/ctulimit/ctulimit.hpp | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pyext/ctulimit.i b/pyext/ctulimit.i index e722ff8..289189d 100644 --- a/pyext/ctulimit.i +++ b/pyext/ctulimit.i @@ -48,6 +48,7 @@ public: void run(void); void save(void); const GObservations& obs(void) const; + const GOptimizer* opt(void) const; const double& diff_ulimit(void) const; const double& flux_ulimit(void) const; const double& eflux_ulimit(void) const; diff --git a/src/ctulimit/ctulimit.cpp b/src/ctulimit/ctulimit.cpp index 92b8110..25e1043 100644 --- a/src/ctulimit/ctulimit.cpp +++ b/src/ctulimit/ctulimit.cpp @@ -232,9 +232,6 @@ void ctulimit::run(void) // Save original models GModels models_orig = m_obs.models(); - // Allocate a new optimizer - m_opt = new GOptimizerLM(); - // Initialise best fit optimizer GOptimizerLM best_opt; @@ -418,7 +415,17 @@ void ctulimit::init_members(void) m_flux_ulimit = 0.0; m_diff_ulimit = 0.0; m_eflux_ulimit = 0.0; - m_opt = NULL; + m_opt = NULL; + + // Allocate LM optimizer + GOptimizerLM* opt = new GOptimizerLM(); + + // Set optimizer parameters + opt->max_iter(m_max_iter); + opt->max_stalls(10); + + // Set optimizer pointer + m_opt = opt; // Return return; @@ -451,7 +458,7 @@ void ctulimit::copy_members(const ctulimit& app) m_diff_ulimit = app.m_diff_ulimit; m_flux_ulimit = app.m_flux_ulimit; m_eflux_ulimit = app.m_eflux_ulimit; - m_opt = NULL; + m_opt = app.m_opt->clone(); // Extract model parameter get_model_parameter(); diff --git a/src/ctulimit/ctulimit.hpp b/src/ctulimit/ctulimit.hpp index c1728db..df2f01a 100644 --- a/src/ctulimit/ctulimit.hpp +++ b/src/ctulimit/ctulimit.hpp @@ -68,6 +68,7 @@ public: void run(void); void save(void); const GObservations& obs(void) const; + const GOptimizer* opt(void) const; const double& diff_ulimit(void) const; const double& flux_ulimit(void) const; const double& eflux_ulimit(void) const; -- libgit2 0.21.4