You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2018/08/29 00:15:55 UTC
[4/4] [math] Unit test for MATH-1466.
Unit test for MATH-1466.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/efb02300
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/efb02300
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/efb02300
Branch: refs/heads/master
Commit: efb0230063b31d53bd077d9f6a4bb64fcbb9c97f
Parents: 2b4fcc2
Author: Gilles <er...@apache.org>
Authored: Wed Aug 29 02:13:57 2018 +0200
Committer: Gilles <er...@apache.org>
Committed: Wed Aug 29 02:13:57 2018 +0200
----------------------------------------------------------------------
.../scalar/noderiv/CMAESOptimizerTest.java | 24 ++++++++++++++++++++
1 file changed, 24 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/efb02300/src/test/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizerTest.java
----------------------------------------------------------------------
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 f7ea7b8..d7fb53d 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
@@ -158,6 +158,30 @@ public class CMAESOptimizerTest {
}
@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);
double[] insigma = point(DIM,0.1);