From a37c5e7c2bdc0f4724c3bc14960b485fb7db541a Mon Sep 17 00:00:00 2001 From: Davis King Date: Mon, 19 Feb 2018 13:31:07 -0500 Subject: [PATCH] Add the example program contents as a test as well. --- tools/python/test/test_global_optimization.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/python/test/test_global_optimization.py b/tools/python/test/test_global_optimization.py index 5e85ca920..548fce34e 100644 --- a/tools/python/test/test_global_optimization.py +++ b/tools/python/test/test_global_optimization.py @@ -21,3 +21,17 @@ def test_global_optimization_nargs(): find_max_global(lambda a, b, c, d, *args: 0, [0, 0, 0], [1, 1, 1], 10) with raises(Exception): find_min_global(lambda a, b, c, d, *args: 0, [0, 0, 0], [1, 1, 1], 10) + + + + +from math import sin,cos,pi,exp,sqrt +def holder_table(x0,x1): + return -abs(sin(x0)*cos(x1)*exp(abs(1-sqrt(x0*x0+x1*x1)/pi))) + +def test_on_holder_table(): + x,y = find_min_global(holder_table, + [-10,-10], + [10,10], + 200) + assert (y - -19.2085025679) < 1e-7