subject to the following set of restrictions:
; ; ; ;
Since DenseLP minimizes
, the sign of the objective function must be changed to compute this solution. The signs of the dual solution components and the optimal value must also be changed. Because and are not uniquely determined within the bounds, this problem has a convex family of solutions. DenseLP issues an exception, MultipleSolutionsException
. A particular solution is available and retrieved in the finally
block.
import com.imsl.math.*; public class DenseLPEx3 { public static void main(String[] args) throws Exception { int[] constraintType = {1, 1}; /* Ax <= b */ double[] lowerVariableBound = {0.0, 0.0, 0.0, 0.0, 0.0}; double[] upperVariableBound = {1.0, 1.0, 1.0, 1.0, 1.0}; double[][] A = { {100.0, 50.0, 50.0, 40.0, 120.0}, {40.0, 50.0, 50.0, 15.0, 30.0} }; double[] b = {300.0, 40.0}; /* constraint type Ax <= b */ double[] c = {10.0, 15.0, 15.0, 13.0, 9.0 }; /* Since DenseLP minimizes, change signs of the objective coefficients. */ double[] negC = new double[c.length]; for (int i=0; i<c.length; i++) negC[i] = -c[i]; DenseLP zf = new DenseLP(A, b, negC); zf.setLowerBound(lowerVariableBound); zf.setConstraintType(constraintType); zf.setUpperBound(upperVariableBound); try { zf.solve(); } catch (DenseLP.MultipleSolutionsException e) { /* x_2 and x_3 are not uniquely determined, expect multiple solutions. * Catch the exception, but continue to print result found. */ System.out.println("Multiple solutions giving " + "essentially the same minimum exist."); } finally { double[] dSolution = zf.getDualSolution(); /* Change the sign of the dual solution and optimal value * since DenseLP minimizes. */ for (int i = 0; i < dSolution.length; i++) dSolution[i] = -dSolution[i]; double optimalValue = -zf.getOptimalValue(); new PrintMatrix("Solution").print(zf.getPrimalSolution()); new PrintMatrix("Dual Solution").print(dSolution); System.out.println("Optimal Value = " + optimalValue); } } }
Multiple solutions giving essentially the same minimum exist. Solution 0 0 0 1 0.257 2 0.243 3 1 4 0 Dual Solution 0 0 -0 1 0.3 Optimal Value = 20.5Link to Java source.