Processing math: 100%

Wednesday, May 14, 2008

Multiplication of binary variables

I see often MINLP models where the only nonlinear expression is the multiplication of two binary variables. Such models can be linearized quite easily and are in most cases better solved as a linear MIP model. A good formulation for z=x1x2 where x1, x2 are binary variables is as follows:
0z1zx1zx2zx1+x21
Notice that we relaxed z to be continuous between 0 and 1: z is automatically integer; a property we can use to reduce the number of discrete variable. Note that modern high performance solvers may reintroduce these variables as binary as they can exploit this in their algorithms.

Another weaker formulation that is sometimes used is:
z{0,1}zx1+x22zx1+x21
This formulation has fewer equations but has two major disadvantages:
  • z needs to be integer
  • it is not as tight as the first formulation. E.g. (x1,x2,z)=(0,1,12) is infeasible in the first formulation, while it is allowed in relaxations of the second formulation.

An application of this reformulation is a QP (Quadratic Program) with binary variables:

minxQxAx=bx{0,1}

This can be modeled as:

variable y(i,j);

set ij(i,j);
ij(i,j)$( ord(i)<ord(j) ) = yes;

y.lo(ij)=0;
y.up(ij)=1;

obj.. z =e= sum(i, q(i,i)*x(i)) + sum(ij(i,j), (q(i,j)+q(j,i))*y(i,j) );
ymul1(ij(i,j)).. y(i,j) =L= x(i);
ymul2(ij(i,j)).. y(i,j) =L= x(j);
ymul3(ij(i,j)).. y(i,j) =G= x(i)+x(j)-1;

The more general product z=ixi with xi{0,1} can be linearized in the same way:

zxizixi(n1)z{0,1}
where n is the cardinality of the set I. Again if we want we can relax z to z[0,1].

1 comment: