Example 3: Solve a Quadratic Programming Problem with Inconsistent System Constraints

In the quadratic programming problem variables 2 and 6 are fixed at the value zero by the equality constraints. The inequalities propose that the sums of the variables are at least 5.1 and no more than 4.9. These last two are inconsistent conditions, causing the NoLPSolutionException to be thrown.


import com.imsl.math.*;

public class QuadraticProgrammingEx3 {

    public static void main(String[] args) {

        double[][] h = {
            {2.000, 0.000, 0.000, 0.000, 0.000, 0.000},
            {0.000, 2.000, 0.000, 0.000, 0.000, 0.000},
            {0.000, 0.000, 2.000, 0.000, 0.000, 0.000},
            {0.000, 0.000, 0.000, 2.000, 0.000, 0.000},
            {0.000, 0.000, 0.000, 0.000, 2.000, 0.000},
            {0.000, 0.000, 0.000, 0.000, 0.000, 2.000}
        };
        double[] g = {5.000, 5.000, 5.000, 5.000, 5.000, 5.000};

        double[][] aEquality = {
            {0.000, 1.000, 0.000, 0.000, 0.000, 0.000},
            {0.000, 0.000, 0.000, 0.000, 0.000, 1.000}
        };
        double[] bEquality = {0.000, 0.000};

        double[][] aInequality = {
            {1.000, 1.000, 1.000, 1.000, 1.000, 1.000},
            {-1.000, -1.000, -1.000, -1.000, -1.000, -1.000}
        };
        double delta = 0.1;  // change to 0.0 to pass
        double[] bInequality = {5 + delta, -5 + delta};
      
        try {
            QuadraticProgramming qp =
                    new QuadraticProgramming(h, g, aEquality, bEquality,
                    aInequality, bInequality);
            double x[] = qp.getSolution();
            new com.imsl.math.PrintMatrix("Solution").print(x);
        } catch (Exception e) {
            WriteCutString(e.getMessage(), 72);
        }
    }
    public static void WriteCutString(String value, int interval) {
        int rem = value.length() % interval;
        int len = value.length() / interval + rem / (1 > rem ? 1 : rem);

        for (int i = 0; i < len; i++) {
            System.out.println(value.substring(i * interval,
                  (i * interval) + (interval < (value.length() - i * interval)
                   ? interval : (value.length() - i * interval))));
        }
   }
}

Output

No solution for the LP problem was found. All constraints are not satisf
ied. L1 minimization was applied to all constraints (including bounds an
d simple variables) but the equalities, to approximate violated non-equa
lities as well as possible.  If a feasible solution is possible then try
 using refinement.
Link to Java source.