I found this related question, but that's not quite it
Is it possible to model this with integer programming:
$$A = \begin{cases} 1 & \text{if } B \geq C \geq D \\ 0 & \text{otherwise}\end{cases}$$
where $A \in \{0,1\}$, $B, D \in \mathbb R$ and $C \in \mathbb N$. We have upper and lower bounds on $B$, $C$ and $D$.
-
$\begingroup$ Since you have upper bounds on B,C, and D, can you not use the technique you have linked twice? $A_1 = 1$ iff $B \geq C,ドル and $A_2 = 1$ iff $C \geq D$. Then $A = A_1\cdot A_2$. $\endgroup$MrHug– MrHug2019年08月16日 11:53:04 +00:00Commented Aug 16, 2019 at 11:53
-
$\begingroup$ I can only have linear constraints, therefore it is not possible to calculate $A = A_1 * A_2$ $\endgroup$DaWit– DaWit2019年08月16日 12:53:42 +00:00Commented Aug 16, 2019 at 12:53
-
$\begingroup$ Then how about $A_1 + A_2 \geq 2$? $\endgroup$MrHug– MrHug2019年08月16日 13:15:13 +00:00Commented Aug 16, 2019 at 13:15
-
$\begingroup$ You can implement any comparisons you like with big M trick. blog.adamfurmanek.pl/2015/09/12/ilp-part-4 $\endgroup$user1543037– user15430372019年08月16日 15:40:36 +00:00Commented Aug 16, 2019 at 15:40
1 Answer 1
Thanks MrHug, I should have thought of this myself after your first hint.
after using the solution from here twice with the resulting binaries $A_1$ and $A_2$ we can form another problem: $$A = \begin{cases} 1 & \text{if } A_1+A_2 \geq 2 \\ 0 & \text{otherwise}\end{cases}$$
This one can be solved with a little hint from there:
$$A_1 + A_2 \geq 2 - M * (1-A) \\ 2 - \epsilon \geq A_1 + A_2 - M * A$$
where $M$ is a big value and $\epsilon$ is a very small value (above 0, below 1).
It's a bit unfortunate that so many variables are needed as $A$, $A_1$ and $A_2$ are cubic in my case. But I'm glad about this solution.
Explore related questions
See similar questions with these tags.