1 #include <gsl/gsl_blas.h> 11 void print_state( uint32_t iter, gsl_multifit_nlinear_workspace*
s,
int status )
13 double c = gsl_blas_dnrm2( gsl_multifit_nlinear_residual(s) );
14 printf(
"Solver '%s/%s'; iter = %3u; (|f(x)|^2)/2 = %g; status = %s\n",
15 gsl_multifit_nlinear_name(s), gsl_multifit_nlinear_trs_name(s),
16 iter, c*c/2.0, gsl_strerror(status) );
18 printf(
"Where x is\n" );
19 (void) gsl_vector_fprintf(stdout, gsl_multifit_nlinear_position(s),
"%25.14lf");
34 const gsl_multifit_nlinear_type * T = get_gsl_multifit_nlinear_solver();
37 int gsl_status = GSL_FAILURE;
38 int gsl_status_conv = GSL_CONTINUE;
40 gsl_multifit_nlinear_workspace *
s = gsl_multifit_nlinear_alloc(T, &FDF_params, f.n, f.p);
42 blitz::Array<double, 1> X(P->parameters());
44 uint32_t num_step = 0;
47 if( !(gsl_status = gsl_multifit_nlinear_init(
GslVector(X).gsl(), &f, s)) ) {
56 record_cost_at_accepted_point(P->cost());
57 record_accepted_point(P->parameters());
58 record_gradient_at_accepted_point(P->gradient());
67 gsl_status = gsl_multifit_nlinear_iterate(s);
68 if( (gsl_status != GSL_SUCCESS) && (gsl_status != GSL_ENOPROG) ) {
81 gsl_status_conv = gsl_multifit_nlinear_test(X_tol, G_tol, F_tol, &info, s);
95 if(sum(abs(P->gradient())) > G_tol) {
96 gsl_status_conv = GSL_CONTINUE;
101 if( (info == 1) || (info == 2) ) {
106 if(gsl_status == GSL_ENOPROG) {
112 }
while ( (gsl_status_conv == GSL_CONTINUE)
113 && (P->num_cost_evaluations() < max_cost_f_calls)
119 record_cost_at_accepted_point(P->cost());
120 record_accepted_point(P->parameters());
121 record_gradient_at_accepted_point(P->gradient());
123 if(
verbose && (stat != CONTINUE) )
124 print_state( num_step, s, ((stat == ERROR)?gsl_status:gsl_status_conv) );
126 if( s ) gsl_multifit_nlinear_free(s);
const Unit s("s", 1.0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0)
virtual void solve()
The method that solves the optimization problem.
gsl_multifit_nlinear_fdf gsl_sm_get_lsp_fdf(const FullPhysics::NLLSProblem *lsp)
void print_state(uint32_t iter, gsl_multifit_nlinear_workspace *s, int status)
Apply value function to a blitz array.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
This provides thin wrapper around the GNU Scientific Library gsl_vector.