From d8e1809529ef78737dbbe4080622330970866793 Mon Sep 17 00:00:00 2001 From: Gilles Sadowski Date: Sat, 29 Oct 2011 11:19:30 +0000 Subject: [PATCH] MATH-697 Fixed bug in check that the initial value is within bounds. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1194874 13f79535-47bb-0310-9956-ffa450edef68 --- .../BaseMultivariateRealOptimizer.java | 6 ++- .../direct/BaseAbstractScalarOptimizer.java | 38 +++++++++++-------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java b/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java index 61b2000d0..a09e7e9f4 100644 --- a/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java +++ b/src/main/java/org/apache/commons/math/optimization/BaseMultivariateRealOptimizer.java @@ -73,8 +73,10 @@ public interface BaseMultivariateRealOptimizer hi) { - throw new OutOfRangeException(v, lo, hi); + 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); + } } }