6

I'm trying to model the following

IF $tS = 0$ THEN $Y = 1$, IF $tS \gt 0$ THEN $Y \ge 0$

$tS$ is a positive real number and $Y$ is binary.

I tried the following: $tS - \epsilon \ge -M Y$ but this doesn't work.

The optimiser always sets $ts = \epsilon$ and $Y = 0$

Clement
  • 2,252
  • 7
  • 13

2 Answers2

11

Your second if-then statement is always true because $Y$ is binary. For your first if-then statement, rewrite as its contrapositive $Y=0 \implies tS \ge \epsilon$. The following big-M constraint enforces that: $$\epsilon - tS \le MY$$ This is equivalent to what you tried. Note that $(tS,Y)=(\epsilon,0)$ is feasible, so if the solver always returns it, maybe it is optimal. As a sanity check, you could fix $tS$ to $0$ and see what happens.

Update based on a lower bound of $0$ for $tS$: you can take $M=\epsilon-0=\epsilon$, yielding $$tS\ge\epsilon(1-Y)$$

RobPratt
  • 32,006
  • 1
  • 44
  • 84
  • I am failing to see why the big-M is necessary and why epsilon - tS <= Y is not sufficient. Am I missing something obvious? – Renaud M. Mar 20 '20 at 08:31
  • Hi Rob $\$ Valid is, $0 \le tS \le \alpha, \alpha$ not known a priori; anything within that range is feasible. For these values, according to the problem's logic, $Y$ should be $1$. However, $Y=0$ doesn't make the problem infeasible. The "funny" thing is, why does CPLEX prefer to set $ts=\epsilon$, for whatever $\epsilon \le \alpha $ and $Y=0$ and not $tS=0$ and $Y=1$. $\$ As for Renaud's question, I think he is right. $M=1$ should be fine. – Clement Mar 20 '20 at 09:53
  • I updated the answer with a recommended $M$ just now. – RobPratt Mar 20 '20 at 12:44
  • The original version, ϵ−tS≤MY, is actually better. The case M=e creates problems, when tS<ϵ. Then, after trasformation we get Y ≥ 1 - (tS/ϵ), which leads to Y=1 but we should have Y ≥ 0. When M = BigM, then we get Y ≥ (ϵ - tS) / M. If in this case tS < ϵ, the (ϵ - tS) / M gets past the tolerance for 0 and thus Y ≥ 0. As an example, M = ϵ = 1E-08 drives the problem infeasible using the default settings of CPLEX.. – Clement Mar 21 '20 at 12:12
  • Better not to divide by $\epsilon$. – RobPratt Mar 21 '20 at 13:49
1

$$1 - M \cdot ts \leq Y$$

when $ts = 0$ then $1 \leq Y$

when $ts \gt 0 $ then $-M \leq Y$ and $0 \leq Y$ (because $Y$ is binary).

Here the value of $M$ must be chosen carefully by taking into consideration the decimal precision of $ts$, i.e., $\forall ts \in (0,1] \quad ts\cdot M > 1$

ooo
  • 1,589
  • 4
  • 12
  • This is algebraically equivalent to what I suggested if you set your $M$ to $1/\epsilon$. But dividing by a small number will cause numerical difficulties, so it is better to leave it in the form I had, with $\epsilon$ as a coefficient. – RobPratt Mar 21 '20 at 13:54
  • yes that is better. – ooo Mar 21 '20 at 17:28