Formulating a complicated if else statement with linear programming

42 Views Asked by At

I'm trying to convert the following statement into «only one» inequality. Is it possible?

If $M[i] < M[j]$ and $M[j] < M[k] $ and $A[i,k] = 1$ then $A[i,j]=1$

$M$ is an array of size N and its elements are in the range of 1..N. $A$ is a 2d array of size $N*N$ and its elements are either 0 or 1. I've seen a lot of examples of converting problems into lp problems but none of them were this complicated. I've thought of some solutions but they don't seem to work. Any help would be really appreciated.

1

There are 1 best solutions below

0
On

You can enforce the desired implication via the following linear constraint: $$\text{$A[i,k] \le A[i,j]$ for all $i,j,k$ such that $M[i] < M[j]$ and $M[j] < M[k]$}$$