Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B97F5C3D5 for ; Tue, 10 Jul 2012 20:00:51 +0000 (UTC) Received: (qmail 4342 invoked by uid 500); 10 Jul 2012 20:00:49 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 4265 invoked by uid 500); 10 Jul 2012 20:00:49 -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 4149 invoked by uid 99); 10 Jul 2012 20:00:49 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jul 2012 20:00:49 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id 43B16142877 for ; Tue, 10 Jul 2012 20:00:47 +0000 (UTC) Date: Tue, 10 Jul 2012 20:00:47 +0000 (UTC) From: "Raghu Rangarajan (JIRA)" To: issues@commons.apache.org Message-ID: <1283536762.30628.1341950447281.JavaMail.jiratomcat@issues-vm> In-Reply-To: <2141951051.28530.1341932314630.JavaMail.jiratomcat@issues-vm> Subject: [jira] [Closed] (MATH-813) SimplexSolver bug? MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Raghu Rangarajan closed MATH-813. --------------------------------- > SimplexSolver bug? > ------------------ > > Key: MATH-813 > URL: https://issues.apache.org/jira/browse/MATH-813 > Project: Commons Math > Issue Type: Bug > Affects Versions: 3.0 > Environment: Windows 7, JDK 1.7.0_03 > Reporter: Raghu Rangarajan > Fix For: Nightly Builds > > Attachments: Commons_Solver.java > > > I am trying to use the SimplexSolver in commons-math3-3.0 and am getting unpredictable results. I am pasting the problem code below. Basically swapping the sequence of the last two constraints results in two different results (of which one is pure sub-optimal). Am I not using the solver correctly? > ------------------------------ > import java.util.ArrayList; > import java.util.Collection; > import org.apache.commons.math3.optimization.*; > import org.apache.commons.math3.optimization.linear.*; > public class Commons_Solver { > public static void main(String[] args) { > // describe the optimization problem > > LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 1, 1, 1, 1, 1, 1, 0, 0 }, 0); > Collection constraints = new ArrayList(); > > //variables upper bounds > constraints.add(new LinearConstraint(new double[] { 1, 0, 0, 0, 0, 0, 0, 0 }, Relationship.LEQ, 38)); > constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 0, 0, 0, 0, 0 }, Relationship.LEQ, 34)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 1, 0, 0, 0, 0, 0 }, Relationship.LEQ, 1)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 1, 0, 0, 0, 0 }, Relationship.LEQ, 6)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 1, 0, 0, 0 }, Relationship.LEQ, 17)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 0, 1, 0, 0 }, Relationship.LEQ, 11)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 0, 0, 1, 0 }, Relationship.LEQ, 101)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 0, 0, 0, 1 }, Relationship.LEQ, 1e10)); > //variables lower bounds > constraints.add(new LinearConstraint(new double[] { 1, 0, 0, 0, 0, 0, 0, 0 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 0, 0, 0, 0, 0 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 1, 0, 0, 0, 0, 0 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 1, 0, 0, 0, 0 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 1, 0, 0, 0 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 0, 1, 0, 0 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 0, 0, 1, 0 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 0, 0, 0, 1 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { -1,-1, -1, -1, -1, -1, 1, 0 }, Relationship.EQ, 0)); > constraints.add(new LinearConstraint(new double[] { -1, -1, -1, -1, -1, -1,0 , 1 }, Relationship.EQ, 0)); > constraints.add(new LinearConstraint(new double[] { 1, 0, 0, 0, 0, 0, 0, -0.2841121495327103 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 1, 0, 0, 0, 0, 0, -0.25420560747663556 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 1, 0, 0, 0, -0.04485981308411215 }, Relationship.GEQ, 0)); > > /*--------------- > Swapping the sequence of the below two constraints produces two different results > ------------------*/ > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 1, 0, 0, -0.12710280373831778 }, Relationship.GEQ, 0)); > constraints.add(new LinearConstraint(new double[] { 0, 0, 0, 0, 0, 1, 0, -0.08224299065420561 }, Relationship.GEQ, 0)); > /*------------------*/ > > PointValuePair solution = new SimplexSolver().optimize(f, constraints, GoalType.MAXIMIZE, false); > // get the solution > for (int i = 0 ; i < solution.getPoint().length; i++) > System.out.println("x[" + i + "] = " + solution.getPoint()[i]); > > System.out.println("value = " + solution.getValue()); > } > } > ---------------------------------- -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira