This is an automated email from the ASF dual-hosted git repository. erans pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git
commit a2491345b8e549f653c0e3592408ca6cfa74bb12 Author: Gilles Sadowski <gillese...@gmail.com> AuthorDate: Mon Aug 9 16:10:48 2021 +0200 Remove duplicate function (unit tests). --- .../optim/nonlinear/scalar/TestFunction.java | 15 +-------------- .../scalar/noderiv/BOBYQAOptimizerTest.java | 14 +++++++------- .../scalar/noderiv/CMAESOptimizerTest.java | 22 +++++++++++----------- .../SimplexOptimizerMultiDirectionalTest.java | 10 ---------- .../noderiv/SimplexOptimizerNelderMeadTest.java | 10 ---------- 5 files changed, 19 insertions(+), 52 deletions(-) diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/TestFunction.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/TestFunction.java index 2dd7048..44ebc4f 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/TestFunction.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/TestFunction.java @@ -104,19 +104,6 @@ public enum TestFunction { return f; }; }), - ROSEN(dim -> { - final int last = dim - 1; - return x -> { - double f = 0; - for (int i = 0; i < last; i++) { - final double xi = x[i]; - final double a = xi * xi - x[i + 1]; - final double b = xi - 1; - f += 1e2 * a * a + b * b; - } - return f; - }; - }), ACKLEY(dim -> { final double A = 20; final double B = 0.2; @@ -176,7 +163,7 @@ public enum TestFunction { final double xiP1 = x[i + 1]; final double a = xiP1 - xi * xi; final double b = xi - 1; - f += 100 * a * a + b * b; + f += 1e2 * a * a + b * b; } return f; }; diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/BOBYQAOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/BOBYQAOptimizerTest.java index 020c67d..bd6cd3a 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/BOBYQAOptimizerTest.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/BOBYQAOptimizerTest.java @@ -42,7 +42,7 @@ public class BOBYQAOptimizerTest { public void testInitOutOfBounds() { double[] startPoint = OptimTestUtils.point(DIM, 3); double[][] boundaries = boundaries(DIM, -1, 2); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, boundaries, GoalType.MINIMIZE, 1e-13, 1e-6, 2000, null); } @@ -51,7 +51,7 @@ public class BOBYQAOptimizerTest { public void testBoundariesDimensionMismatch() { double[] startPoint = OptimTestUtils.point(DIM, 0.5); double[][] boundaries = boundaries(DIM + 1, -1, 2); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, boundaries, GoalType.MINIMIZE, 1e-13, 1e-6, 2000, null); } @@ -59,7 +59,7 @@ public class BOBYQAOptimizerTest { @Test(expected=NumberIsTooSmallException.class) public void testProblemDimensionTooSmall() { double[] startPoint = OptimTestUtils.point(1, 0.5); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, null, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, null, GoalType.MINIMIZE, 1e-13, 1e-6, 2000, null); } @@ -69,7 +69,7 @@ public class BOBYQAOptimizerTest { final int lowMaxEval = 2; double[] startPoint = OptimTestUtils.point(DIM, 0.1); double[][] boundaries = null; - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, boundaries, GoalType.MINIMIZE, 1e-13, 1e-6, lowMaxEval, null); } @@ -79,7 +79,7 @@ public class BOBYQAOptimizerTest { double[] startPoint = OptimTestUtils.point(DIM,0.1); double[][] boundaries = null; PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, boundaries, GoalType.MINIMIZE, 1e-13, 1e-6, 2000, expected); } @@ -230,7 +230,7 @@ public class BOBYQAOptimizerTest { double[][] boundaries = boundaries(DIM,-1,2); PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, boundaries, GoalType.MINIMIZE, 1e-13, 1e-6, 2000, expected); } @@ -252,7 +252,7 @@ public class BOBYQAOptimizerTest { final int maxAdditionalPoints = 47; for (int num = 1; num <= maxAdditionalPoints; num++) { - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, boundaries, GoalType.MINIMIZE, 1e-12, 1e-6, 2000, num, diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java index 6b307b0..bf9bdb4 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java @@ -53,7 +53,7 @@ public class CMAESOptimizerTest { double[][] boundaries = boundaries(DIM,-1,2); PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13, 1e-13, 1e-6, 100000, expected); } @@ -64,7 +64,7 @@ public class CMAESOptimizerTest { double[][] boundaries = boundaries(DIM,-1,2); PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13, 1e-13, 1e-6, 100000, expected); } @@ -76,7 +76,7 @@ public class CMAESOptimizerTest { double[][] boundaries = boundaries(DIM+1,-1,2); PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13, 1e-13, 1e-6, 100000, expected); } @@ -88,7 +88,7 @@ public class CMAESOptimizerTest { double[][] boundaries = null; PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13, 1e-13, 1e-6, 100000, expected); } @@ -100,7 +100,7 @@ public class CMAESOptimizerTest { double[][] boundaries = boundaries(DIM,-0.5,0.5); PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13, 1e-13, 1e-6, 100000, expected); } @@ -112,7 +112,7 @@ public class CMAESOptimizerTest { double[][] boundaries = null; PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13, 1e-13, 1e-6, 100000, expected); } @@ -125,10 +125,10 @@ public class CMAESOptimizerTest { double[][] boundaries = null; PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, LAMBDA, true, 0, 1e-13, 1e-13, 1e-6, 100000, expected); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, LAMBDA, false, 0, 1e-13, 1e-13, 1e-6, 100000, expected); } @@ -365,10 +365,10 @@ public class CMAESOptimizerTest { double[][] boundaries = boundaries(DIM, -1, 2); PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, 2*LAMBDA, true, 0, 1e-13, 1e-13, 1e-6, 100000, expected); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, 2*LAMBDA, false, 0, 1e-13, 1e-13, 1e-6, 100000, expected); } @@ -380,7 +380,7 @@ public class CMAESOptimizerTest { double[][] boundaries = null; PointValuePair expected = new PointValuePair(OptimTestUtils.point(DIM,1.0),0.0); - doTest(TestFunction.ROSEN.withDimension(DIM), startPoint, insigma, boundaries, + doTest(TestFunction.ROSENBROCK.withDimension(DIM), startPoint, insigma, boundaries, GoalType.MINIMIZE, LAMBDA, false, 1, 1e-13, 1e-10, 1e-4, 1000000, expected); } diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java index a652cfb..a381212 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java @@ -142,16 +142,6 @@ public class SimplexOptimizerMultiDirectionalTest { 2e-4); } - @Test - public void testRosen() { - doTest(TestFunction.ROSEN.withDimension(DIM), - OptimTestUtils.point(DIM, 0.1), - GoalType.MINIMIZE, - 186915, - new PointValuePair(OptimTestUtils.point(DIM, 1.0), 0.0), - 1e-4); - } - @Ignore("See MATH-1552")@Test public void testEllipse() { doTest(TestFunction.ELLI.withDimension(DIM), diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java index e2ed741..9b191b4 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java @@ -226,16 +226,6 @@ public class SimplexOptimizerNelderMeadTest { 2e-4); } - @Test - public void testRosen() { - doTest(TestFunction.ROSEN.withDimension(DIM), - OptimTestUtils.point(DIM, 0.1), - GoalType.MINIMIZE, - 9078, - new PointValuePair(OptimTestUtils.point(DIM, 1.0), 0.0), - 1e-6); - } - @Ignore("See MATH-1552")@Test public void testEllipse() { doTest(TestFunction.ELLI.withDimension(DIM),