commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1190686 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization: BaseMultivariateRealOptimizer.java direct/BaseAbstractScalarOptimizer.java
Date Fri, 28 Oct 2011 23:54:33 GMT
Author: erans
Date: Fri Oct 28 23:54:32 2011
New Revision: 1190686

URL: http://svn.apache.org/viewvc?rev=1190686&view=rev
Log:
MATH-697
Check that the given starting point is within the bounds.

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

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java?rev=1190686&r1=1190685&r2=1190686&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java
Fri Oct 28 23:54:32 2011
@@ -73,6 +73,8 @@ public interface BaseMultivariateRealOpt
      * if the maximal number of evaluations is exceeded.
      * @throws org.apache.commons.math.exception.NullArgumentException if
      * {@code f}, {@code goalType} or {@code startPoint} is {@code null}.
+     * @throws org.apache.commons.math.exception.OutOfRangeException if any
+     * of the initial values is out of bounds.
      */
     RealPointValuePair optimize(int maxEval, FUNC f, GoalType goalType,
                                 double[] startPoint,

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/BaseAbstractScalarOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/BaseAbstractScalarOptimizer.java?rev=1190686&r1=1190685&r2=1190686&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/BaseAbstractScalarOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/direct/BaseAbstractScalarOptimizer.java
Fri Oct 28 23:54:32 2011
@@ -22,6 +22,7 @@ import org.apache.commons.math.exception
 import org.apache.commons.math.exception.TooManyEvaluationsException;
 import org.apache.commons.math.exception.NullArgumentException;
 import org.apache.commons.math.exception.DimensionMismatchException;
+import org.apache.commons.math.exception.OutOfRangeException;
 import org.apache.commons.math.analysis.MultivariateRealFunction;
 import org.apache.commons.math.optimization.BaseMultivariateRealOptimizer;
 import org.apache.commons.math.optimization.GoalType;
@@ -132,6 +133,15 @@ public abstract class BaseAbstractScalar
             upper.length != dim) {
             throw new DimensionMismatchException(upper.length, dim);
         }
+        for (int i = 0; i < dim; i++) {
+            final double v = startPoint[i];
+            final double lo = lower[i];
+            final double hi = upper[i];
+            if (v < lo ||
+                v > hi) {
+                throw new OutOfRangeException(v, lo, hi);
+            }
+        }
 
         // Reset.
         evaluations.setMaximalCount(maxEval);



Mime
View raw message