# Modeling following constraints in MILP. I want to know how I should formulate the following constraints in my MIP problem? x=x_1z_1+⋯+x_n z_n and y_1 <= y <= y_n and z_1+ cdots +z_n=1

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

OR

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.
You can still ask an expert for help

• Questions are typically answered in as fast as 30 minutes

Solve your problem for the price of one coffee

• Math expert for every subject
• Pay only if we can solve it

Szulikto
Step 1
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 \left\{0,1\right\}$ and ${w}_{1},\dots ,{w}_{n}\in \left\{0,1\right\}$, plus $\stackrel{^}{z},\stackrel{~}{z},\stackrel{^}{w},\stackrel{~}{w}\in \left[0,1\right]$ and one more binary variable $t\in \left\{0,1\right\}$. The constraints will be as follows:
$\begin{array}{rl}x& =\sum _{i}{x}_{i}{z}_{i}+{x}_{1}\stackrel{^}{z}+{x}_{n}\stackrel{~}{z}\\ y& =\sum _{i}{y}_{i}{w}_{i}+{y}_{1}\stackrel{^}{w}+{y}_{n}\stackrel{~}{w}\\ \sum _{i}{z}_{i}& =1-t\\ \stackrel{^}{z}+\stackrel{~}{z}& =t\\ \sum _{i}{w}_{i}& =t\\ \stackrel{^}{w}+\stackrel{~}{w}& =1-t.\end{array}$
Step 2
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 $\left[{y}_{1},{y}_{n}\right]$. If $t=1$, the reverse occurs.
###### Did you like this example?
varsa1m
Step 1
$\begin{array}{}\text{(1)}& {x}_{min}\le x& \le {x}_{max}\text{(2)}& {y}_{min}\le y& \le {y}_{max}\text{(3)}& \left({x}_{min}-\sum _{i}{x}_{i}\right)t\le x-\sum _{i}{x}_{i}{z}_{i}& \le {x}_{max}\cdot t\text{(4)}& -t\le \sum _{i}{z}_{i}-1& \le \left(n-1\right)t\text{(5)}& \left({y}_{min}-\sum _{i}{y}_{i}\right)\left(1-t\right)\le y-\sum _{i}{y}_{i}{w}_{i}& \le {y}_{max}\left(1-t\right)\text{(6)}& -\left(1-t\right)\le \sum _{i}{w}_{i}-1& \le \left(n-1\right)\left(1-t\right)\end{array}$
Step 2
Constraints (1) and (2) are valid for both sides of the desired disjunction. Constraints (3) and (4) enforce
$t=0\phantom{\rule{thickmathspace}{0ex}}⟹\phantom{\rule{thickmathspace}{0ex}}\left(x=\sum _{i}{x}_{i}{z}_{i}\wedge \sum _{i}{z}_{i}=1\right).$
Constraints (5) and (6) enforce
$t=1\phantom{\rule{thickmathspace}{0ex}}⟹\phantom{\rule{thickmathspace}{0ex}}\left(y=\sum _{i}{y}_{i}{w}_{i}\wedge \sum _{i}{w}_{i}=1\right).$