Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 76064 invoked from network); 31 Aug 2009 19:12:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 31 Aug 2009 19:12:05 -0000 Received: (qmail 38772 invoked by uid 500); 31 Aug 2009 19:12:04 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 38675 invoked by uid 500); 31 Aug 2009 19:12:03 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 38665 invoked by uid 99); 31 Aug 2009 19:12:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 Aug 2009 19:12:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 Aug 2009 19:11:53 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C978F234C052 for ; Mon, 31 Aug 2009 12:11:32 -0700 (PDT) Message-ID: <1548984978.1251745892824.JavaMail.jira@brutus> Date: Mon, 31 Aug 2009 12:11:32 -0700 (PDT) From: "Andrea (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (MATH-286) SimplexSolver not working as expected? In-Reply-To: <166608494.1250780714807.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12749580#action_12749580 ] Andrea commented on MATH-286: ----------------------------- Hi Ben, Even if I don't completely understand the format of the posted tableau, I guess the error is in the last step... You can solve the above problem on this homepage, where you can see all the steps of the simplex method: http://www.phpsimplex.com/simplex/page2.php?objetivo=max&x1=0.8&x2=0.7&restricciones=3&variables=2&l=en&x11=1&x12=1&desigualdad1=-1&y1=18&x21=1&x22=0&desigualdad2=1&y2=10&x31=0&x32=1&desigualdad3=1&y3=8&Submit=Continue The tables you posted and the tables on the above homepage look similar till the last step (the first of the second phase)... Try look at it, maybe you find the problem > 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 > Attachments: simplex.txt, SimplexSolverTest.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 constraints = new ArrayList(); > 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.