is solved.
import com.imsl.math.*; public class SparseLPEx1 { public static void main(String args[]) throws Exception { double[] b = {3.0, 6.0, 2.0}; double[] c = {2.0, -8.0, 3.0}; double[] xlb = {-1.0, 0.0, 0.0}; double[] xub = {5.0, 7.0, 9.0}; int[] irtype = {1, 1, 2}; SparseMatrix a = new SparseMatrix(3, 3); a.set(0, 0, 1.0); a.set(0, 1, 3.0); a.set(1, 1, 2.0); a.set(1, 2, 3.0); a.set(2, 0, 1.0); a.set(2, 1, 1.0); a.set(2, 2, 1.0); // Solve problem. SparseLP lp = new SparseLP(a, b, c); lp.setLowerBound(xlb); lp.setUpperBound(xub); lp.setConstraintType(irtype); lp.solve(); // Print solution. PrintMatrixFormat mf = new PrintMatrixFormat(); mf.setNoColumnLabels(); new PrintMatrix("Solution").print(mf, lp.getSolution()); System.out.printf("Objective: %.2f\n", lp.getOptimalValue()); } }
Solution 0 -0.375 1 1.125 2 1.25 Objective: -6.00Link to Java source.