You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "David Kopp (JIRA)" <ji...@apache.org> on 2015/06/09 17:14:00 UTC
[jira] [Commented] (MATH-1230) SimplexSolver returning wrong answer
from optimize
[ https://issues.apache.org/jira/browse/MATH-1230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14579055#comment-14579055 ]
David Kopp commented on MATH-1230:
----------------------------------
This test case should be added to SimplexSolverTest.java
@Test
public void testMath1230() {
// min 2x1 +15x2 +18x3
// Subject to
// -x1 +2x2 -6x3 <=-10
// x2 +2x3 <= 6
// 2x1 +10x3 <= 19
// -x1 +x2 <= -2
// x1,x2,x3 >= 0
LinearObjectiveFunction f =
new LinearObjectiveFunction(new double[] { 2, 15, 18 }, 0);
Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
constraints.add(new LinearConstraint(new double[] { -1, 2 -6 }, Relationship.LEQ, -10));
constraints.add(new LinearConstraint(new double[] { 0, 1, 2 }, Relationship.LEQ, 6));
constraints.add(new LinearConstraint(new double[] { 2, 0, 10 }, Relationship.LEQ, 19));
constraints.add(new LinearConstraint(new double[] { -1, 1, 0 }, Relationship.LEQ, -2));
SimplexSolver solver = new SimplexSolver();
PointValuePair solution = solver.optimize(f,
new LinearConstraintSet(constraints),
new NonNegativeConstraint(true),
PivotSelectionRule.BLAND);
Assert.assertEquals(7, solution.getPoint()[0], 0d);
Assert.assertEquals(0, solution.getPoint()[1], 0d);
Assert.assertEquals(0.5, solution.getPoint()[2], 0d);
Assert.assertEquals(23, solution.getValue(), 0d);
}
> SimplexSolver returning wrong answer from optimize
> --------------------------------------------------
>
> Key: MATH-1230
> URL: https://issues.apache.org/jira/browse/MATH-1230
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.5
> Reporter: David Kopp
>
> SimplexSolver fails for the following linear program:
> min 2x1 +15x2 +18x3
> Subject to
> -x1 +2x2 -6x3 <=-10
> x2 +2x3 <= 6
> 2x1 +10x3 <= 19
> -x1 +x2 <= -2
> x1,x2,x3 >= 0
> Solution should be
> x1 = 7
> x2 = 0
> x3 = 1/2
> Objective function = 23
> Instead, it is returning
> x1 = 9.5
> x2 = 1/8
> x3 = 0
> Objective function = 20.875
> Constraint number 1 is violated by this answer
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)