commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1198741 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java site/xdoc/changes.xml test/java/org/apache/commons/math/optimization/direct/CMAESOptimizerTest.java
Date Mon, 07 Nov 2011 14:12:45 GMT
Author: luc
Date: Mon Nov  7 14:12:45 2011
New Revision: 1198741

URL: http://svn.apache.org/viewvc?rev=1198741&view=rev
Log:
Make CMA-ES input sigma is now consistent with boundaries units.

JIRA: MATH-702

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/CMAESOptimizerTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java?rev=1198741&r1=1198740&r2=1198741&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/CMAESOptimizer.java
Mon Nov  7 14:12:45 2011
@@ -515,8 +515,8 @@ public class CMAESOptimizer
                     throw new NotPositiveException(inputSigma[i]);
                 }
                 if (boundaries != null) {
-                    if (inputSigma[i] > 1.0) {
-                        throw new OutOfRangeException(inputSigma[i], 0, 1.0);
+                    if (inputSigma[i] > boundaries[1][i] - boundaries[0][i]) {
+                        throw new OutOfRangeException(inputSigma[i], 0, boundaries[1][i]
- boundaries[0][i]);
                     }
                 }
             }
@@ -535,7 +535,8 @@ public class CMAESOptimizer
         // initialize sigma
         double[][] sigmaArray = new double[guess.length][1];
         for (int i = 0; i < guess.length; i++) {
-            sigmaArray[i][0] = inputSigma != null ? inputSigma[i] : 0.3;
+            final double range =  (boundaries == null) ? 1.0 : boundaries[1][i] - boundaries[0][i];
+            sigmaArray[i][0]   = ((inputSigma == null) ? 0.3 : inputSigma[i]) / range;
         }
         RealMatrix insigma = new Array2DRowRealMatrix(sigmaArray, false);
         sigma = max(insigma); // overall standard deviation

Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=1198741&r1=1198740&r2=1198741&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Mon Nov  7 14:12:45 2011
@@ -52,6 +52,9 @@ The <action> type attribute can be add,u
     If the output is not quite correct, check for invisible trailing spaces!
      -->
     <release version="3.0" date="TBD" description="TBD">
+      <action dev="luc" type="fix" issue="MATH-702" >
+        CMA-ES optimizer input sigma is now consistent with boundaries range units.
+      </action>
       <action dev="psteitz" type="add" issue="MATH-462" due-to="Pavel Ryzhof">
         Added stable random generator based on Chambers-Mallows-Stuck method.
       </action>

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/CMAESOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/CMAESOptimizerTest.java?rev=1198741&r1=1198740&r2=1198741&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/CMAESOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/direct/CMAESOptimizerTest.java
Mon Nov  7 14:12:45 2011
@@ -96,7 +96,7 @@ public class CMAESOptimizerTest {
     public void testInputSigmaOutOfRange() {
         double[] startPoint = point(DIM,0.5);
         double[] insigma = point(DIM, 1.1);
-        double[][] boundaries = boundaries(DIM,-1,2);
+        double[][] boundaries = boundaries(DIM,-0.5,0.5);
         RealPointValuePair expected =
             new RealPointValuePair(point(DIM,1.0),0.0);
         doTest(new Rosen(), startPoint, insigma, boundaries,



Mime
View raw message