From: stevenj Date: Mon, 10 Nov 2008 02:10:39 +0000 (-0500) Subject: keep track of max/min evaluation counts X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=16bf40f27abf74b191ad451749424b2b263152af;p=nlopt.git keep track of max/min evaluation counts darcs-hash:20081110021039-c8de0-3815b01480dc472b75da7fbeb8846e2a2189fefc.gz --- 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;