commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1443444 - in /commons/proper/math/trunk/src: changes/ main/java/org/apache/commons/math3/optim/ main/java/org/apache/commons/math3/optim/linear/ main/java/org/apache/commons/math3/optim/nonlinear/scalar/ main/java/org/apache/commons/math3/...
Date Thu, 07 Feb 2013 12:41:37 GMT
Author: erans
Date: Thu Feb  7 12:41:36 2013
New Revision: 1443444

URL: http://svn.apache.org/viewvc?rev=1443444&view=rev
Log:
MATH-933
Throw exception from optimizers that do not support simple bounds.
Changing visibility of "parseOptimizationData" method to "protected" in order
to allow the parent class to parse its data before the subclass (and thus
providing more flexibility: the subclass is able check input consistency at
the options parsing step).

Modified:
    commons/proper/math/trunk/src/changes/changes.xml
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseMultivariateOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/LinearOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/GradientMultivariateOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/MultivariateOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/JacobianMultivariateVectorOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/MultivariateVectorOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/AbstractLeastSquaresOptimizer.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/UnivariateOptimizer.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizerTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.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=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Thu Feb  7 12:41:36 2013
@@ -55,6 +55,11 @@ This is a minor release: It combines bug
   Changes to existing features were made in a backwards-compatible
   way such as to allow drop-in replacement of the v3.1[.1] JAR file.
 ">
+      <action dev="erans" type="update" issue="MATH-933">
+        Throw "MathUnsupportedOperationException" from optimizers that do
+        not support constraints (previous behaviour was to silently ignore
+        the "SimpleBounds" argument).
+      </action>
       <action dev="luc" type="add" >
         Added conversion of gradients and Hessians from spherical to Cartesian
         coordinates in 3D.

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseMultivariateOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseMultivariateOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseMultivariateOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseMultivariateOptimizer.java Thu Feb  7 12:41:36 2013
@@ -51,10 +51,10 @@ public abstract class BaseMultivariateOp
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data.
-     * The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link BaseOptimizer#parseOptimizationData(OptimizationData[]) BaseOptimizer},
+     * this method will register the following data:
      * <ul>
-     *  <li>{@link MaxEval}</li>
      *  <li>{@link InitialGuess}</li>
      *  <li>{@link SimpleBounds}</li>
      * </ul>
@@ -62,10 +62,6 @@ public abstract class BaseMultivariateOp
      */
     @Override
     public PAIR optimize(OptimizationData... optData) {
-        // Retrieve settings.
-        parseOptimizationData(optData);
-        // Check input consistency.
-        checkParameters();
         // Perform optimization.
         return super.optimize(optData);
     }
@@ -80,7 +76,11 @@ public abstract class BaseMultivariateOp
      *  <li>{@link SimpleBounds}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {
@@ -95,6 +95,9 @@ public abstract class BaseMultivariateOp
                 continue;
             }
         }
+
+        // Check input consistency.
+        checkParameters();
     }
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/BaseOptimizer.java Thu Feb  7 12:41:36 2013
@@ -112,8 +112,14 @@ public abstract class BaseOptimizer<PAIR
      * only when actually present in the list of arguments: when not specified,
      * data set in a previous call is retained (and thus is optional in
      * subsequent calls).
+     * <br/>
+     * Important note: Subclasses <em>must</em> override
+     * {@link #parseOptimizationData(OptimizationData[])} if they need to register
+     * their own options; but then, they <em>must</em> also call
+     * {@code super.parseOptimizationData(optData)} within that method.
      *
-     * @param optData Optimization data. The following data will be looked for:
+     * @param optData Optimization data.
+     * This method will register the following data:
      * <ul>
      *  <li>{@link MaxEval}</li>
      *  <li>{@link MaxIter}</li>
@@ -127,8 +133,9 @@ public abstract class BaseOptimizer<PAIR
     public PAIR optimize(OptimizationData... optData)
         throws TooManyEvaluationsException,
                TooManyIterationsException {
-        // Retrieve settings.
+        // Parse options.
         parseOptimizationData(optData);
+
         // Reset counters.
         evaluations.resetCount();
         iterations.resetCount();
@@ -177,7 +184,7 @@ public abstract class BaseOptimizer<PAIR
      *  <li>{@link MaxIter}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    protected void parseOptimizationData(OptimizationData... optData) {
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/LinearOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/LinearOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/LinearOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/linear/LinearOptimizer.java Thu Feb  7 12:41:36 2013
@@ -76,9 +76,10 @@ public abstract class LinearOptimizer
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data. The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link MultivariateOptimizer#parseOptimizationData(OptimizationData[])
+     * MultivariateOptimizer}, this method will register the following data:
      * <ul>
-     *  <li>{@link org.apache.commons.math3.optim.MaxIter}</li>
      *  <li>{@link LinearObjectiveFunction}</li>
      *  <li>{@link LinearConstraintSet}</li>
      *  <li>{@link NonNegativeConstraint}</li>
@@ -90,8 +91,6 @@ public abstract class LinearOptimizer
     @Override
     public PointValuePair optimize(OptimizationData... optData)
         throws TooManyIterationsException {
-         // Retrieve settings.
-        parseOptimizationData(optData);
         // Set up base class and perform computation.
         return super.optimize(optData);
     }
@@ -108,7 +107,11 @@ public abstract class LinearOptimizer
      *  <li>{@link NonNegativeConstraint}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/GradientMultivariateOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/GradientMultivariateOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/GradientMultivariateOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/GradientMultivariateOptimizer.java Thu Feb  7 12:41:36 2013
@@ -57,14 +57,10 @@ public abstract class GradientMultivaria
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data.
-     * The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link MultivariateOptimizer#parseOptimizationData(OptimizationData[])
+     * MultivariateOptimizer}, this method will register the following data:
      * <ul>
-     *  <li>{@link org.apache.commons.math3.optim.MaxEval}</li>
-     *  <li>{@link org.apache.commons.math3.optim.InitialGuess}</li>
-     *  <li>{@link org.apache.commons.math3.optim.SimpleBounds}</li>
-     *  <li>{@link ObjectiveFunction}</li>
-     *  <li>{@link GoalType}</li>
      *  <li>{@link ObjectiveFunctionGradient}</li>
      * </ul>
      * @return {@inheritDoc}
@@ -74,8 +70,6 @@ public abstract class GradientMultivaria
     @Override
     public PointValuePair optimize(OptimizationData... optData)
         throws TooManyEvaluationsException {
-         // Retrieve settings.
-        parseOptimizationData(optData);
         // Set up base class and perform computation.
         return super.optimize(optData);
     }
@@ -90,7 +84,11 @@ public abstract class GradientMultivaria
      *  <li>{@link ObjectiveFunctionGradient}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/MultivariateOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/MultivariateOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/MultivariateOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/MultivariateOptimizer.java Thu Feb  7 12:41:36 2013
@@ -46,11 +46,10 @@ public abstract class MultivariateOptimi
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data. The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link BaseMultivariateOptimizer#parseOptimizationData(OptimizationData[])
+     * BaseMultivariateOptimizer}, this method will register the following data:
      * <ul>
-     *  <li>{@link org.apache.commons.math3.optim.MaxEval}</li>
-     *  <li>{@link org.apache.commons.math3.optim.InitialGuess}</li>
-     *  <li>{@link org.apache.commons.math3.optim.SimpleBounds}</li>
      *  <li>{@link ObjectiveFunction}</li>
      *  <li>{@link GoalType}</li>
      * </ul>
@@ -61,8 +60,6 @@ public abstract class MultivariateOptimi
     @Override
     public PointValuePair optimize(OptimizationData... optData)
         throws TooManyEvaluationsException {
-         // Retrieve settings.
-        parseOptimizationData(optData);
         // Set up base class and perform computation.
         return super.optimize(optData);
     }
@@ -78,7 +75,11 @@ public abstract class MultivariateOptimi
      *  <li>{@link GoalType}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {
@@ -86,7 +87,7 @@ public abstract class MultivariateOptimi
                 goal = (GoalType) data;
                 continue;
             }
-            if  (data instanceof ObjectiveFunction) {
+            if (data instanceof ObjectiveFunction) {
                 function = ((ObjectiveFunction) data).getObjectiveFunction();
                 continue;
             }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizer.java Thu Feb  7 12:41:36 2013
@@ -23,21 +23,25 @@ import org.apache.commons.math3.analysis
 import org.apache.commons.math3.exception.MathInternalError;
 import org.apache.commons.math3.exception.MathIllegalStateException;
 import org.apache.commons.math3.exception.TooManyEvaluationsException;
+import org.apache.commons.math3.exception.MathUnsupportedOperationException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.optim.OptimizationData;
-import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.PointValuePair;
 import org.apache.commons.math3.optim.ConvergenceChecker;
+import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.nonlinear.scalar.GradientMultivariateOptimizer;
 import org.apache.commons.math3.util.FastMath;
 
 /**
  * Non-linear conjugate gradient optimizer.
- * <p>
+ * <br/>
  * This class supports both the Fletcher-Reeves and the Polak-Ribière
  * update formulas for the conjugate search directions.
  * It also supports optional preconditioning.
- * </p>
+ * <br/>
+ * Constraints are not supported: the call to
+ * {@link #optimize(OptimizationData[]) optimize} will throw
+ * {@link MathUnsupportedOperationException} if bounds are passed to it.
  *
  * @version $Id$
  * @since 2.0
@@ -166,15 +170,10 @@ public class NonLinearConjugateGradientO
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data.
-     * The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link GradientMultivariateOptimizer#parseOptimizationData(OptimizationData[])
+     * GradientMultivariateOptimizer}, this method will register the following data:
      * <ul>
-     *  <li>{@link org.apache.commons.math3.optim.MaxEval}</li>
-     *  <li>{@link org.apache.commons.math3.optim.InitialGuess}</li>
-     *  <li>{@link org.apache.commons.math3.optim.SimpleBounds}</li>
-     *  <li>{@link org.apache.commons.math3.optim.nonlinear.scalar.GoalType}</li>
-     *  <li>{@link org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction}</li>
-     *  <li>{@link org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunctionGradient}</li>
      *  <li>{@link BracketingStep}</li>
      * </ul>
      * @return {@inheritDoc}
@@ -184,8 +183,6 @@ public class NonLinearConjugateGradientO
     @Override
     public PointValuePair optimize(OptimizationData... optData)
         throws TooManyEvaluationsException {
-         // Retrieve settings.
-        parseOptimizationData(optData);
         // Set up base class and perform computation.
         return super.optimize(optData);
     }
@@ -300,7 +297,11 @@ public class NonLinearConjugateGradientO
      *  <li>{@link InitialStep}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {
@@ -311,6 +312,8 @@ public class NonLinearConjugateGradientO
                 break;
             }
         }
+
+        checkParameters();
     }
 
     /**
@@ -390,4 +393,15 @@ public class NonLinearConjugateGradientO
             return dotProduct;
         }
     }
+
+    /**
+     * @throws MathUnsupportedOperationException if bounds were passed to the
+     * {@link #optimize(OptimizationData[]) optimize} method.
+     */
+    private void checkParameters() {
+        if (getLowerBound() != null ||
+            getUpperBound() != null) {
+            throw new MathUnsupportedOperationException(LocalizedFormats.CONSTRAINT);
+        }
+    }
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java Thu Feb  7 12:41:36 2013
@@ -342,12 +342,10 @@ public class CMAESOptimizer
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data. The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link MultivariateOptimizer#parseOptimizationData(OptimizationData[])
+     * MultivariateOptimizer}, this method will register the following data:
      * <ul>
-     *  <li>{@link org.apache.commons.math3.optim.MaxEval}</li>
-     *  <li>{@link org.apache.commons.math3.optim.InitialGuess}</li>
-     *  <li>{@link org.apache.commons.math3.optim.SimpleBounds}</li>
-     *  <li>{@link org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction}</li>
      *  <li>{@link Sigma}</li>
      *  <li>{@link PopulationSize}</li>
      * </ul>
@@ -361,8 +359,6 @@ public class CMAESOptimizer
     public PointValuePair optimize(OptimizationData... optData)
         throws TooManyEvaluationsException,
                DimensionMismatchException {
-        // Retrieve settings.
-        parseOptimizationData(optData);
         // Set up base class and perform computation.
         return super.optimize(optData);
     }
@@ -370,7 +366,6 @@ public class CMAESOptimizer
     /** {@inheritDoc} */
     @Override
     protected PointValuePair doOptimize() {
-        checkParameters();
          // -------------------- Initialization --------------------------------
         isMinimize = getGoalType().equals(GoalType.MINIMIZE);
         final FitnessFunction fitfun = new FitnessFunction();
@@ -528,7 +523,11 @@ public class CMAESOptimizer
      *  <li>{@link PopulationSize}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {
@@ -541,6 +540,8 @@ public class CMAESOptimizer
                 continue;
             }
         }
+
+        checkParameters();
     }
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizer.java Thu Feb  7 12:41:36 2013
@@ -21,8 +21,10 @@ import org.apache.commons.math3.util.Mat
 import org.apache.commons.math3.analysis.UnivariateFunction;
 import org.apache.commons.math3.exception.NumberIsTooSmallException;
 import org.apache.commons.math3.exception.NotStrictlyPositiveException;
-import org.apache.commons.math3.optim.MaxEval;
+import org.apache.commons.math3.exception.MathUnsupportedOperationException;
+import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
+import org.apache.commons.math3.optim.MaxEval;
 import org.apache.commons.math3.optim.PointValuePair;
 import org.apache.commons.math3.optim.ConvergenceChecker;
 import org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer;
@@ -34,7 +36,7 @@ import org.apache.commons.math3.optim.un
 import org.apache.commons.math3.optim.univariate.UnivariateObjectiveFunction;
 
 /**
- * Powell algorithm.
+ * Powell's algorithm.
  * This code is translated and adapted from the Python version of this
  * algorithm (as implemented in module {@code optimize.py} v0.5 of
  * <em>SciPy</em>).
@@ -46,6 +48,16 @@ import org.apache.commons.math3.optim.un
  * <br/>
  * The internal line search optimizer is a {@link BrentOptimizer} with a
  * convergence checker set to {@link SimpleUnivariateValueChecker}.
+ * <br/>
+ * Constraints are not supported: the call to
+ * {@link #optimize(OptimizationData[]) optimize} will throw
+ * {@link MathUnsupportedOperationException} if bounds are passed to it.
+ * In order to impose simple constraints, the objective function must be
+ * wrapped in an adapter like
+ * {@link org.apache.commons.math3.optim.nonlinear.scalar.MultivariateFunctionMappingAdapter
+ * MultivariateFunctionMappingAdapter} or
+ * {@link org.apache.commons.math3.optim.nonlinear.scalar.MultivariateFunctionPenaltyAdapter
+ * MultivariateFunctionPenaltyAdapter}.
  *
  * @version $Id$
  * @since 2.2
@@ -159,6 +171,8 @@ public class PowellOptimizer
     /** {@inheritDoc} */
     @Override
     protected PointValuePair doOptimize() {
+        checkParameters();
+
         final GoalType goal = getGoalType();
         final double[] guess = getStartPoint();
         final int n = guess.length;
@@ -353,4 +367,15 @@ public class PowellOptimizer
                                                bracket.getMid()));
         }
     }
+
+    /**
+     * @throws MathUnsupportedOperationException if bounds were passed to the
+     * {@link #optimize(OptimizationData[]) optimize} method.
+     */
+    private void checkParameters() {
+        if (getLowerBound() != null ||
+            getUpperBound() != null) {
+            throw new MathUnsupportedOperationException(LocalizedFormats.CONSTRAINT);
+        }
+    }
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java Thu Feb  7 12:41:36 2013
@@ -19,6 +19,8 @@ package org.apache.commons.math3.optim.n
 import java.util.Comparator;
 import org.apache.commons.math3.analysis.MultivariateFunction;
 import org.apache.commons.math3.exception.NullArgumentException;
+import org.apache.commons.math3.exception.MathUnsupportedOperationException;
+import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.ConvergenceChecker;
 import org.apache.commons.math3.optim.PointValuePair;
@@ -76,6 +78,9 @@ import org.apache.commons.math3.optim.no
  *  MultivariateFunctionMappingAdapter} or
  *  {@link org.apache.commons.math3.optim.nonlinear.scalar.MultivariateFunctionPenaltyAdapter
  *  MultivariateFunctionPenaltyAdapter}.
+ *  <br/>
+ *  The call to {@link #optimize(OptimizationData[]) optimize} will throw
+ *  {@link MathUnsupportedOperationException} if bounds are passed to it.
  * </p>
  *
  * @version $Id$
@@ -103,20 +108,16 @@ public class SimplexOptimizer extends Mu
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data.
-     * The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link MultivariateOptimizer#parseOptimizationData(OptimizationData[])
+     * MultivariateOptimizer}, this method will register the following data:
      * <ul>
-     *  <li>{@link org.apache.commons.math3.optim.MaxEval}</li>
-     *  <li>{@link org.apache.commons.math3.optim.InitialGuess}</li>
-     *  <li>{@link org.apache.commons.math3.optim.SimpleBounds}</li>
      *  <li>{@link AbstractSimplex}</li>
      * </ul>
      * @return {@inheritDoc}
      */
     @Override
     public PointValuePair optimize(OptimizationData... optData) {
-        // Retrieve settings
-        parseOptimizationData(optData);
         // Set up base class and perform computation.
         return super.optimize(optData);
     }
@@ -124,9 +125,7 @@ public class SimplexOptimizer extends Mu
     /** {@inheritDoc} */
     @Override
     protected PointValuePair doOptimize() {
-        if (simplex == null) {
-            throw new NullArgumentException();
-        }
+        checkParameters();
 
         // Indirect call to "computeObjectiveValue" in order to update the
         // evaluations counter.
@@ -186,7 +185,11 @@ public class SimplexOptimizer extends Mu
      *  <li>{@link AbstractSimplex}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {
@@ -198,4 +201,20 @@ public class SimplexOptimizer extends Mu
             }
         }
     }
+
+    /**
+     * @throws MathUnsupportedOperationException if bounds were passed to the
+     * {@link #optimize(OptimizationData[]) optimize} method.
+     * @throws NullArgumentException if no initial simplex was passed to the
+     * {@link #optimize(OptimizationData[]) optimize} method.
+     */
+    private void checkParameters() {
+        if (simplex == null) {
+            throw new NullArgumentException();
+        }
+        if (getLowerBound() != null ||
+            getUpperBound() != null) {
+            throw new MathUnsupportedOperationException(LocalizedFormats.CONSTRAINT);
+        }
+    }
 }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/JacobianMultivariateVectorOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/JacobianMultivariateVectorOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/JacobianMultivariateVectorOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/JacobianMultivariateVectorOptimizer.java Thu Feb  7 12:41:36 2013
@@ -63,14 +63,10 @@ public abstract class JacobianMultivaria
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data. The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link MultivariateOptimizer#parseOptimizationData(OptimizationData[])
+     * MultivariateOptimizer}, this method will register the following data:
      * <ul>
-     *  <li>{@link org.apache.commons.math3.optim.MaxEval}</li>
-     *  <li>{@link org.apache.commons.math3.optim.InitialGuess}</li>
-     *  <li>{@link org.apache.commons.math3.optim.SimpleBounds}</li>
-     *  <li>{@link Target}</li>
-     *  <li>{@link Weight}</li>
-     *  <li>{@link ModelFunction}</li>
      *  <li>{@link ModelFunctionJacobian}</li>
      * </ul>
      * @return {@inheritDoc}
@@ -83,8 +79,6 @@ public abstract class JacobianMultivaria
     public PointVectorValuePair optimize(OptimizationData... optData)
         throws TooManyEvaluationsException,
                DimensionMismatchException {
-        // Retrieve settings.
-        parseOptimizationData(optData);
         // Set up base class and perform computation.
         return super.optimize(optData);
     }
@@ -99,7 +93,11 @@ public abstract class JacobianMultivaria
      *  <li>{@link ModelFunctionJacobian}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/MultivariateVectorOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/MultivariateVectorOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/MultivariateVectorOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/MultivariateVectorOptimizer.java Thu Feb  7 12:41:36 2013
@@ -66,11 +66,10 @@ public abstract class MultivariateVector
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data. The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link BaseMultivariateOptimizer#parseOptimizationData(OptimizationData[])
+     * BaseMultivariateOptimizer}, this method will register the following data:
      * <ul>
-     *  <li>{@link org.apache.commons.math3.optim.MaxEval}</li>
-     *  <li>{@link org.apache.commons.math3.optim.InitialGuess}</li>
-     *  <li>{@link org.apache.commons.math3.optim.SimpleBounds}</li>
      *  <li>{@link Target}</li>
      *  <li>{@link Weight}</li>
      *  <li>{@link ModelFunction}</li>
@@ -84,10 +83,6 @@ public abstract class MultivariateVector
     public PointVectorValuePair optimize(OptimizationData... optData)
         throws TooManyEvaluationsException,
                DimensionMismatchException {
-        // Retrieve settings.
-        parseOptimizationData(optData);
-        // Check input consistency.
-        checkParameters();
         // Set up base class and perform computation.
         return super.optimize(optData);
     }
@@ -130,7 +125,11 @@ public abstract class MultivariateVector
      *  <li>{@link ModelFunction}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {
@@ -147,6 +146,9 @@ public abstract class MultivariateVector
                 continue;
             }
         }
+
+        // Check input consistency.
+        checkParameters();
     }
 
     /**

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/AbstractLeastSquaresOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/AbstractLeastSquaresOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/AbstractLeastSquaresOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/AbstractLeastSquaresOptimizer.java Thu Feb  7 12:41:36 2013
@@ -178,15 +178,11 @@ public abstract class AbstractLeastSquar
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data. The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link JacobianMultivariateVectorOptimizer#parseOptimizationData(OptimizationData[])
+     * JacobianMultivariateVectorOptimizer}, this method will register the following data:
      * <ul>
-     *  <li>{@link org.apache.commons.math3.optim.MaxEval}</li>
-     *  <li>{@link org.apache.commons.math3.optim.InitialGuess}</li>
-     *  <li>{@link org.apache.commons.math3.optim.SimpleBounds}</li>
-     *  <li>{@link org.apache.commons.math3.optim.nonlinear.vector.Target}</li>
      *  <li>{@link org.apache.commons.math3.optim.nonlinear.vector.Weight}</li>
-     *  <li>{@link org.apache.commons.math3.optim.nonlinear.vector.ModelFunction}</li>
-     *  <li>{@link org.apache.commons.math3.optim.nonlinear.vector.ModelFunctionJacobian}</li>
      * </ul>
      * @return {@inheritDoc}
      * @throws TooManyEvaluationsException if the maximal number of
@@ -197,8 +193,6 @@ public abstract class AbstractLeastSquar
     @Override
     public PointVectorValuePair optimize(OptimizationData... optData)
         throws TooManyEvaluationsException {
-        // Retrieve settings.
-        parseOptimizationData(optData);
         // Set up base class and perform computation.
         return super.optimize(optData);
     }
@@ -244,7 +238,11 @@ public abstract class AbstractLeastSquar
      *  <li>{@link Weight}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/UnivariateOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/UnivariateOptimizer.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/UnivariateOptimizer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/optim/univariate/UnivariateOptimizer.java Thu Feb  7 12:41:36 2013
@@ -52,8 +52,9 @@ public abstract class UnivariateOptimize
     /**
      * {@inheritDoc}
      *
-     * @param optData Optimization data.
-     * The following data will be looked for:
+     * @param optData Optimization data. In addition to those documented in
+     * {@link BaseOptimizer#parseOptimizationData(OptimizationData[])
+     * BaseOptimizer}, this method will register the following data:
      * <ul>
      *  <li>{@link GoalType}</li>
      *  <li>{@link SearchInterval}</li>
@@ -65,8 +66,6 @@ public abstract class UnivariateOptimize
      */
     public UnivariatePointValuePair optimize(OptimizationData... optData)
         throws TooManyEvaluationsException {
-        // Retrieve settings.
-        parseOptimizationData(optData);
         // Perform computation.
         return super.optimize(optData);
     }
@@ -90,7 +89,11 @@ public abstract class UnivariateOptimize
      *  <li>{@link UnivariateObjectiveFunction}</li>
      * </ul>
      */
-    private void parseOptimizationData(OptimizationData... optData) {
+    @Override
+    protected void parseOptimizationData(OptimizationData... optData) {
+        // Allow base class to register its own data.
+        super.parseOptimizationData(optData);
+
         // The existing values (as set by the previous call) are reused if
         // not provided in the argument list.
         for (OptimizationData data : optData) {

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizerTest.java Thu Feb  7 12:41:36 2013
@@ -27,15 +27,17 @@ import org.apache.commons.math3.analysis
 import org.apache.commons.math3.analysis.solvers.BrentSolver;
 import org.apache.commons.math3.exception.DimensionMismatchException;
 import org.apache.commons.math3.exception.MathIllegalArgumentException;
+import org.apache.commons.math3.exception.MathUnsupportedOperationException;
 import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
 import org.apache.commons.math3.linear.BlockRealMatrix;
 import org.apache.commons.math3.linear.RealMatrix;
-import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.PointValuePair;
 import org.apache.commons.math3.optim.SimpleValueChecker;
 import org.apache.commons.math3.optim.InitialGuess;
 import org.apache.commons.math3.optim.MaxEval;
+import org.apache.commons.math3.optim.SimpleBounds;
 import org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction;
+import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunctionGradient;
 import org.junit.Assert;
 import org.junit.Test;
@@ -103,6 +105,22 @@ import org.junit.Test;
  * @author Luc Maisonobe (non-minpack tests and minpack tests Java translation)
  */
 public class NonLinearConjugateGradientOptimizerTest {
+    @Test(expected=MathUnsupportedOperationException.class)
+    public void testBoundsUnsupported() {
+        LinearProblem problem
+            = new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
+        NonLinearConjugateGradientOptimizer optimizer
+            = new NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
+                                                      new SimpleValueChecker(1e-6, 1e-6));
+        optimizer.optimize(new MaxEval(100),
+                           problem.getObjectiveFunction(),
+                           problem.getObjectiveFunctionGradient(),
+                           GoalType.MINIMIZE,
+                           new InitialGuess(new double[] { 0 }),
+                           new SimpleBounds(new double[] { -1 },
+                                            new double[] { 1 }));
+    }
+
     @Test
     public void testTrivial() {
         LinearProblem problem

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizerTest.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizerTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizerTest.java Thu Feb  7 12:41:36 2013
@@ -18,11 +18,13 @@ package org.apache.commons.math3.optim.n
 
 import org.apache.commons.math3.analysis.MultivariateFunction;
 import org.apache.commons.math3.analysis.SumSincFunction;
-import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.PointValuePair;
 import org.apache.commons.math3.optim.InitialGuess;
 import org.apache.commons.math3.optim.MaxEval;
+import org.apache.commons.math3.optim.SimpleBounds;
+import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction;
+import org.apache.commons.math3.exception.MathUnsupportedOperationException;
 import org.apache.commons.math3.util.FastMath;
 import org.junit.Assert;
 import org.junit.Test;
@@ -31,6 +33,19 @@ import org.junit.Test;
  * Test for {@link PowellOptimizer}.
  */
 public class PowellOptimizerTest {
+    @Test(expected=MathUnsupportedOperationException.class)
+    public void testBoundsUnsupported() {
+        final MultivariateFunction func = new SumSincFunction(-1);
+        final PowellOptimizer optim = new PowellOptimizer(1e-8, 1e-5,
+                                                          1e-4, 1e-4);
+
+        optim.optimize(new MaxEval(100),
+                       new ObjectiveFunction(func),
+                       GoalType.MINIMIZE,
+                       new InitialGuess(new double[] { -3, 0 }),
+                       new SimpleBounds(new double[] { -5, -1 },
+                                        new double[] { 5, 1 }));
+    }
 
     @Test
     public void testSumSinc() {

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerMultiDirectionalTest.java Thu Feb  7 12:41:36 2013
@@ -19,16 +19,32 @@ package org.apache.commons.math3.optim.n
 
 import org.apache.commons.math3.analysis.MultivariateFunction;
 import org.apache.commons.math3.optim.MaxEval;
-import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.InitialGuess;
 import org.apache.commons.math3.optim.PointValuePair;
 import org.apache.commons.math3.optim.SimpleValueChecker;
+import org.apache.commons.math3.optim.SimpleBounds;
+import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction;
+import org.apache.commons.math3.exception.MathUnsupportedOperationException;
 import org.apache.commons.math3.util.FastMath;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class SimplexOptimizerMultiDirectionalTest {
+    @Test(expected=MathUnsupportedOperationException.class)
+    public void testBoundsUnsupported() {
+        SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30);
+        final FourExtrema fourExtrema = new FourExtrema();
+
+        optimizer.optimize(new MaxEval(100),
+                           new ObjectiveFunction(fourExtrema),
+                           GoalType.MINIMIZE,
+                           new InitialGuess(new double[] { -3, 0 }),
+                           new NelderMeadSimplex(new double[] { 0.2, 0.2 }),
+                           new SimpleBounds(new double[] { -5, -1 },
+                                            new double[] { 5, 1 }));
+    }
+
     @Test
     public void testMinimize1() {
         SimplexOptimizer optimizer = new SimplexOptimizer(1e-11, 1e-30);

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java?rev=1443444&r1=1443443&r2=1443444&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizerNelderMeadTest.java Thu Feb  7 12:41:36 2013
@@ -19,21 +19,37 @@ package org.apache.commons.math3.optim.n
 
 
 import org.apache.commons.math3.exception.TooManyEvaluationsException;
+import org.apache.commons.math3.exception.MathUnsupportedOperationException;
 import org.apache.commons.math3.analysis.MultivariateFunction;
 import org.apache.commons.math3.analysis.MultivariateVectorFunction;
 import org.apache.commons.math3.linear.Array2DRowRealMatrix;
 import org.apache.commons.math3.linear.RealMatrix;
-import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
 import org.apache.commons.math3.optim.InitialGuess;
 import org.apache.commons.math3.optim.MaxEval;
-import org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction;
+import org.apache.commons.math3.optim.SimpleBounds;
 import org.apache.commons.math3.optim.PointValuePair;
+import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
+import org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction;
 import org.apache.commons.math3.optim.nonlinear.scalar.LeastSquaresConverter;
 import org.apache.commons.math3.util.FastMath;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class SimplexOptimizerNelderMeadTest {
+    @Test(expected=MathUnsupportedOperationException.class)
+    public void testBoundsUnsupported() {
+        SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30);
+        final FourExtrema fourExtrema = new FourExtrema();
+
+        optimizer.optimize(new MaxEval(100),
+                           new ObjectiveFunction(fourExtrema),
+                           GoalType.MINIMIZE,
+                           new InitialGuess(new double[] { -3, 0 }),
+                           new NelderMeadSimplex(new double[] { 0.2, 0.2 }),
+                           new SimpleBounds(new double[] { -5, -1 },
+                                            new double[] { 5, 1 }));
+    }
+
     @Test
     public void testMinimize1() {
         SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30);



Mime
View raw message