You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2015/06/11 14:10:39 UTC

[1/2] [math] Fixed error message for unknown parameter name in ODE.

Repository: commons-math
Updated Branches:
  refs/heads/master a55ae8544 -> 2990f6caa


Fixed error message for unknown parameter name in ODE.

JIRA: MATH-1232

Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/8f35fcb8
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/8f35fcb8
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/8f35fcb8

Branch: refs/heads/master
Commit: 8f35fcb8f7b17c7201a31f157e7d77bf3e6fe2b5
Parents: 12ec160
Author: Luc Maisonobe <lu...@apache.org>
Authored: Thu Jun 11 13:50:04 2015 +0200
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Thu Jun 11 13:50:04 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |  3 +++
 .../math4/ode/UnknownParameterException.java    |  2 +-
 .../commons/math4/ode/JacobianMatricesTest.java | 25 +++++++++++++++-----
 3 files changed, 23 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/8f35fcb8/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 228a7f3..4094a48 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,9 @@ If the output is not quite correct, check for invisible trailing spaces!
     </release>
 
     <release version="4.0" date="XXXX-XX-XX" description="">
+      <action dev="luc" type="fix" issue="MATH-1232"> <!-- backported to 3.6 -->
+        Fixed error message for unknown parameter name in ODE.
+      </action>
       <action dev="luc" type="fix" issue="MATH-1226"> <!-- backported to 3.6 -->
         Fixed wrong event detection in case of close events pairs.
       </action>

http://git-wip-us.apache.org/repos/asf/commons-math/blob/8f35fcb8/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java b/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java
index 75c6210..bbbaa4a 100644
--- a/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java
+++ b/src/main/java/org/apache/commons/math4/ode/UnknownParameterException.java
@@ -38,7 +38,7 @@ public class UnknownParameterException extends MathIllegalArgumentException {
      * @param name parameter name.
      */
     public UnknownParameterException(final String name) {
-        super(LocalizedFormats.UNKNOWN_PARAMETER);
+        super(LocalizedFormats.UNKNOWN_PARAMETER, name);
         this.name = name;
     }
 

http://git-wip-us.apache.org/repos/asf/commons-math/blob/8f35fcb8/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java b/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java
index b50fe7a..b4e20ed 100644
--- a/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java
+++ b/src/test/java/org/apache/commons/math4/ode/JacobianMatricesTest.java
@@ -103,19 +103,32 @@ public class JacobianMatricesTest {
     }
 
     @Test
+    public void testWrongParameterName() {
+        final String name = "an-unknown-parameter";
+        try {
+            ParamBrusselator brusselator = new ParamBrusselator(2.9);
+            brusselator.setParameter(name, 3.0);
+            Assert.fail("an exception should have been thrown");
+        } catch (UnknownParameterException upe) {
+            Assert.assertTrue(upe.getMessage().contains(name));
+            Assert.assertEquals(name, upe.getName());
+        }
+    }
+
+    @Test
     public void testInternalDifferentiation()
-        throws NumberIsTooSmallException, DimensionMismatchException,
-               MaxCountExceededException, NoBracketingException,
-               UnknownParameterException, MismatchedEquations {
+                    throws NumberIsTooSmallException, DimensionMismatchException,
+                    MaxCountExceededException, NoBracketingException,
+                    UnknownParameterException, MismatchedEquations {
         AbstractIntegrator integ =
-            new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-4, 1.0e-4 }, new double[] { 1.0e-4, 1.0e-4 });
+                        new DormandPrince54Integrator(1.0e-8, 100.0, new double[] { 1.0e-4, 1.0e-4 }, new double[] { 1.0e-4, 1.0e-4 });
         double hP = 1.0e-12;
         double hY = 1.0e-12;
         SummaryStatistics residualsP0 = new SummaryStatistics();
         SummaryStatistics residualsP1 = new SummaryStatistics();
         for (double b = 2.88; b < 3.08; b += 0.001) {
-            ParamBrusselator brusselator = new ParamBrusselator(b);
-            brusselator.setParameter(ParamBrusselator.B, b);
+                ParamBrusselator brusselator = new ParamBrusselator(b);
+                brusselator.setParameter(ParamBrusselator.B, b);
             double[] z = { 1.3, b };
             double[][] dZdZ0 = new double[2][2];
             double[]   dZdP  = new double[2];


[2/2] [math] Merge branch 'master' of https://luc@git-wip-us.apache.org/repos/asf/commons-math.git

Posted by lu...@apache.org.
Merge branch 'master' of
https://luc@git-wip-us.apache.org/repos/asf/commons-math.git

Conflicts:
	src/changes/changes.xml


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/2990f6ca
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/2990f6ca
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/2990f6ca

Branch: refs/heads/master
Commit: 2990f6caad0db0f7c7a2df22d65f1031ed9e33e1
Parents: 8f35fcb a55ae85
Author: Luc Maisonobe <lu...@apache.org>
Authored: Thu Jun 11 14:09:52 2015 +0200
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Thu Jun 11 14:09:52 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml                         |  9 +--
 .../math4/optim/linear/SimplexSolver.java       |  2 +
 .../math4/optim/linear/SimplexTableau.java      | 25 +++++++-
 .../math4/optim/linear/SimplexSolverTest.java   | 66 ++++++++++++++------
 4 files changed, 77 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/2990f6ca/src/changes/changes.xml
----------------------------------------------------------------------
diff --cc src/changes/changes.xml
index 4094a48,132509b..2620bc7
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@@ -54,9 -54,11 +54,14 @@@ If the output is not quite correct, che
      </release>
  
      <release version="4.0" date="XXXX-XX-XX" description="">
 +      <action dev="luc" type="fix" issue="MATH-1232"> <!-- backported to 3.6 -->
 +        Fixed error message for unknown parameter name in ODE.
 +      </action>
+       <action dev="tn" type="fix" issue="MATH-1230">
+         The "SimplexSolver" will now throw a "DimensionMismatchException"
+         when calling "optimize(...)" with linear constraints whose dimension
+         does not match the dimension of the objective function.
+       </action>
        <action dev="luc" type="fix" issue="MATH-1226"> <!-- backported to 3.6 -->
          Fixed wrong event detection in case of close events pairs.
        </action>

http://git-wip-us.apache.org/repos/asf/commons-math/blob/2990f6ca/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java
----------------------------------------------------------------------
diff --cc src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java
index d4b4259,743fe9b..a835765
--- a/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java
+++ b/src/main/java/org/apache/commons/math4/optim/linear/SimplexSolver.java
@@@ -146,6 -147,8 +146,8 @@@ public class SimplexSolver extends Line
       *
       * @return {@inheritDoc}
       * @throws TooManyIterationsException if the maximal number of iterations is exceeded.
 -     * @throws DimensionMismatchException if the dimension of the constraints does not match the
 -     *   dimension of the objective function
++     * @throws org.apache.commons.math4.exception.DimensionMismatchException if the dimension
++     * of the constraints does not match the dimension of the objective function
       */
      @Override
      public PointValuePair optimize(OptimizationData... optData)

http://git-wip-us.apache.org/repos/asf/commons-math/blob/2990f6ca/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java
----------------------------------------------------------------------
diff --cc src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java
index e869a74,f0a842f..f11632b
--- a/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java
+++ b/src/main/java/org/apache/commons/math4/optim/linear/SimplexTableau.java
@@@ -154,6 -160,23 +160,23 @@@ class SimplexTableau implements Seriali
      }
  
      /**
+      * Checks that the dimensions of the objective function and the constraints match.
 -     * @param f the objective function
 -     * @param constraints the set of constraints
++     * @param objectiveFunction the objective function
++     * @param c the set of constraints
+      * @throws DimensionMismatchException if the constraint dimensions do not match with the
+      *   dimension of the objective function
+      */
 -    private void checkDimensions(final LinearObjectiveFunction f,
 -                                 final Collection<LinearConstraint> constraints) {
 -        final int dimension = f.getCoefficients().getDimension();
 -        for (final LinearConstraint constraint : constraints) {
++    private void checkDimensions(final LinearObjectiveFunction objectiveFunction,
++                                 final Collection<LinearConstraint> c) {
++        final int dimension = objectiveFunction.getCoefficients().getDimension();
++        for (final LinearConstraint constraint : c) {
+             final int constraintDimension = constraint.getCoefficients().getDimension();
+             if (constraintDimension != dimension) {
+                 throw new DimensionMismatchException(constraintDimension, dimension);
+             }
+         }
+     }
+     /**
       * Initialize the labels for the columns.
       */
      protected void initializeColumnLabels() {