diff --git a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java index f7ea7b898..d7fb53d3e 100644 --- a/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java +++ b/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java @@ -157,6 +157,30 @@ public class CMAESOptimizerTest { 2e-10, 5e-6, 100000, expected); } + @Test + public void testMath1466() { + final CMAESOptimizer optimizer + = new CMAESOptimizer(30000, Double.NEGATIVE_INFINITY, true, 10, + 0, RandomSource.create(RandomSource.MT_64), false, null); + final MultivariateFunction fitnessFunction = new MultivariateFunction() { + @Override + public double value(double[] x) { + return x[0] * x[0] - 100; + } + }; + + final double[] start = { 100 }; + final double[] sigma = { 1e-1 }; + final double[] result = optimizer.optimize(new MaxEval(10000), + new ObjectiveFunction(fitnessFunction), + SimpleBounds.unbounded(1), + GoalType.MINIMIZE, + new CMAESOptimizer.PopulationSize(5), + new CMAESOptimizer.Sigma(sigma), + new InitialGuess(start)).getPoint(); + Assert.assertEquals(0, result[0], 1e-7); + } + @Test public void testEllipse() { double[] startPoint = point(DIM,1.0);