ReFRACtor
|
This class tests for convergence of a Levenberg-Marquardt solver. More...
#include <chisq_convergence.h>
Public Member Functions | |
ChisqConvergence (double stopping_criteria=0.001, double dropf=0.1, double boostf=10, double min_chisq=0.01, int max_iteration=50) | |
Constructor. More... | |
virtual | ~ChisqConvergence () |
virtual void | convergence_check (const FitStatistic &fit_stat_last, FitStatistic &fit_stat, bool &has_converged, bool &convergence_failed, double &gamma, bool &step_diverged) |
Check for the convergence of a Solver, or if we have taken a divergent step. More... | |
virtual void | evaluate_quality (FitStatistic &fit_stat, const blitz::Array< double, 1 > &Residual, const blitz::Array< double, 1 > &Residual_cov_diag) |
Evaluates the quality of a converged fit from the residuals and expected residual error. More... | |
virtual void | initialize_check () |
Called before the first iteration, in case there is any setup. More... | |
virtual void | print (std::ostream &Os) const |
Print object to stream. More... | |
std::string | print_to_string () const |
Print to string. More... | |
This class tests for convergence of a Levenberg-Marquardt solver.
This is a simple criteria based just on the chisq. If the chisq is below a given threshold and has changed less than Stopping_criteria, then we are done. If the chisq is larger than the chisq than the last iteration, we say the step has diverged and increase lambda by a boost factor. Otherwise, we reduce lambda by a drop factor.
Definition at line 16 of file chisq_convergence.h.
ChisqConvergence::ChisqConvergence | ( | double | stopping_criteria = 0.001 , |
double | dropf = 0.1 , |
||
double | boostf = 10 , |
||
double | min_chisq = 0.01 , |
||
int | max_iteration = 50 |
||
) |
Constructor.
Definition at line 10 of file chisq_convergence.cc.
|
inlinevirtual |
Definition at line 22 of file chisq_convergence.h.
|
virtual |
Check for the convergence of a Solver, or if we have taken a divergent step.
We pass in data from both this iteration and the last. If this is the first iteration, then the last values can be any kind of garbage value that is convenient (e.g., an empty Array) - we don't look at the value.
fit_stat_last | FitStatistic from the last iteration. |
fit_stat | FitStatistic from this iteration. If we fail convergence, the class may update fit_stat.outcome with the reason for failing. |
has_converged | On exit, true if we have converged to a solution. |
convergence_failed | On exit, true if we have failed to converge and solver should just give up (e.g., we've exceeded a maximum number of iterations. |
gamma | The Levenberg-Marquardt gamma parameter. On input this is value used in this iteration, on exit this is possibly updated to a new value. |
step_diverged | On exit, this is true if the last iteration took a divergent step. In that case, we also update gamma to its new value. |
Implements FullPhysics::ConvergenceCheck.
Definition at line 27 of file chisq_convergence.cc.
|
virtual |
Evaluates the quality of a converged fit from the residuals and expected residual error.
fit_stat_last | FitStatistic from the last iteration. An error should occur if fit_stat.fit_succeeded = False |
Residual | The residual fit from the solver. |
Residual_cov_diag | The expected error for the fit data. |
Implements FullPhysics::ConvergenceCheck.
Definition at line 59 of file chisq_convergence.cc.
|
inlinevirtualinherited |
Called before the first iteration, in case there is any setup.
The default here does nothing, but derived classes can override this to do whatever initialization is needed.
Definition at line 240 of file convergence_check.h.
|
virtual |
Print object to stream.
Reimplemented from FullPhysics::ConvergenceCheck.
Definition at line 79 of file chisq_convergence.cc.
|
inlineinherited |
Print to string.
This is primarily useful for SWIG wrappers to this class, e.g. a to_s method in ruby.
Definition at line 31 of file printable.h.