From 0facde2a5224bb2a17f26540eb493e369a78ab0c Mon Sep 17 00:00:00 2001 From: Marc Fehling Date: Thu, 19 May 2022 15:17:14 -0600 Subject: [PATCH] Check for range of function calls in bfgs tests. --- tests/optimization/bfgs_05.cc | 11 +++++++---- tests/optimization/bfgs_05.output | 3 +-- tests/optimization/bfgs_05b.cc | 11 +++++++---- tests/optimization/bfgs_05b.output | 3 +-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/optimization/bfgs_05.cc b/tests/optimization/bfgs_05.cc index bd12085ce3..cfccb73523 100644 --- a/tests/optimization/bfgs_05.cc +++ b/tests/optimization/bfgs_05.cc @@ -210,7 +210,13 @@ test() SolverBFGS solver(solver_control, data); solver.connect_line_search_slot(line_min); solver.connect_preconditioner_slot(preconditioner); - solver.solve(func, x); + + // We will check whether the number of function calls is within a specified + // range. + check_solver_within_range(solver.solve(func, x), + (tot_fun_calls - 1) /*one evaluation above*/, + 130, + 140); Assert(tot_fun_calls == line_search_iterations + 1, ExcInternalError()); @@ -221,9 +227,6 @@ test() x.add(-1, location); deallog << "Linf error in solution: " << x.linfty_norm() << std::endl; - - // deallog << "function calls: " - // << (tot_fun_calls - 1) /*one evaluation above*/ << std::endl; } int diff --git a/tests/optimization/bfgs_05.output b/tests/optimization/bfgs_05.output index a9c3007991..ed87759ccc 100644 --- a/tests/optimization/bfgs_05.output +++ b/tests/optimization/bfgs_05.output @@ -1,5 +1,4 @@ -DEAL:BFGS::Starting value 63.201 ------------------------------------------------ Line search 0 @@ -156,7 +155,7 @@ function value: 9.39817 stepsize: 1.00000 -0.10382 -2.78767 0.00745 -0.04649 -1.29372 0.00407 0.00033 0.06337 -0.00053 -DEAL:BFGS::Convergence step 127 value 8.1397e-06 +DEAL::Solver stopped within 130 - 140 iterations DEAL::Limited memory BFGS solution: -4.483e-09 5.000e-02 1.000e-01 1.500e-01 2.000e-01 2.500e-01 3.000e-01 3.500e-01 4.000e-01 4.500e-01 5.000e-01 5.500e-01 6.000e-01 6.500e-01 7.000e-01 7.500e-01 8.000e-01 8.500e-01 9.000e-01 9.500e-01 1.000e+00 DEAL::Function value: 1.3096e-13 diff --git a/tests/optimization/bfgs_05b.cc b/tests/optimization/bfgs_05b.cc index 5d5257aee9..b2632f9e4d 100644 --- a/tests/optimization/bfgs_05b.cc +++ b/tests/optimization/bfgs_05b.cc @@ -113,7 +113,13 @@ test() typename SolverBFGS::AdditionalData data(m_max, false); SolverBFGS solver(solver_control, data); solver.connect_preconditioner_slot(preconditioner); - solver.solve(func, x); + + // We will check whether the number of function calls is within a specified + // range. + check_solver_within_range(solver.solve(func, x), + (tot_fun_calls - 1) /*one evaluation above*/, + 130, + 140); deallog << "Limited memory BFGS solution:" << std::endl; x.print(deallog.get_file_stream()); @@ -122,9 +128,6 @@ test() x.add(-1, location); deallog << "Linf error in solution: " << x.linfty_norm() << std::endl; - - // deallog << "function calls: " - // << (tot_fun_calls - 1) /*one evaluation above*/ << std::endl; } int diff --git a/tests/optimization/bfgs_05b.output b/tests/optimization/bfgs_05b.output index e3b6ff7268..bc2b2c92d4 100644 --- a/tests/optimization/bfgs_05b.output +++ b/tests/optimization/bfgs_05b.output @@ -1,6 +1,5 @@ -DEAL:BFGS::Starting value 63.201 -DEAL:BFGS::Convergence step 127 value 8.1397e-06 +DEAL::Solver stopped within 130 - 140 iterations DEAL::Limited memory BFGS solution: -4.483e-09 5.000e-02 1.000e-01 1.500e-01 2.000e-01 2.500e-01 3.000e-01 3.500e-01 4.000e-01 4.500e-01 5.000e-01 5.500e-01 6.000e-01 6.500e-01 7.000e-01 7.500e-01 8.000e-01 8.500e-01 9.000e-01 9.500e-01 1.000e+00 DEAL::Function value: 1.3096e-13 -- 2.39.5