commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1401928 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization: direct/BaseAbstractMultivariateOptimizer.java general/AbstractDifferentiableOptimizer.java general/AbstractScalarDifferentiableOptimizer.java
Date Thu, 25 Oct 2012 00:20:24 GMT
Author: erans
Date: Thu Oct 25 00:20:24 2012
New Revision: 1401928

URL: http://svn.apache.org/viewvc?rev=1401928&view=rev
Log:
MATH-874
Reduced number of overridden public "optimize" methods (replaced by protected
"optimizeInternal"): whenever the code is ready for 4.0, only the base class's
"optimize" method should define the public API (subclass specifics are handled
in overridden "optimizeInternal" which must call the base class's version to
handle the common setup).

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/direct/BaseAbstractMultivariateOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractDifferentiableOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractScalarDifferentiableOptimizer.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/direct/BaseAbstractMultivariateOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/direct/BaseAbstractMultivariateOptimizer.java?rev=1401928&r1=1401927&r2=1401928&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/direct/BaseAbstractMultivariateOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/direct/BaseAbstractMultivariateOptimizer.java
Thu Oct 25 00:20:24 2012
@@ -162,7 +162,7 @@ public abstract class BaseAbstractMultiv
      * instead.
      */
     @Deprecated
-    protected PointValuePair optimizeInternal(int maxEval, MultivariateFunction f, GoalType
goalType,
+    protected PointValuePair optimizeInternal(int maxEval, FUNC f, GoalType goalType,
                                               double[] startPoint) {
         return optimizeInternal(maxEval, f, goalType, new InitialGuess(startPoint));
     }
@@ -184,7 +184,7 @@ public abstract class BaseAbstractMultiv
      * evaluations is exceeded.
      */
     protected PointValuePair optimizeInternal(int maxEval,
-                                              MultivariateFunction f,
+                                              FUNC f,
                                               GoalType goalType,
                                               OptimizationData... optData)
         throws TooManyEvaluationsException {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractDifferentiableOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractDifferentiableOptimizer.java?rev=1401928&r1=1401927&r2=1401928&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractDifferentiableOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractDifferentiableOptimizer.java
Thu Oct 25 00:20:24 2012
@@ -22,6 +22,8 @@ import org.apache.commons.math3.analysis
 import org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableFunction;
 import org.apache.commons.math3.optimization.ConvergenceChecker;
 import org.apache.commons.math3.optimization.GoalType;
+import org.apache.commons.math3.optimization.OptimizationData;
+import org.apache.commons.math3.optimization.InitialGuess;
 import org.apache.commons.math3.optimization.MultivariateDifferentiableOptimizer;
 import org.apache.commons.math3.optimization.PointValuePair;
 import org.apache.commons.math3.optimization.direct.BaseAbstractMultivariateOptimizer;
@@ -35,9 +37,7 @@ import org.apache.commons.math3.optimiza
  * @since 3.1
  */
 public abstract class AbstractDifferentiableOptimizer
-    extends BaseAbstractMultivariateOptimizer<MultivariateDifferentiableFunction>
-    implements MultivariateDifferentiableOptimizer {
-
+    extends BaseAbstractMultivariateOptimizer<MultivariateDifferentiableFunction> {
     /**
      * Objective function gradient.
      */
@@ -60,17 +60,31 @@ public abstract class AbstractDifferenti
         return gradient.value(evaluationPoint);
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * @deprecated In 3.1. Please use
+     * {@link #optimizeInternal(int,MultivariateDifferentiableFunction,GoalType,OptimizationData[])}
+     * instead.
+     */
+    @Override@Deprecated
+    protected PointValuePair optimizeInternal(final int maxEval,
+                                              final MultivariateDifferentiableFunction f,
+                                              final GoalType goalType,
+                                              final double[] startPoint) {
+        return optimizeInternal(maxEval, f, goalType, new InitialGuess(startPoint));
+    }
+
     /** {@inheritDoc} */
     @Override
-    public PointValuePair optimize(final int maxEval, final MultivariateDifferentiableFunction
f,
-                                   final GoalType goalType, final double[] startPoint) {
-
-        // store optimization problem characteristics
+    protected PointValuePair optimizeInternal(final int maxEval,
+                                              final MultivariateDifferentiableFunction f,
+                                              final GoalType goalType,
+                                              final OptimizationData... optData) {
+        // Store optimization problem characteristics.
         gradient = new GradientFunction(f);
 
-        // perform optimization
-        return super.optimize(maxEval, f, goalType, startPoint);
-
+        // Perform optimization.
+        return super.optimizeInternal(maxEval, f, goalType, optData);
     }
-
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractScalarDifferentiableOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractScalarDifferentiableOptimizer.java?rev=1401928&r1=1401927&r2=1401928&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractScalarDifferentiableOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optimization/general/AbstractScalarDifferentiableOptimizer.java
Thu Oct 25 00:20:24 2012
@@ -19,7 +19,7 @@ package org.apache.commons.math3.optimiz
 
 import org.apache.commons.math3.analysis.DifferentiableMultivariateFunction;
 import org.apache.commons.math3.analysis.MultivariateVectorFunction;
-import org.apache.commons.math3.analysis.differentiation.GradientFunction;
+import org.apache.commons.math3.analysis.FunctionUtils;
 import org.apache.commons.math3.analysis.differentiation.MultivariateDifferentiableFunction;
 import org.apache.commons.math3.optimization.DifferentiableMultivariateOptimizer;
 import org.apache.commons.math3.optimization.GoalType;
@@ -76,14 +76,14 @@ public abstract class AbstractScalarDiff
 
     /** {@inheritDoc} */
     @Override
-    public PointValuePair optimize(int maxEval,
-                                       final DifferentiableMultivariateFunction f,
-                                       final GoalType goalType,
-                                       final double[] startPoint) {
+    protected PointValuePair optimizeInternal(int maxEval,
+                                              final DifferentiableMultivariateFunction f,
+                                              final GoalType goalType,
+                                              final double[] startPoint) {
         // Store optimization problem characteristics.
         gradient = f.gradient();
 
-        return optimizeInternal(maxEval, f, goalType, startPoint);
+        return super.optimizeInternal(maxEval, f, goalType, startPoint);
     }
 
     /**
@@ -107,9 +107,9 @@ public abstract class AbstractScalarDiff
                                    final MultivariateDifferentiableFunction f,
                                    final GoalType goalType,
                                    final double[] startPoint) {
-        // Store optimization problem characteristics.
-        gradient = new GradientFunction(f);
-
-        return optimizeInternal(maxEval, f, goalType, startPoint);
+        return optimizeInternal(maxEval,
+                                FunctionUtils.toDifferentiableMultivariateFunction(f),
+                                goalType,
+                                startPoint);
     }
 }



Mime
View raw message