title: apache.commons.math3 - how to use linear programming?
body: <p>commons-math (ver. 2.2) had an LP solver. </p>
  
  <p><a href="https://michaelmadhukalya.wordpress.com/2013/11/06/solving-linear-programming-lp-problems-using-java/" rel="nofollow">Here</a> I found the follow example code: </p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Collection;
  
  import org.apache.commons.math.optimization.GoalType;
  import org.apache.commons.math.optimization.OptimizationException;
  import org.apache.commons.math.optimization.RealPointValuePair;
  import org.apache.commons.math.optimization.linear.LinearConstraint;
  import org.apache.commons.math.optimization.linear.LinearObjectiveFunction;
  import org.apache.commons.math.optimization.linear.Relationship;
  import org.apache.commons.math.optimization.linear.SimplexSolver;
  
  @SuppressWarnings("deprecation")
  public class Main {
      @SuppressWarnings({ "rawtypes", "unchecked"})
      public static void main(String[] args) {
          //describe the optimization problem
          LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 3, 5}, 0);
  
          Collection constraints = new ArrayList();
          constraints.add(new LinearConstraint(new double[] { 2, 8}, Relationship.LEQ, 13));
          constraints.add(new LinearConstraint(new double[] { 5, -1}, Relationship.LEQ, 11));
  
          constraints.add(new LinearConstraint(new double[] { 1, 0}, Relationship.GEQ, 0));
          constraints.add(new LinearConstraint(new double[] { 0, 1}, Relationship.GEQ, 0));
  
          //create and run solver
          RealPointValuePair solution = null;
          try {
              solution = new SimplexSolver().optimize(f, constraints, GoalType.MAXIMIZE, false);
          }
          catch (OptimizationException e) {
              e.printStackTrace();
          }
  
          if (solution != null) {
              //get solution
              double max = solution.getValue();
              System.out.println("Opt: " + max);
  
              //print decision variables
              for (int i = 0; i &lt; 2; i++) {
                  System.out.print(solution.getPoint()[i] + "\t");
              }
          }
      }
  }
  </code></pre>
  
  <p>However, when adding the maven dependency of the latest math version (3.6.1) </p>
  
  <p>I see most related classes are deprecated, and I haven't found any code examples for the updated versions.</p>
  
  <p>Would be glad to use 3.6.1 for my LP problems - can someone assist here please? </p>