You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stefan Radacovsky (JIRA)" <ji...@apache.org> on 2009/08/25 00:31:59 UTC
[jira] Created: (MATH-288) SimplexSolver not working as expected 2
SimplexSolver not working as expected 2
---------------------------------------
Key: MATH-288
URL: https://issues.apache.org/jira/browse/MATH-288
Project: Commons Math
Issue Type: Bug
Affects Versions: 2.1
Environment: Java 1.6.0_13 on Windows XP 32-bit
Reporter: Stefan Radacovsky
SimplexSolver didn't find the optimal solution.
Program for Lpsolve:
=====================
/* Objective function */
max: 7 a 3 b;
/* Constraints */
R1: +3 a -5 c <= 0;
R2: +2 a -5 d <= 0;
R3: +2 b -5 c <= 0;
R4: +3 b -5 d <= 0;
R5: +3 a +2 b <= 5;
R6: +2 a +3 b <= 5;
/* Variable bounds */
a <= 1;
b <= 1;
=====================
Results(correct): a = 1, b = 1, value = 10
Program for SimplexSolve:
=====================
LinearObjectiveFunction kritFcia = new LinearObjectiveFunction(new double[]{7, 3, 0, 0}, 0);
Collection<LinearConstraint> podmienky = new ArrayList<LinearConstraint>();
podmienky.add(new LinearConstraint(new double[]{1, 0, 0, 0}, Relationship.LEQ, 1));
podmienky.add(new LinearConstraint(new double[]{0, 1, 0, 0}, Relationship.LEQ, 1));
podmienky.add(new LinearConstraint(new double[]{3, 0, -5, 0}, Relationship.LEQ, 0));
podmienky.add(new LinearConstraint(new double[]{2, 0, 0, -5}, Relationship.LEQ, 0));
podmienky.add(new LinearConstraint(new double[]{0, 2, -5, 0}, Relationship.LEQ, 0));
podmienky.add(new LinearConstraint(new double[]{0, 3, 0, -5}, Relationship.LEQ, 0));
podmienky.add(new LinearConstraint(new double[]{3, 2, 0, 0}, Relationship.LEQ, 5));
podmienky.add(new LinearConstraint(new double[]{2, 3, 0, 0}, Relationship.LEQ, 5));
SimplexSolver solver = new SimplexSolver();
RealPointValuePair result = solver.optimize(kritFcia, podmienky, GoalType.MAXIMIZE, true);
=====================
Results(incorrect): a = 1, b = 0.5, value = 8.5
P.S. I used the latest software from the repository (including MATH-286 fix).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (MATH-288) SimplexSolver not working as expected
2
Posted by "Benjamin McCann (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12747167#action_12747167 ]
Benjamin McCann commented on MATH-288:
--------------------------------------
Thanks for the bug report. I've confirmed this is an issue.
Here's a slightly smaller version of the problem that causes the same bug, which might be easier for debugging:
MAX 7 a + 3 b
s.t.
3 a -5 c <= 0
2 a -5 d <= 0
3 b -5 d <= 0
a <= 1
b <= 1
LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 7, 3, 0, 0 }, 0 );
Collection<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
constraints.add(new LinearConstraint(new double[] { 3, 0, -5, 0 }, Relationship.LEQ, 0.0));
constraints.add(new LinearConstraint(new double[] { 2, 0, 0, -5 }, Relationship.LEQ, 0.0));
constraints.add(new LinearConstraint(new double[] { 0, 3, 0, -5 }, Relationship.LEQ, 0.0));
constraints.add(new LinearConstraint(new double[] { 1, 0, 0, 0 }, Relationship.LEQ, 1.0));
constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 0 }, Relationship.LEQ, 1.0));
SimplexSolver solver = new SimplexSolver();
RealPointValuePair solution = solver.optimize(f, constraints, GoalType.MAXIMIZE, true);
assertEquals(10.0, solution.getValue(), .0000001);
> SimplexSolver not working as expected 2
> ---------------------------------------
>
> Key: MATH-288
> URL: https://issues.apache.org/jira/browse/MATH-288
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 2.1
> Environment: Java 1.6.0_13 on Windows XP 32-bit
> Reporter: Stefan Radacovsky
> Original Estimate: 8h
> Remaining Estimate: 8h
>
> SimplexSolver didn't find the optimal solution.
> Program for Lpsolve:
> =====================
> /* Objective function */
> max: 7 a 3 b;
> /* Constraints */
> R1: +3 a -5 c <= 0;
> R2: +2 a -5 d <= 0;
> R3: +2 b -5 c <= 0;
> R4: +3 b -5 d <= 0;
> R5: +3 a +2 b <= 5;
> R6: +2 a +3 b <= 5;
> /* Variable bounds */
> a <= 1;
> b <= 1;
> =====================
> Results(correct): a = 1, b = 1, value = 10
> Program for SimplexSolve:
> =====================
> LinearObjectiveFunction kritFcia = new LinearObjectiveFunction(new double[]{7, 3, 0, 0}, 0);
> Collection<LinearConstraint> podmienky = new ArrayList<LinearConstraint>();
> podmienky.add(new LinearConstraint(new double[]{1, 0, 0, 0}, Relationship.LEQ, 1));
> podmienky.add(new LinearConstraint(new double[]{0, 1, 0, 0}, Relationship.LEQ, 1));
> podmienky.add(new LinearConstraint(new double[]{3, 0, -5, 0}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{2, 0, 0, -5}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{0, 2, -5, 0}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{0, 3, 0, -5}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{3, 2, 0, 0}, Relationship.LEQ, 5));
> podmienky.add(new LinearConstraint(new double[]{2, 3, 0, 0}, Relationship.LEQ, 5));
> SimplexSolver solver = new SimplexSolver();
> RealPointValuePair result = solver.optimize(kritFcia, podmienky, GoalType.MAXIMIZE, true);
> =====================
> Results(incorrect): a = 1, b = 0.5, value = 8.5
> P.S. I used the latest software from the repository (including MATH-286 fix).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (MATH-288) SimplexSolver not working as expected 2
Posted by "Luc Maisonobe (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Luc Maisonobe resolved MATH-288.
--------------------------------
Resolution: Fixed
Fix Version/s: 2.1
resolved in subversion repository as of r807738
patch applied (except for debug print function)
thanks for the repoart and thanks for the patch
> SimplexSolver not working as expected 2
> ---------------------------------------
>
> Key: MATH-288
> URL: https://issues.apache.org/jira/browse/MATH-288
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 2.1
> Environment: Java 1.6.0_13 on Windows XP 32-bit
> Reporter: Stefan Radacovsky
> Fix For: 2.1
>
> Attachments: SimplexSolver.patch, SimplexSolverTest.patch, SimplexTableau.patch
>
> Original Estimate: 8h
> Remaining Estimate: 8h
>
> SimplexSolver didn't find the optimal solution.
> Program for Lpsolve:
> =====================
> /* Objective function */
> max: 7 a 3 b;
> /* Constraints */
> R1: +3 a -5 c <= 0;
> R2: +2 a -5 d <= 0;
> R3: +2 b -5 c <= 0;
> R4: +3 b -5 d <= 0;
> R5: +3 a +2 b <= 5;
> R6: +2 a +3 b <= 5;
> /* Variable bounds */
> a <= 1;
> b <= 1;
> =====================
> Results(correct): a = 1, b = 1, value = 10
> Program for SimplexSolve:
> =====================
> LinearObjectiveFunction kritFcia = new LinearObjectiveFunction(new double[]{7, 3, 0, 0}, 0);
> Collection<LinearConstraint> podmienky = new ArrayList<LinearConstraint>();
> podmienky.add(new LinearConstraint(new double[]{1, 0, 0, 0}, Relationship.LEQ, 1));
> podmienky.add(new LinearConstraint(new double[]{0, 1, 0, 0}, Relationship.LEQ, 1));
> podmienky.add(new LinearConstraint(new double[]{3, 0, -5, 0}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{2, 0, 0, -5}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{0, 2, -5, 0}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{0, 3, 0, -5}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{3, 2, 0, 0}, Relationship.LEQ, 5));
> podmienky.add(new LinearConstraint(new double[]{2, 3, 0, 0}, Relationship.LEQ, 5));
> SimplexSolver solver = new SimplexSolver();
> RealPointValuePair result = solver.optimize(kritFcia, podmienky, GoalType.MAXIMIZE, true);
> =====================
> Results(incorrect): a = 1, b = 0.5, value = 8.5
> P.S. I used the latest software from the repository (including MATH-286 fix).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (MATH-288) SimplexSolver not working as expected 2
Posted by "Phil Steitz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz closed MATH-288.
----------------------------
> SimplexSolver not working as expected 2
> ---------------------------------------
>
> Key: MATH-288
> URL: https://issues.apache.org/jira/browse/MATH-288
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 2.1
> Environment: Java 1.6.0_13 on Windows XP 32-bit
> Reporter: Stefan Radacovsky
> Fix For: 2.1
>
> Attachments: SimplexSolver.patch, SimplexSolverTest.patch, SimplexTableau.patch
>
> Original Estimate: 8h
> Remaining Estimate: 8h
>
> SimplexSolver didn't find the optimal solution.
> Program for Lpsolve:
> =====================
> /* Objective function */
> max: 7 a 3 b;
> /* Constraints */
> R1: +3 a -5 c <= 0;
> R2: +2 a -5 d <= 0;
> R3: +2 b -5 c <= 0;
> R4: +3 b -5 d <= 0;
> R5: +3 a +2 b <= 5;
> R6: +2 a +3 b <= 5;
> /* Variable bounds */
> a <= 1;
> b <= 1;
> =====================
> Results(correct): a = 1, b = 1, value = 10
> Program for SimplexSolve:
> =====================
> LinearObjectiveFunction kritFcia = new LinearObjectiveFunction(new double[]{7, 3, 0, 0}, 0);
> Collection<LinearConstraint> podmienky = new ArrayList<LinearConstraint>();
> podmienky.add(new LinearConstraint(new double[]{1, 0, 0, 0}, Relationship.LEQ, 1));
> podmienky.add(new LinearConstraint(new double[]{0, 1, 0, 0}, Relationship.LEQ, 1));
> podmienky.add(new LinearConstraint(new double[]{3, 0, -5, 0}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{2, 0, 0, -5}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{0, 2, -5, 0}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{0, 3, 0, -5}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{3, 2, 0, 0}, Relationship.LEQ, 5));
> podmienky.add(new LinearConstraint(new double[]{2, 3, 0, 0}, Relationship.LEQ, 5));
> SimplexSolver solver = new SimplexSolver();
> RealPointValuePair result = solver.optimize(kritFcia, podmienky, GoalType.MAXIMIZE, true);
> =====================
> Results(incorrect): a = 1, b = 0.5, value = 8.5
> P.S. I used the latest software from the repository (including MATH-286 fix).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Updated: (MATH-288) SimplexSolver not working as expected 2
Posted by "Benjamin McCann (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/MATH-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Benjamin McCann updated MATH-288:
---------------------------------
Attachment: SimplexTableau.patch
SimplexSolverTest.patch
SimplexSolver.patch
Patch attached. It was a 1 character bug. I was saying to only do the minimum ratio test if the entry is >= 0, but it should have been > 0 (dividing by 0 is never good :o)
Thanks again for the bug report.
> SimplexSolver not working as expected 2
> ---------------------------------------
>
> Key: MATH-288
> URL: https://issues.apache.org/jira/browse/MATH-288
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 2.1
> Environment: Java 1.6.0_13 on Windows XP 32-bit
> Reporter: Stefan Radacovsky
> Attachments: SimplexSolver.patch, SimplexSolverTest.patch, SimplexTableau.patch
>
> Original Estimate: 8h
> Remaining Estimate: 8h
>
> SimplexSolver didn't find the optimal solution.
> Program for Lpsolve:
> =====================
> /* Objective function */
> max: 7 a 3 b;
> /* Constraints */
> R1: +3 a -5 c <= 0;
> R2: +2 a -5 d <= 0;
> R3: +2 b -5 c <= 0;
> R4: +3 b -5 d <= 0;
> R5: +3 a +2 b <= 5;
> R6: +2 a +3 b <= 5;
> /* Variable bounds */
> a <= 1;
> b <= 1;
> =====================
> Results(correct): a = 1, b = 1, value = 10
> Program for SimplexSolve:
> =====================
> LinearObjectiveFunction kritFcia = new LinearObjectiveFunction(new double[]{7, 3, 0, 0}, 0);
> Collection<LinearConstraint> podmienky = new ArrayList<LinearConstraint>();
> podmienky.add(new LinearConstraint(new double[]{1, 0, 0, 0}, Relationship.LEQ, 1));
> podmienky.add(new LinearConstraint(new double[]{0, 1, 0, 0}, Relationship.LEQ, 1));
> podmienky.add(new LinearConstraint(new double[]{3, 0, -5, 0}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{2, 0, 0, -5}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{0, 2, -5, 0}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{0, 3, 0, -5}, Relationship.LEQ, 0));
> podmienky.add(new LinearConstraint(new double[]{3, 2, 0, 0}, Relationship.LEQ, 5));
> podmienky.add(new LinearConstraint(new double[]{2, 3, 0, 0}, Relationship.LEQ, 5));
> SimplexSolver solver = new SimplexSolver();
> RealPointValuePair result = solver.optimize(kritFcia, podmienky, GoalType.MAXIMIZE, true);
> =====================
> Results(incorrect): a = 1, b = 0.5, value = 8.5
> P.S. I used the latest software from the repository (including MATH-286 fix).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.