Language Reference

LCP Call

CALL LCP (rc, w, z, m, q <, epsilon> ) ;

This subroutine is supported by the IML procedure and the iml action.

The LCP subroutine solves the linear complementarity problem:

StartLayout 1st Row 1st Column bold w 2nd Column equals 3rd Column bold upper M bold z plus bold q 2nd Row 1st Column bold w prime bold z 2nd Column equals 3rd Column 0 3rd Row 1st Column bold w comma bold z 2nd Column greater-than-or-equal-to 3rd Column 0 EndLayout

That is, given a matrix bold upper M and a vector bold q, the LCP subroutine computes orthogonal, nonnegative vectors bold w and bold z which satisfy the previous equations.

The input arguments to the LCP subroutine are as follows:

m

is an m times m matrix.

q

is an m times 1 matrix.

epsilon

is a scalar that defines virtual zero. The default value of epsilon is 1E–8.

The LCP subroutine returns the following matrices:

rc

returns one of the following scalar return codes:

rc Termination
0 A solution is found.
1 No solution is possible.
5 The solution is numerically unstable.
6 The subroutine could not obtain enough memory.

w

returns an m-element column vector

z

returns an m-element column vector

The following statements give a simple example:

q = {1, 1};
m = {1 0,
     0 1};
call lcp(rc, w, z, m, q);
print rc, w, z;

Figure 220: Solution to a Linear Complementarity Problem

rc
0

w
1
1

z
0
0


The next example shows the relationship between quadratic programming and the linear complementarity problem. Consider the linearly constrained quadratic program:

StartLayout 1st Row 1st Column min bold c prime bold x 2nd Column plus 3rd Column one-half bold x prime bold upper H bold x 2nd Row 1st Column st period bold upper G bold x 2nd Column greater-than-or-equal-to 3rd Column bold b left-parenthesis QP right-parenthesis 3rd Row 1st Column bold x 2nd Column greater-than-or-equal-to 3rd Column 0 EndLayout

If bold upper H is positive semidefinite, then a solution to the Kuhn-Tucker conditions solves QP. The Kuhn-Tucker conditions for QP are

StartLayout 1st Row 1st Column bold c plus bold upper H bold x 2nd Column equals 3rd Column mu plus bold upper G prime lamda 2nd Row 1st Column lamda prime left-parenthesis bold upper G bold x minus bold b right-parenthesis 2nd Column equals 3rd Column 0 3rd Row 1st Column mu prime bold x 2nd Column equals 3rd Column 0 4th Row 1st Column bold upper G bold x 2nd Column greater-than-or-equal-to 3rd Column bold b 5th Row 1st Column x comma mu comma lamda 2nd Column greater-than-or-equal-to 3rd Column 0 EndLayout

In the linear complementarity problem, let

StartLayout 1st Row 1st Column bold upper M 2nd Column equals 3rd Column Start 2 By 2 Matrix 1st Row 1st Column upper H 2nd Column minus upper G prime 2nd Row 1st Column upper G 2nd Column 0 EndMatrix 2nd Row 1st Column bold w prime 2nd Column equals 3rd Column left-parenthesis mu prime bold s prime right-parenthesis 3rd Row 1st Column bold z prime 2nd Column equals 3rd Column left-parenthesis bold x prime lamda prime right-parenthesis 4th Row 1st Column bold q prime 2nd Column equals 3rd Column left-parenthesis bold c prime minus bold b right-parenthesis EndLayout

Then the Kuhn-Tucker conditions are expressed as finding bold w and bold z that satisfy

StartLayout 1st Row 1st Column bold w 2nd Column equals 3rd Column bold upper M bold z plus bold q 2nd Row 1st Column bold w prime bold z 2nd Column equals 3rd Column 0 3rd Row 1st Column bold w comma bold z 2nd Column greater-than-or-equal-to 3rd Column 0 EndLayout

From the solution bold w and bold z to this linear complementarity problem, the solution to QP is obtained; namely, bold x is the primal structural variable, bold s equals bold upper G bold x minus bold b the surpluses, and bold-italic mu and bold-italic lamda are the dual variables. Consider a quadratic program with the following data:

StartLayout 1st Row 1st Column bold upper C prime 2nd Column equals 3rd Column left-parenthesis 1 2 4 5 right-parenthesis bold upper B prime equals left-parenthesis 1 1 right-parenthesis 2nd Row 1st Column bold upper H 2nd Column equals 3rd Column Start 4 By 4 Matrix 1st Row 1st Column 100 2nd Column 10 3rd Column 1 4th Column 0 2nd Row 1st Column 10 2nd Column 100 3rd Column 10 4th Column 1 3rd Row 1st Column 1 2nd Column 10 3rd Column 100 4th Column 10 4th Row 1st Column 0 2nd Column 1 3rd Column 10 4th Column 100 EndMatrix 3rd Row 1st Column bold upper G 2nd Column equals 3rd Column Start 2 By 4 Matrix 1st Row 1st Column 1 2nd Column 2 3rd Column 3 4th Column 4 2nd Row 1st Column 10 2nd Column 20 3rd Column 30 4th Column 40 EndMatrix EndLayout

This problem is solved by using the LCP subroutine as follows:

/*---- Data for the Quadratic Program -----*/
c = {1, 2, 3, 4};
h = {100 10 1 0, 10 100 10 1, 1 10 100 10, 0 1 10 100};
g = {1 2 3 4, 10 20 30 40};
b = {1, 1};

/*----- Express the Kuhn-Tucker Conditions as an LCP ----*/
m = h || -g`;
m = m // (g || j(nrow(g),nrow(g),0));
q = c // -b;

/*----- Solve for a Kuhn-Tucker Point --------*/
call lcp(rc, w, z, m, q);

/*------ Extract the Solution to the Quadratic Program ----*/
x = z[1:nrow(h)];
print rc x;

Figure 221: Solution to a Quadratic Programming Problem

rcx
00.0307522
 0.0619692
 0.0929721
 0.1415983


Last updated: May 07, 2026