This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-math.git


The following commit(s) were added to refs/heads/master by this push:
     new 4108f5f  MATH-1549: Added unit test based on the demo code provided on 
the report page.
4108f5f is described below

commit 4108f5f35e22db3401a11fbbf93f85be21394f5c
Author: Gilles Sadowski <[email protected]>
AuthorDate: Tue Jul 14 14:41:42 2020 +0200

    MATH-1549: Added unit test based on the demo code provided on the report 
page.
    
    Unit test is set to "@Ignore" as the issue is still present.
---
 .../math4/optim/linear/SimplexSolverTest.java      | 47 ++++++++++++++++++++--
 1 file changed, 44 insertions(+), 3 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java 
b/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java
index ecac904..7e46583 100644
--- a/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java
+++ b/src/test/java/org/apache/commons/math4/optim/linear/SimplexSolverTest.java
@@ -19,7 +19,11 @@ package org.apache.commons.math4.optim.linear;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.Assert;
 
+import org.apache.commons.numbers.core.Precision;
 import org.apache.commons.math4.exception.DimensionMismatchException;
 import org.apache.commons.math4.exception.TooManyIterationsException;
 import org.apache.commons.math4.optim.MaxIter;
@@ -35,9 +39,6 @@ import org.apache.commons.math4.optim.linear.SimplexSolver;
 import org.apache.commons.math4.optim.linear.SolutionCallback;
 import org.apache.commons.math4.optim.linear.UnboundedSolutionException;
 import org.apache.commons.math4.optim.nonlinear.scalar.GoalType;
-import org.apache.commons.numbers.core.Precision;
-import org.junit.Test;
-import org.junit.Assert;
 
 public class SimplexSolverTest {
     private static final MaxIter DEFAULT_MAX_ITER = new MaxIter(100);
@@ -819,6 +820,46 @@ public class SimplexSolverTest {
                         PivotSelectionRule.BLAND);
     }
 
+    /* XXX Skipped until issue is solved: 
https://issues.apache.org/jira/browse/MATH-1549 */
+    @Ignore@Test
+    public void testMath1549() {
+        final double m = 10;
+        double scale = 1;
+        int numFailures = 0;
+        for (int pow = 0; pow < 13; pow++) {
+            try {
+                tryMath1549(scale);
+            } catch (RuntimeException e) {
+                e.printStackTrace();
+                ++numFailures;
+            }
+            scale *= m;
+        }
+
+        if (numFailures > 0) {
+            Assert.fail(numFailures + " failures");
+        }
+    }
+
+    /* See JIRA issue: MATH-1549 */
+    private void tryMath1549(double scale) {
+        final NonNegativeConstraint nnegconstr = new 
NonNegativeConstraint(true);
+        final int ulps = 10;
+        final double cutoff = 1e-10;
+        final double eps = 1e-6;
+        final SimplexSolver solver = new SimplexSolver(eps, ulps, cutoff);
+
+        final LinearObjectiveFunction f = new LinearObjectiveFunction(new 
double[] {1, 1}, 0);
+        final List<LinearConstraint> constraints = new ArrayList<>();
+        constraints.add(new LinearConstraint(new double[] {scale * 9000, scale 
* 1}, Relationship.GEQ, 0));
+        constraints.add(new LinearConstraint(new double[] {scale * 10000, 
scale}, Relationship.GEQ, scale * 2000));
+        constraints.add(new LinearConstraint(new double[] {scale, 0}, 
Relationship.GEQ, scale * 2));
+        final LinearConstraintSet constraintSet = new 
LinearConstraintSet(constraints);
+        final PointValuePair solution = solver.optimize(f, constraintSet, 
GoalType.MINIMIZE, nnegconstr);
+
+        System.out.println("scale=" + scale + ": sol=" + 
java.util.Arrays.toString(solution.getPoint()));
+    }
+
     /**
      * Converts a test string to a {@link LinearConstraint}.
      * Ex: x0 + x1 + x2 + x3 - x12 = 0

Reply via email to