You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Raghu Rangarajan (JIRA)" <ji...@apache.org> on 2012/07/10 16:58:34 UTC

[jira] [Created] (MATH-813) SimplexSolver bug?

Raghu Rangarajan created MATH-813:
-------------------------------------

             Summary: 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


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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
    
    //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

        

[jira] [Closed] (MATH-813) SimplexSolver bug?

Posted by "Raghu Rangarajan (JIRA)" <ji...@apache.org>.
     [ 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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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

        

[jira] [Commented] (MATH-813) SimplexSolver bug?

Posted by "Raghu Rangarajan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13410751#comment-13410751 ] 

Raghu Rangarajan commented on MATH-813:
---------------------------------------

Hi Thomas,

I too am able to get the right results with the latest trunk code. Thanks for looking into this. 

Raghu
                
> 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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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

        

[jira] [Resolved] (MATH-813) SimplexSolver bug?

Posted by "Raghu Rangarajan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Raghu Rangarajan resolved MATH-813.
-----------------------------------

    Resolution: Fixed
    
> 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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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

        

[jira] [Closed] (MATH-813) SimplexSolver bug?

Posted by "Raghu Rangarajan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Raghu Rangarajan closed MATH-813.
---------------------------------

       Resolution: Fixed
    Fix Version/s: Nightly Builds
    
> 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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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

        

[jira] [Reopened] (MATH-813) SimplexSolver bug?

Posted by "Raghu Rangarajan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Raghu Rangarajan reopened 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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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

        

[jira] [Commented] (MATH-813) SimplexSolver bug?

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13410637#comment-13410637 ] 

Thomas Neidhart commented on MATH-813:
--------------------------------------

Hi,

I quickly checked your test case with the latest trunk and I get exactly the same result. Most likely your observed problem has been fixed already as part of MATH-781. Could you please check yourself with the latest trunk and confirm that the problem is not existent anymore?

Thanks,

Thomas
                
> 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
>         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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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

        

[jira] [Reopened] (MATH-813) SimplexSolver bug?

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Neidhart reopened 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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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

        

[jira] [Updated] (MATH-813) SimplexSolver bug?

Posted by "Raghu Rangarajan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Raghu Rangarajan updated MATH-813:
----------------------------------

    Attachment: Commons_Solver.java
    
> 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
>         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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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

        

[jira] [Commented] (MATH-813) SimplexSolver bug?

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13410764#comment-13410764 ] 

Thomas Neidhart commented on MATH-813:
--------------------------------------

Thanks for the report anyway!

I marked the issue as a duplicate of MATH-781 and changed the fix version to 3.1
                
> 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: 3.1
>
>         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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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

        

[jira] [Resolved] (MATH-813) SimplexSolver bug?

Posted by "Thomas Neidhart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/MATH-813?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Neidhart resolved MATH-813.
----------------------------------

       Resolution: Duplicate
    Fix Version/s:     (was: Nightly Builds)
                   3.1

Duplicate of MATH-781
                
> 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: 3.1
>
>         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 <LinearConstraint>constraints = new ArrayList<LinearConstraint>();
>     
>     //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