7.6 Retrieving infeasibility certificates

When a continuous problem is declared as primal or dual infeasible, MOSEK provides a Farkas-type infeasibility certificate. If, as it happens in many cases, the problem is infeasible due to an unintended mistake in the formulation or because some individual constraint is too tight, then it is likely that infeasibility can be isolated to a few linear constraints/bounds that mutually contradict each other. In this case it is easy to identify the source of infeasibility. The tutorial in Sec. 8.3 (Debugging infeasibility) has instructions on how to deal with this situation and debug it by hand. We recommend Sec. 8.3 (Debugging infeasibility) as an introduction to infeasibility certificates and how to deal with infeasibilities in general.

Some users, however, would prefer to obtain the infeasibility certificate using API for MATLAB, for example in order to repair the issue automatically, display the information to the user, or perhaps simply because the infeasibility was one of the intended outcomes that should be analyzed in the code.

In this tutorial we show how to obtain such an infeasibility certificate with API for MATLAB in the most typical case, that is when the linear part of a problem is primal infeasible. A Farkas-type primal infeasibility certificate consists of the dual values of linear constraints and bounds. Each of the dual values (multipliers) indicates that a certain multiple of the corresponding constraint should be taken into account when forming the collection of mutually contradictory equalities/inequalities.

7.6.1 Example PINFEAS

For the purpose of this tutorial we use the same example as in Sec. 8.3 (Debugging infeasibility), that is the primal infeasible problem

(7.22)\[\begin{split}\begin{array}{llccccccccccccccl} \mbox{minimize} & & x_{0} & + & 2x_{1} & + & 5x_{2} & + & 2x_{3} & + & x_{4} & + & 2x_{5} & + & x_{6} & & \\ \mbox{subject to}&s_0 : & x_{0} & + & x_{1} & & & & & & & & & & & \leq & 200, \\ &s_1 : & & & & & x_{2} & + & x_{3} & & & & & & & \leq & 1000,\\ &s_2 : & & & & & & & & & x_{4} & + & x_{5} & + & x_{6} & \leq & 1000,\\ &d_0 : & x_{0} & & & & & & & + & x_{4} & & & & & = & 1100,\\ &d_1 : & & & x_{1} & & & & & & & & & & & = & 200, \\ &d_2 : & & & & & x_{2} & + & & & & & x_{5} & & & = & 500, \\ &d_3 : & & & & & & & x_{3} & + & & & & & x_{6} & = & 500, \\ & & & & & & & & & & & & & & x_{i} & \geq & 0. \end{array}\end{split}\]

Checking infeasible status and adjusting settings

After the model has been solved we check that it is indeed infeasible. If yes, then we choose a threshold for when a certificate value is considered as an important contributor to infeasibility (ideally we would like to list all nonzero duals, but just like an optimal solution, an infeasibility certificate is also subject to floating-point rounding errors). All these steps are demonstrated in the snippet below:

% Check problem status
[hassol, prosta, solsta] = model.hassolution("interior");
if hassol && prosta == "PRIM_INFEAS"
    % Set the tolerance at which we consider a dual value as essential
    eps = 1e-7;

Going through the certificate

We now proceed through the dual values and print out the positions of those entries whose dual values exceed the given threshold. These are precisely the values we are interested in:

Listing 7.14 Demonstrates how to retrieve a primal infeasibility certificate. Click here to download.
    % Obtain the dual values (contianing certificate)
    y = model.getsolution("interior", "y");

    % List all certificate entries with (sufficiently) nonzero dual values
    disp("Constraint rows participating in infeasibility: ");
    cert = find(abs(y) > eps);
    disp(cert);

Running this code will produce the following output:

Constraint rows participating in infeasibility:
     1
     3
     4
     5
    13
    14

indicating the positions of bounds which appear in the infeasibility certificate with nonzero values.