20 using namespace blitz;
22 BOOST_FIXTURE_TEST_SUITE(nlls_solver_gsl_sm_freudenstein_roth_b,
GlobalFixture)
34 Array<double, 1> x0(2); x0 = 6.0, 7.0;
48 int n_f_calls = nlls->num_residual_evaluations();
49 int n_j_calls = nlls->num_jacobian_evaluations();
50 double cst = nlls->cost();
53 <<
"Testing NLLSSolverGSLSM with Freudenstein/Roth function:" << std::endl
54 <<
" Number of residual function evaluations = " << n_f_calls << std::endl
55 <<
" Number of jacobian function evaluations = " << n_j_calls << std::endl
56 <<
" Final solver status = " << solver.
status_str() << std::endl
57 <<
" Final problem status (point) = " << nlls->parameters() << std::endl
58 <<
" Final problem status (cost value) = " << cst << std::endl
59 <<
" Final problem status (gradient) = " << nlls->gradient() << std::endl;
62 <<
" ========================================" << std::endl
73 BOOST_CHECK_CLOSE(sum(abs(nlls->parameters()-solver.
accepted_points()[iLast])), 0.0, 1e-12);
77 BOOST_CHECK(n_f_calls < 10);
78 BOOST_CHECK(n_j_calls <= n_f_calls);
79 BOOST_CHECK( (abs(cst-0.0) < 0.0000001) || (abs(cst-24.4921) < 0.001) );
80 if( abs(cst-0.0) < 0.0000001 ) {
81 BOOST_CHECK_CLOSE(nlls->parameters()(0), 5.0, 0.01);
82 BOOST_CHECK_CLOSE(nlls->parameters()(1), 4.0, 0.01);
84 BOOST_CHECK_CLOSE(nlls->parameters()(0), 11.413, 0.01);
85 BOOST_CHECK_CLOSE(nlls->parameters()(1), -0.89681, 0.01);
94 Array<double, 1> x0(2); x0 = 6.0, 7.0;
106 gsl_multifit_nlinear_parameters fdf_params=gsl_multifit_nlinear_default_parameters();
107 fdf_params.trs = gsl_multifit_nlinear_trs_lm;
108 fdf_params.scale = gsl_multifit_nlinear_scale_more;
109 fdf_params.solver = gsl_multifit_nlinear_solver_svd;
115 int n_f_calls = nlls->num_residual_evaluations();
116 int n_j_calls = nlls->num_jacobian_evaluations();
117 double cst = nlls->cost();
120 <<
"Testing NLLSSolverGSLSM with Freudenstein/Roth function:" << std::endl
121 <<
" Number of residual function evaluations = " << n_f_calls << std::endl
122 <<
" Number of jacobian function evaluations = " << n_j_calls << std::endl
123 <<
" Final solver status = " << solver.
status_str() << std::endl
124 <<
" Final problem status (point) = " << nlls->parameters() << std::endl
125 <<
" Final problem status (cost value) = " << cst << std::endl
126 <<
" Final problem status (gradient) = " << nlls->gradient() << std::endl;
129 <<
" ========================================" << std::endl
140 BOOST_CHECK_CLOSE(sum(abs(nlls->parameters()-solver.
accepted_points()[iLast])), 0.0, 1e-12);
144 BOOST_CHECK(n_f_calls < 10);
145 BOOST_CHECK(n_j_calls <= n_f_calls);
146 BOOST_CHECK( (abs(cst-0.0) < 0.0000001) || (abs(cst-24.4921) < 0.001) );
147 if( abs(cst-0.0) < 0.0000001 ) {
148 BOOST_CHECK_CLOSE(nlls->parameters()(0), 5.0, 0.01);
149 BOOST_CHECK_CLOSE(nlls->parameters()(1), 4.0, 0.01);
151 BOOST_CHECK_CLOSE(nlls->parameters()(0), 11.413, 0.01);
152 BOOST_CHECK_CLOSE(nlls->parameters()(1), -0.89681, 0.01);
161 Array<double, 1> x0(2); x0 = 6.0, 7.0;
166 nlls->parameters(x0);
173 gsl_multifit_nlinear_parameters fdf_params=gsl_multifit_nlinear_default_parameters();
174 fdf_params.trs = gsl_multifit_nlinear_trs_lmaccel;
175 fdf_params.scale = gsl_multifit_nlinear_scale_more;
176 fdf_params.solver = gsl_multifit_nlinear_solver_svd;
177 fdf_params.fdtype = GSL_MULTIFIT_NLINEAR_CTRDIFF;
183 int n_f_calls = nlls->num_residual_evaluations();
184 int n_j_calls = nlls->num_jacobian_evaluations();
185 double cst = nlls->cost();
188 <<
"Testing NLLSSolverGSLSM with Freudenstein/Roth function:" << std::endl
189 <<
" Number of residual function evaluations = " << n_f_calls << std::endl
190 <<
" Number of jacobian function evaluations = " << n_j_calls << std::endl
191 <<
" Final solver status = " << solver.
status_str() << std::endl
192 <<
" Final problem status (point) = " << nlls->parameters() << std::endl
193 <<
" Final problem status (cost value) = " << cst << std::endl
194 <<
" Final problem status (gradient) = " << nlls->gradient() << std::endl;
197 <<
" ========================================" << std::endl
208 BOOST_CHECK_CLOSE(sum(abs(nlls->parameters()-solver.
accepted_points()[iLast])), 0.0, 1e-12);
212 BOOST_CHECK(n_f_calls < 25);
213 BOOST_CHECK(n_j_calls <= n_f_calls);
214 BOOST_CHECK( (abs(cst-0.0) < 0.0000001) || (abs(cst-24.4921) < 0.001) );
215 if( abs(cst-0.0) < 0.0000001 ) {
216 BOOST_CHECK_CLOSE(nlls->parameters()(0), 5.0, 0.01);
217 BOOST_CHECK_CLOSE(nlls->parameters()(1), 4.0, 0.01);
219 BOOST_CHECK_CLOSE(nlls->parameters()(0), 11.413, 0.01);
220 BOOST_CHECK_CLOSE(nlls->parameters()(1), -0.89681, 0.01);
229 Array<double, 1> x0(2); x0 = 6.0, 7.0;
234 nlls->parameters(x0);
241 gsl_multifit_nlinear_parameters fdf_params=gsl_multifit_nlinear_default_parameters();
242 fdf_params.trs = gsl_multifit_nlinear_trs_subspace2D;
243 fdf_params.scale = gsl_multifit_nlinear_scale_more;
244 fdf_params.solver = gsl_multifit_nlinear_solver_svd;
250 int n_f_calls = nlls->num_residual_evaluations();
251 int n_j_calls = nlls->num_jacobian_evaluations();
252 double cst = nlls->cost();
255 <<
"Testing NLLSSolverGSLSM with Freudenstein/Roth function:" << std::endl
256 <<
" Number of residual function evaluations = " << n_f_calls << std::endl
257 <<
" Number of jacobian function evaluations = " << n_j_calls << std::endl
258 <<
" Final solver status = " << solver.
status_str() << std::endl
259 <<
" Final problem status (point) = " << nlls->parameters() << std::endl
260 <<
" Final problem status (cost value) = " << cst << std::endl
261 <<
" Final problem status (gradient) = " << nlls->gradient() << std::endl;
264 <<
" ========================================" << std::endl
275 BOOST_CHECK_CLOSE(sum(abs(nlls->parameters()-solver.
accepted_points()[iLast])), 0.0, 1e-12);
279 BOOST_CHECK(n_f_calls < 10);
280 BOOST_CHECK(n_j_calls <= n_f_calls);
281 BOOST_CHECK( (abs(cst-0.0) < 0.0000001) || (abs(cst-24.4921) < 0.001) );
282 if( abs(cst-0.0) < 0.0000001 ) {
283 BOOST_CHECK_CLOSE(nlls->parameters()(0), 5.0, 0.01);
284 BOOST_CHECK_CLOSE(nlls->parameters()(1), 4.0, 0.01);
286 BOOST_CHECK_CLOSE(nlls->parameters()(0), 11.413, 0.01);
287 BOOST_CHECK_CLOSE(nlls->parameters()(1), -0.89681, 0.01);
296 Array<double, 1> x0(2); x0 = 6.0, 7.0;
301 nlls->parameters(x0);
308 gsl_multifit_nlinear_parameters fdf_params=gsl_multifit_nlinear_default_parameters();
309 fdf_params.trs = gsl_multifit_nlinear_trs_ddogleg;
310 fdf_params.scale = gsl_multifit_nlinear_scale_more;
311 fdf_params.solver = gsl_multifit_nlinear_solver_svd;
317 int n_f_calls = nlls->num_residual_evaluations();
318 int n_j_calls = nlls->num_jacobian_evaluations();
319 double cst = nlls->cost();
322 <<
"Testing NLLSSolverGSLSM with Freudenstein/Roth function:" << std::endl
323 <<
" Number of residual function evaluations = " << n_f_calls << std::endl
324 <<
" Number of jacobian function evaluations = " << n_j_calls << std::endl
325 <<
" Final solver status = " << solver.
status_str() << std::endl
326 <<
" Final problem status (point) = " << nlls->parameters() << std::endl
327 <<
" Final problem status (cost value) = " << cst << std::endl
328 <<
" Final problem status (gradient) = " << nlls->gradient() << std::endl;
331 <<
" ========================================" << std::endl
342 BOOST_CHECK_CLOSE(sum(abs(nlls->parameters()-solver.
accepted_points()[iLast])), 0.0, 1e-12);
346 BOOST_CHECK(n_f_calls < 10);
347 BOOST_CHECK(n_j_calls <= n_f_calls);
348 BOOST_CHECK( (abs(cst-0.0) < 0.0000001) || (abs(cst-24.4921) < 0.001) );
349 if( abs(cst-0.0) < 0.0000001 ) {
350 BOOST_CHECK_CLOSE(nlls->parameters()(0), 5.0, 0.01);
351 BOOST_CHECK_CLOSE(nlls->parameters()(1), 4.0, 0.01);
353 BOOST_CHECK_CLOSE(nlls->parameters()(0), 11.413, 0.01);
354 BOOST_CHECK_CLOSE(nlls->parameters()(1), -0.89681, 0.01);
918 BOOST_AUTO_TEST_SUITE_END()
virtual const char *const status_str() const
Returns the string version of the solver status.
This is a global fixture that is available to all unit tests.
virtual std::vector< blitz::Array< double, 1 > > gradient_at_accepted_points() const
Returns a vector (std) of gradients evaluated at accepted points.
solve method called and a solution found
virtual void solve()
The method that solves the optimization problem.
virtual int num_accepted_steps() const
Returns the number of the accepted steps.
Apply value function to a blitz array.
solve method not called yet
BOOST_AUTO_TEST_CASE(freudenstein_roth_b_gsl_sm__default)
virtual status_t status() const
Returns a value of IterativeSolver::status_t type.
virtual std::vector< blitz::Array< double, 1 > > accepted_points() const
Returns a vector (std) of accepted points.
virtual std::vector< double > cost_at_accepted_points() const
Returns a vector (std) of cost function values at accepted points.
Contains classes to abstract away details in various Spurr Radiative Transfer software.