commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1164303 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java
Date Fri, 02 Sep 2011 00:07:17 GMT
Author: erans
Date: Fri Sep  2 00:07:16 2011
New Revision: 1164303

URL: http://svn.apache.org/viewvc?rev=1164303&view=rev
Log:
MATH-413
Optional, user-defined, convergence checker passed in the constructor.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java?rev=1164303&r1=1164302&r2=1164303&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/PowellOptimizer.java
Fri Sep  2 00:07:16 2011
@@ -39,9 +39,8 @@ import org.apache.commons.math.optimizat
  * <br/>
  * The default stopping criterion is based on the differences of the
  * function value between two successive iterations. It is however possible
- * to define custom convergence criteria by calling a {@link
- * #setConvergenceChecker(ConvergenceChecker) setConvergenceChecker}
- * prior to using the optimizer.
+ * to define a custom convergence checker that might terminate the algorithm
+ * earlier.
  *
  * @version $Id$
  * @since 2.2
@@ -67,16 +66,21 @@ public class PowellOptimizer
     private final LineSearch line;
 
     /**
-     * The arguments control the behaviour of the default convergence
-     * checking procedure.
+     * This constructor allows to specify a user-defined convergence checker,
+     * in addition to the parameters that control the default convergence
+     * checking procedure and the line search tolerances.
      *
      * @param rel Relative threshold.
      * @param abs Absolute threshold.
+     * @param checker Convergence checker.
      * @throws NotStrictlyPositiveException if {@code abs <= 0}.
      * @throws NumberIsTooSmallException if {@code rel < 2 * Math.ulp(1d)}.
      */
     public PowellOptimizer(double rel,
-                           double abs) {
+                           double abs,
+                           ConvergenceChecker<RealPointValuePair> checker) {
+        super(checker);
+
         if (rel < MIN_RELATIVE_TOLERANCE) {
             throw new NumberIsTooSmallException(rel, MIN_RELATIVE_TOLERANCE, true);
         }
@@ -94,6 +98,20 @@ public class PowellOptimizer
         line = new LineSearch(lsRel, lsAbs);
     }
 
+    /**
+     * The parameters control the default convergence checking procedure, and
+     * the line search tolerances.
+     *
+     * @param rel Relative threshold.
+     * @param abs Absolute threshold.
+     * @throws NotStrictlyPositiveException if {@code abs <= 0}.
+     * @throws NumberIsTooSmallException if {@code rel < 2 * Math.ulp(1d)}.
+     */
+    public PowellOptimizer(double rel,
+                           double abs) {
+        this(rel, abs, null);
+    }
+
     /** {@inheritDoc} */
     @Override
     protected RealPointValuePair doOptimize() {



Mime
View raw message