commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1194874 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization: BaseMultivariateRealOptimizer.java direct/BaseAbstractScalarOptimizer.java
Date Sat, 29 Oct 2011 11:19:31 GMT
Author: erans
Date: Sat Oct 29 11:19:30 2011
New Revision: 1194874

URL: http://svn.apache.org/viewvc?rev=1194874&view=rev
Log:
MATH-697
Fixed bug in check that the initial value is within 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=1194874&r1=1194873&r2=1194874&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
Sat Oct 29 11:19:30 2011
@@ -73,8 +73,10 @@ 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.
+     * @throws org.apache.commons.math.exception.NumberIsTooSmallException if any
+     * of the initial values is less than its lower bound.
+     * @throws org.apache.commons.math.exception.NumberIsTooLargeException if any
+     * of the initial values is greater than its upper bound.
      */
     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=1194874&r1=1194873&r2=1194874&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
Sat Oct 29 11:19:30 2011
@@ -22,7 +22,8 @@ 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.exception.NumberIsTooSmallException;
+import org.apache.commons.math.exception.NumberIsTooLargeException;
 import org.apache.commons.math.analysis.MultivariateRealFunction;
 import org.apache.commons.math.optimization.BaseMultivariateRealOptimizer;
 import org.apache.commons.math.optimization.GoalType;
@@ -125,21 +126,28 @@ public abstract class BaseAbstractScalar
             throw new NullArgumentException();
         }
         final int dim = startPoint.length;
-        if (lower != null &&
-            lower.length != dim) {
-            throw new DimensionMismatchException(lower.length, dim);
-        }
-        if (upper != null &&
-            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);
+        if (lower != null) {
+            if (lower.length != dim) {
+                throw new DimensionMismatchException(lower.length, dim);
+            }
+            for (int i = 0; i < dim; i++) {
+                final double v = startPoint[i];
+                final double lo = lower[i];
+                if (v < lo) {
+                    throw new NumberIsTooSmallException(v, lo, true);
+                }
+            }
+        }
+        if (upper != null) {
+            if (upper.length != dim) {
+                throw new DimensionMismatchException(upper.length, dim);
+            }
+            for (int i = 0; i < dim; i++) {
+                final double v = startPoint[i];
+                final double hi = upper[i];
+                if (v > hi) {
+                    throw new NumberIsTooLargeException(v, hi, true);
+                }
             }
         }
 



Mime
View raw message