subject to:
is solved.
import com.imsl.math.*; public class LinearProgrammingEx2 { public static void main(String args[]) throws Exception { int[] constraintType = {3}; double[] upperBound = {1.0, 1.0}; double[][] a = {{1.0, 1.0}}; double[] b = {0.5}; double[] upperLimit = {1.5}; double[] c = {-1.0, -3.0}; LinearProgramming zf = new LinearProgramming(a, b, c); zf.setUpperLimit(upperLimit); zf.setConstraintType(constraintType); zf.setUpperBound(upperBound); zf.solve(); new PrintMatrix("Solution").print(zf.getPrimalSolution()); new PrintMatrix("Dual Solution").print(zf.getDualSolution()); System.out.println("Optimal Value = " + zf.getOptimalValue()); } }
Solution 0 0 0.5 1 1 Dual Solution 0 0 -1 Optimal Value = -3.5Link to Java source.