Timeline for How to model logic constraint: $y=1$ if $a\le x\le b$ and $y=0$ otherwise?
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 20, 2022 at 19:40 | comment | added | RobPratt | Yes, or you can just replace each $y^-$ with $1-y$ and omit the equality constraint. | |
Oct 20, 2022 at 18:30 | comment | added | GuanghuiLiu | I modify your code as below $$\ell y^- + a y \le x \le (a - \epsilon) y^- + My \\ y^- + y = 1$$, where $ M $ is an upper bound of $ x, $ and $ y^-, y $ are binary. Is it correct? | |
Oct 20, 2022 at 18:20 | comment | added | GuanghuiLiu | Hi Rob: I would like to get your expert suggestions on the one-side variant: $ y $ is binary 0 or 1. $ x $ is a continuous variable. $$ y = \begin{cases} 1, & \text{ if } x \geq a \\ 0, & \text{ if } x <a \end{cases} $$ using your $\epsilon $ method. | |
Oct 20, 2022 at 18:14 | comment | added | RobPratt | Related: or.stackexchange.com/questions/6641/… | |
Oct 20, 2022 at 17:19 | vote | accept | GuanghuiLiu | ||
Oct 20, 2022 at 17:19 | comment | added | GuanghuiLiu | Your solution is amazing! It's awesome and admirable - 2 lines of your codes solved the problem. I tried to find any holes with your solution but ended up with being convinced after considering all sorts of case work with your solution. Thank you so much for your very intelligent and efficient solution! | |
Oct 20, 2022 at 16:29 | history | edited | RobPratt | CC BY-SA 4.0 |
added 51 characters in body
|
Oct 20, 2022 at 16:02 | history | answered | RobPratt | CC BY-SA 4.0 |