If-then-else condition to Linear Programming (equations) representation

401 Views Asked by At
if(P == 1) then T = A else T = 0;

Where P is binary, A is an int variable. Basically T = AP

How to express this in linear equations?

I'm unable to figure out from link1, link2, link3, link4, or link5.

1

There are 1 best solutions below

0
On

Let $\ell \le A \le u$ for constants $\ell$ and $u$, and impose linear constraints \begin{align} \ell (1-P) \le A - T &\le u (1-P) \tag1\\ \ell P \le T &\le u P \tag2 \end{align} Constraint $(1)$ enforces $P=1 \implies T=A$. Constraint $(2)$ enforces $P=0 \implies T = 0$.