commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1594174 - in /commons/proper/math/trunk/src: changes/changes.xml main/java/org/apache/commons/math3/optim/univariate/BrentOptimizer.java test/java/org/apache/commons/math3/optim/univariate/BrentOptimizerTest.java
Date Tue, 13 May 2014 09:39:23 GMT
Author: erans
Date: Tue May 13 09:39:22 2014
New Revision: 1594174

URL: http://svn.apache.org/r1594174
Log:
MATH-1121
Use base class iteration counter. Reported by Ajo Fod.

Modified:
    commons/proper/math/trunk/src/changes/changes.xml
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/BrentOptimizer.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/univariate/BrentOptimizerTest.java

Modified: commons/proper/math/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1594174&r1=1594173&r2=1594174&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Tue May 13 09:39:22 2014
@@ -73,6 +73,9 @@ Users are encouraged to upgrade to this 
   2. A few methods in the FastMath class are in fact slower that their
   counterpart in either Math or StrictMath (cf. MATH-740 and MATH-901).
 ">
+      <action dev="erans" type="fix" issue="MATH-1121" due-to="Ajo Fod">
+        "BrentOptimizer": increment base class iteration counter.
+      </action>
     </release>
 
     <release version="3.3" date="2014-05-05" description="

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/BrentOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/BrentOptimizer.java?rev=1594174&r1=1594173&r2=1594174&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/BrentOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/BrentOptimizer.java
Tue May 13 09:39:22 2014
@@ -150,7 +150,6 @@ public class BrentOptimizer extends Univ
         // Best point encountered so far (which is the initial guess).
         UnivariatePointValuePair best = current;
 
-        int iter = 0;
         while (true) {
             final double m = 0.5 * (a + b);
             final double tol1 = relativeThreshold * FastMath.abs(x) + absoluteThreshold;
@@ -238,7 +237,7 @@ public class BrentOptimizer extends Univ
                                  isMinim),
                             isMinim);
 
-                if (checker != null && checker.converged(iter, previous, current))
{
+                if (checker != null && checker.converged(getIterations(), previous,
current)) {
                     return best;
                 }
 
@@ -281,7 +280,8 @@ public class BrentOptimizer extends Univ
                                  isMinim),
                             isMinim);
             }
-            ++iter;
+
+            incrementIterationCount();
         }
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/univariate/BrentOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/univariate/BrentOptimizerTest.java?rev=1594174&r1=1594173&r2=1594174&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/univariate/BrentOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/univariate/BrentOptimizerTest.java
Tue May 13 09:39:22 2014
@@ -162,6 +162,9 @@ public final class BrentOptimizerTest {
         Assert.assertTrue(meanOptValue > -0.2719561281);
         Assert.assertTrue(meanOptValue < -0.2719561280);
         Assert.assertEquals(23, (int) medianEval);
+
+        // MATH-1121: Ensure that the iteration counter is incremented.
+        Assert.assertTrue(optimizer.getIterations() > 0);
     }
 
     @Test



Mime
View raw message