You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Andrea (JIRA)" <ji...@apache.org> on 2009/09/09 16:42:57 UTC

[jira] Issue Comment Edited: (MATH-286) SimplexSolver not working as expected?

    [ https://issues.apache.org/jira/browse/MATH-286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12753053#action_12753053 ] 

Andrea edited comment on MATH-286 at 9/9/09 7:41 AM:
-----------------------------------------------------

Hi Luc, hi Ben,
This time I can confirm Ben's patch fixes the original problem. :-)

If I find something else related to this bug (or not) I will let you know, but I'm pretty sure this time the SimplexSolver is much more robust it was a couple of weeks ago!

I "improved" the JUnit test case for this bug, I attach the patch to this message. There are 5 new assertions that check all the constraints are really satisfied.

Thanks again for all the commitment
Andrea

PS: I don't know if this is somehow related, but I found another bug MATH-293... Ben, please look at that as well.

      was (Author: ciaccia):
    Hi Luc, hi Ben,
This time I can confirm Ben's patch fixes the original problem. :-)

If I find something else related to this bug (or not) I will let you know, but I'm pretty sure this time the SimplexSolver is much more robust it was a couple of weeks ago!

I "improved" the JUnit test case for this bug, I attach the patch to this message. There are 5 new assertions that check all the constraints are really satisfied.

Thanks again for all the commitment
Andrea
  
> SimplexSolver not working as expected?
> --------------------------------------
>
>                 Key: MATH-286
>                 URL: https://issues.apache.org/jira/browse/MATH-286
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.0
>         Environment: Java 1.6.0_13 on  Windows XP 32-bit
>            Reporter: Andrea
>             Fix For: 2.1
>
>         Attachments: patch.zip, simplex.txt, SimplexSolver.patch, SimplexSolverTest-Andrea.patch, SimplexSolverTest.patch, SimplexSolverTest.patch, SimplexTableau.patch, SimplexTableau.patch
>
>
> I guess (but I could be wrong) that SimplexSolver does not always return the optimal solution, nor satisfies all the constraints...
> Consider this LP:
> max: 0.8 x0 + 0.2 x1 + 0.7 x2 + 0.3 x3 + 0.6 x4 + 0.4 x5;
> r1: x0 + x2 + x4 = 23.0;
> r2: x1 + x3 + x5 = 23.0;
> r3: x0 >= 10.0;
> r4: x2 >= 8.0;
> r5: x4 >= 5.0;
> LPSolve returns 25.8, with x0 = 10.0, x1 = 0.0, x2 = 8.0, x3 = 0.0, x4 = 5.0, x5 = 23.0;
> The same LP expressed in Apache commons math is:
> LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 0.8, 0.2, 0.7, 0.3, 0.6, 0.4 }, 0 );
> Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
> constraints.add(new LinearConstraint(new double[] { 1, 0, 1, 0, 1, 0 }, Relationship.EQ, 23.0));
> constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 1, 0, 1 }, Relationship.EQ, 23.0));
> constraints.add(new LinearConstraint(new double[] { 1, 0, 0, 0, 0, 0 }, Relationship.GEQ, 10.0));
> constraints.add(new LinearConstraint(new double[] { 0, 0, 1, 0, 0, 0 }, Relationship.GEQ, 8.0));
> constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 1, 0 }, Relationship.GEQ, 5.0));
> RealPointValuePair solution = new SimplexSolver().optimize(f, constraints, GoalType.MAXIMIZE, true);
> that returns 22.20, with x0 = 15.0, x1 = 23.0, x2 = 8.0, x3 = 0.0, x4 = 0.0, x5 = 0.0;
> Is it possible SimplexSolver is buggy that way? The returned value is 22.20 instead of 25.8, and the last constraint (x4 >= 5.0) is not satisfied...
> Am I using the interface wrongly?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.