Modeling following constraints in MILP

65 Views Asked by At

I want to know how I should formulate the following constraints in my MIP problem?

$$x= x_1 z_1+ \dots +x_n z_n \text{ and } y_1 \le y \le y_n \text{ and } z_1+\dots+z_n=1$$

OR

$$y= y_1 w_1+\dots+y_n w_n \text{ and } x_1 \le x \le x_n \text{ and } w_1+\dots+w_n=1$$

$x$ and $y$ are continuous variables. $z_1,\dots,z_n$ and $w_1,\dots,w_n$ are binary decision variables. $x_1,\dots,x_n$ and $y_1,\dots,y_n$ are parameters.

2

There are 2 best solutions below

2
On BEST ANSWER

The usual big-M approach is to introduce a binary variable $t$ as in @prubin's formulation and then impose the following constraints: \begin{align} x_{\min} \le x &\le x_{\max} \tag{1} \\ y_{\min} \le y &\le y_{\max} \tag{2} \\ \left(x_{\min} - \sum_i x_i\right) t \le x - \sum_i x_i z_i &\le x_{\max} \cdot t \tag{3} \\ -t \le \sum_i z_i - 1 &\le (n-1) t \tag{4} \\ \left(y_{\min} - \sum_i y_i\right) (1-t) \le y - \sum_i y_i w_i &\le y_{\max}(1-t) \tag{5} \\ -(1-t) \le \sum_i w_i - 1 &\le (n-1) (1-t) \tag{6} \end{align}

Constraints $(1)$ and $(2)$ are valid for both sides of the desired disjunction. Constraints $(3)$ and $(4)$ enforce $$t=0 \implies \left(x = \sum_i x_i z_i \land \sum_i z_i = 1\right).$$ Constraints $(5)$ and $(6)$ enforce $$t=1 \implies \left(y = \sum_i y_i w_i \land \sum_i w_i = 1\right).$$

2
On

Brace yourself, the notation is about to get a little ugly.

Let me list the variables first. In addition to $x$ and $y$ (continuous), we will have $z_1,\dots,z_n\in \lbrace 0,1 \rbrace$ and $w_1,\dots,w_n\in \lbrace 0,1 \rbrace$, plus $\hat{z},\tilde{z},\hat{w},\tilde{w}\in [0,1]$ and one more binary variable $t\in \lbrace 0,1 \rbrace$. The constraints will be as follows:\begin{align} x & =\sum_{i}x_{i}z_{i}+x_{1}\hat{z}+x_{n}\tilde{z}\\ y & =\sum_{i}y_{i}w_{i}+y_{1}\hat{w}+y_{n}\tilde{w}\\ \sum_{i}z_{i} & =1-t\\ \hat{z}+\tilde{z} & =t\\ \sum_{i}w_{i} & =t\\ \hat{w}+\tilde{w} & =1-t. \end{align}

If $t=0$, the fourth equation zeroes out the last two terms of the first equation and the third equation plus the first equation result in $x$ being one of the $x_i$. Meanwhile, the fifth equation zeroes out the summation in the second equation and the sixth equation and what's left of the second equation make $y$ a convex combination of the endpoints $y_1$, $y_n$, so basically any value in the interval $[y_1,y_n]$. If $t=1$, the reverse occurs.