Integer programming formulation for the entire region of a triangle except the region of a rectangle inside it

29 Views Asked by At

Suppose we have a triangle-shaped region such as:

$x-y\ge0$

$x+y\le8$

$x,y\ge0$ and integers

How to write an IP formulation to describe all real points inside this triangle except the points inside the rectangle (Only the red-shaded region) as depicted in the figure below: Red shaded region

1

There are 1 best solutions below

0
On BEST ANSWER

You want to enforce $$\lnot(3 < x < 5 \land 1 < y < 2),$$ equivalently, $$x \le 3 \lor x \ge 5 \lor y \le 1 \lor y \le 2.$$ Introduce binary variables $z_i$ for $i \in \{1,2,3,4\}$ and linear constraints: \begin{align} x - 3 &\le (8-3)(1-z_1) \tag1\\ 5 - x &\le (5-0)(1-z_2) \tag2\\ y - 1 &\le (4-1)(1-z_3) \tag3\\ 2 - y &\le (2-0)(1-z_4) \tag4\\ \sum_{i=1}^4 z_i &\ge 1 \tag5 \end{align} Constraint $(1)$ enforces $z_1=1 \implies x \le 3$. Constraint $(2)$ enforces $z_2=1 \implies x \ge 5$. Constraint $(3)$ enforces $z_3=1 \implies y \le 1$. Constraint $(4)$ enforces $z_4=1 \implies y \ge 2$. Constraint $(5)$ enforces $\lor_i (z_i = 1)$.