Quantcast
Channel: Yet Another Math Programming Consultant
Viewing all articles
Browse latest Browse all 809

Linearize min(a,b)>min(x,y)

$
0
0

This question was posed [1]: How to linearize \[\min(\color{darkred}a,\color{darkred}b)\gt \min(\color{darkred}x,\color{darkred}y)\] where \(\color{darkred}a,\color{darkred}b,\color{darkred}x,\color{darkred}y\) are variables. The type of variables is not specified so let's assume they all are continuous variables.

The easiest is to split the problem in two parts: \[\begin{align} &\color{darkred}z = \min(\color{darkred}x,\color{darkred}y) \\ & \min(\color{darkred}a,\color{darkred}b) \gt \color{darkred}z\end{align}\] The first part: \(\color{darkred}z = \min(\color{darkred}x,\color{darkred}y)\) can be modeled with an extra binary variable \(\delta\): \[\begin{align}&\color{darkred}z \le \color{darkred}x \\ & \color{darkred}z \le \color{darkred}y \\ & \color{darkred}z \ge \color{darkred}x - \color{darkblue}M\cdot \color{darkred}\delta \\ & \color{darkred}z \ge \color{darkred}x - \color{darkblue}M\cdot (1-\color{darkred}\delta)\end{align}\] The constant \(\color{darkblue}M\) is a large enough number (but not larger) that should be chosen with care. This construct is essentially: \[\begin{align} & \color{darkred}z\le \color{darkred}x\> {\bf and }\> \color{darkred}z \le \color{darkred}y\\ & \color{darkred}z \ge \color{darkred}x \>{\bf or }\> \color{darkred}z \ge \color{darkred}y \end{align}\] 

If we cannot establish a good value for \(\color{darkblue}M\), we can use some alternatives for \[\begin{align}&\color{darkred}z \ge \color{darkred}x - \color{darkblue}M\cdot \color{darkred}\delta \\ & \color{darkred}z \ge \color{darkred}x - \color{darkblue}M\cdot (1-\color{darkred}\delta)\end{align}\] depending on what your MIP solver supports:

  • Indicator constraints: \[\begin{align}& \color{darkred}\delta=0 \implies \color{darkred}z \ge \color{darkred}x\\ & \color{darkred}\delta=1 \implies \color{darkred}z \ge \color{darkred}y\end{align}\]
  • SOS1 variables:  \[\begin{align}& \color{darkred}z \ge \color{darkred}x - \color{darkred}s_1\\ &  \color{darkred}z \ge \color{darkred}y -\color{darkred}s_2\\ & \color{darkred}s_1,\color{darkred}s_2 \ge 0 \\ &\color{darkred}s_1,\color{darkred}s_2 \in SOS1\end{align}\]



The remaining part \( \min(\color{darkred}a,\color{darkred}b) \gt \color{darkred}z\) can be modeled as: \[\color{darkred}a \gt \color{darkred}z\> {\bf and}\> \color{darkred}b \gt \color{darkred}z\] Putting things together, we have \[\begin{align}&\color{darkred}z \le \color{darkred}x \\ & \color{darkred}z \le \color{darkred}y \\ & \color{darkred}z \ge \color{darkred}x - \color{darkblue}M\cdot \color{darkred}\delta \\ & \color{darkred}z \ge \color{darkred}x - \color{darkblue}M\cdot (1-\color{darkblue}\delta) \\ & \color{darkred}a \ge \color{darkred}z + 0.0001 \\& \color{darkred}b \ge \color{darkred}z + 0.0001\\ & \color{darkred}\delta \in \{0,1\}\end{align}\]

Wanting to implement a \(\gt\) inequality for continuous variables is usually a mistake [2]. First: optimization models just don't work with \(\gt\). But also from a modeling point of view, I don't think I ever used this in a real model. For integer variables, \(\color{darkred}a\gt \color{darkred}z\) can be better viewed as \(\color{darkred}a \ge \color{darkred}z+1\). For continuous variables, you probably should not even consider \(\gt\). In this example, I just simulated \(\gt\) by a small constant.


References

 


Viewing all articles
Browse latest Browse all 809

Trending Articles