HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Express product in ILP

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
expressilpproduct

Problem

Suppose I have a mixed integer-linear program (MILP) with variables $x,y,z$, where $y$ is a 0-or-1 variable, and I want to impose the constraint $z=xy$. This is not expressible in a MILP directly. Is there a way to express this using linear inequalities, by adding some new variables (possibly variables restricted to integers)?

To put it another way: I want to express the constraint $(z=0 \land y=0) \lor (z=x \land y=1)$, in a situation where I already know $y$ is constrained to be either 0 or 1.

Solution

It depends on $x$ being bounded or not.

Suppose that $x$ is bounded as $x\in[0,x_{\mathrm{max}}]$. Then, the constraint $z=xy$ can be written as:
$$
\begin{cases}
z\leq x_{\mathrm{max}} y,\\
z\leq x,\\
z\geq x-(1-y)x_{\mathrm{max}},\\
z\geq 0.
\end{cases}
$$

You easily see that:

  • if $y=0$, then $z=0$; and



  • if $y=1$, then $z=x$.

Context

StackExchange Computer Science Q#54393, answer score: 2

Revisions (0)

No revisions yet.