From 16bf40f27abf74b191ad451749424b2b263152af Mon Sep 17 00:00:00 2001 From: stevenj Date: Sun, 9 Nov 2008 21:10:39 -0500 Subject: [PATCH] keep track of max/min evaluation counts darcs-hash:20081110021039-c8de0-3815b01480dc472b75da7fbeb8846e2a2189fefc.gz --- test/testopt.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/testopt.cpp b/test/testopt.cpp index 98ce278..3ea4050 100644 --- a/test/testopt.cpp +++ b/test/testopt.cpp @@ -64,7 +64,7 @@ static int test_function(int ifunc) double *x, minf, minf_max, f0, *xtabs, *lb, *ub; nlopt_result ret; double start = nlopt_seconds(); - int total_count = 0; + int total_count = 0, max_count = 0, min_count = 1<<30; double total_err = 0, max_err = 0; bounds_wrap_data bw; @@ -176,6 +176,8 @@ static int test_function(int ifunc) printf("Found minimum f = %g after %d evaluations.\n", minf, testfuncs_counter); total_count += testfuncs_counter; + if (testfuncs_counter > max_count) max_count = testfuncs_counter; + if (testfuncs_counter < min_count) min_count = testfuncs_counter; printf("Minimum at x = ["); for (i = 0; i < func.n; ++i) printf(" %g", x[i]); printf("]\n"); @@ -196,7 +198,7 @@ static int test_function(int ifunc) } } if (iterations > 1) - printf("average #evaluations = %g\naverage |f-minf| = %g, max |f-minf| = %g\n", total_count * 1.0 / iterations, total_err / iterations, max_err); + printf("average #evaluations = %g (%d-%d)\naverage |f-minf| = %g, max |f-minf| = %g\n", total_count * 1.0 / iterations, min_count, max_count, total_err / iterations, max_err); free(x); return 1; -- 2.30.2