Skip to main content
added 138 characters in body
Source Link
RobPratt
  • 48.8k
  • 3
  • 25
  • 63

You want to enforce two implications: \begin{align} y = 1 &\implies x \le c \tag1\label1 \\ y = 0 &\implies x > c \tag2\label2 \end{align}\begin{align} x \le c &\implies y = 1 \\ x > c &\implies y = 0 \end{align} Equivalently, you want to enforce their contrapositives: \begin{align} y = 0 &\implies x > c \tag1\label1 \\ y = 1 &\implies x \le c \tag2\label2 \end{align} Assume $L_c \le c \le U_c$ for constants $L_c$ and $U_c$. As you suggested, \eqref{12} can be enforced by a big-M constraint: $$x - c \le (x-L_c)(1-y)$$ If you introduce a small constant tolerance $\epsilon>0$, \eqref{21} can also be enforced by a big-M constraint: $$c - x + \epsilon \le (U_c-x+\epsilon)y$$


Another way to think about this is that you want $x \le c \le U_c$ if $y=1$ and $L_c \le c \le x-\epsilon$ if $y=0$. So combine these two constraints as $$xy + L_c(1-y) \le c \le U_c y + (x-\epsilon)(1-y)$$

You want to enforce two implications: \begin{align} y = 1 &\implies x \le c \tag1\label1 \\ y = 0 &\implies x > c \tag2\label2 \end{align} Assume $L_c \le c \le U_c$ for constants $L_c$ and $U_c$. As you suggested, \eqref{1} can be enforced by a big-M constraint: $$x - c \le (x-L_c)(1-y)$$ If you introduce a small constant tolerance $\epsilon>0$, \eqref{2} can also be enforced by a big-M constraint: $$c - x + \epsilon \le (U_c-x+\epsilon)y$$


Another way to think about this is that you want $x \le c \le U_c$ if $y=1$ and $L_c \le c \le x-\epsilon$ if $y=0$. So combine these two constraints as $$xy + L_c(1-y) \le c \le U_c y + (x-\epsilon)(1-y)$$

You want to enforce two implications: \begin{align} x \le c &\implies y = 1 \\ x > c &\implies y = 0 \end{align} Equivalently, you want to enforce their contrapositives: \begin{align} y = 0 &\implies x > c \tag1\label1 \\ y = 1 &\implies x \le c \tag2\label2 \end{align} Assume $L_c \le c \le U_c$ for constants $L_c$ and $U_c$. As you suggested, \eqref{2} can be enforced by a big-M constraint: $$x - c \le (x-L_c)(1-y)$$ If you introduce a small constant tolerance $\epsilon>0$, \eqref{1} can also be enforced by a big-M constraint: $$c - x + \epsilon \le (U_c-x+\epsilon)y$$


Another way to think about this is that you want $x \le c \le U_c$ if $y=1$ and $L_c \le c \le x-\epsilon$ if $y=0$. So combine these two constraints as $$xy + L_c(1-y) \le c \le U_c y + (x-\epsilon)(1-y)$$

added 226 characters in body
Source Link
RobPratt
  • 48.8k
  • 3
  • 25
  • 63

You want to enforce two implications: \begin{align} y = 1 &\implies x \le c \tag1\label1 \\ y = 0 &\implies x > c \tag2\label2 \end{align} Assume $L_c \le c \le U_c$ for constants $L_c$ and $U_c$. As you suggested, \eqref{1} can be enforced by a big-M constraint: $$x - c \le (x-L_c)(1-y)$$ If you introduce a small constant tolerance $\epsilon>0$, \eqref{2} can also be enforced by a big-M constraint: $$c - x + \epsilon \le (U_c-x+\epsilon)y$$


Another way to think about this is that you want $x \le c \le U_c$ if $y=1$ and $L_c \le c \le x-\epsilon$ if $y=0$. So combine these two constraints as $$xy + L_c(1-y) \le c \le U_c y + (x-\epsilon)(1-y)$$

You want to enforce two implications: \begin{align} y = 1 &\implies x \le c \tag1\label1 \\ y = 0 &\implies x > c \tag2\label2 \end{align} Assume $L_c \le c \le U_c$ for constants $L_c$ and $U_c$. As you suggested, \eqref{1} can be enforced by a big-M constraint: $$x - c \le (x-L_c)(1-y)$$ If you introduce a small constant tolerance $\epsilon>0$, \eqref{2} can also be enforced by a big-M constraint: $$c - x + \epsilon \le (U_c-x+\epsilon)y$$

You want to enforce two implications: \begin{align} y = 1 &\implies x \le c \tag1\label1 \\ y = 0 &\implies x > c \tag2\label2 \end{align} Assume $L_c \le c \le U_c$ for constants $L_c$ and $U_c$. As you suggested, \eqref{1} can be enforced by a big-M constraint: $$x - c \le (x-L_c)(1-y)$$ If you introduce a small constant tolerance $\epsilon>0$, \eqref{2} can also be enforced by a big-M constraint: $$c - x + \epsilon \le (U_c-x+\epsilon)y$$


Another way to think about this is that you want $x \le c \le U_c$ if $y=1$ and $L_c \le c \le x-\epsilon$ if $y=0$. So combine these two constraints as $$xy + L_c(1-y) \le c \le U_c y + (x-\epsilon)(1-y)$$

Source Link
RobPratt
  • 48.8k
  • 3
  • 25
  • 63

You want to enforce two implications: \begin{align} y = 1 &\implies x \le c \tag1\label1 \\ y = 0 &\implies x > c \tag2\label2 \end{align} Assume $L_c \le c \le U_c$ for constants $L_c$ and $U_c$. As you suggested, \eqref{1} can be enforced by a big-M constraint: $$x - c \le (x-L_c)(1-y)$$ If you introduce a small constant tolerance $\epsilon>0$, \eqref{2} can also be enforced by a big-M constraint: $$c - x + \epsilon \le (U_c-x+\epsilon)y$$