6
$\begingroup$

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$

$\endgroup$
  • $\begingroup$ If tS is a positive real number, as you say, then the IF tS = 0 THEN Y = 1 part is irrelevant because positive numbers are never zero. $\endgroup$ – RocketNuts Mar 20 at 19:51
  • $\begingroup$ He meant nonnegative. $\endgroup$ – RobPratt Mar 21 at 13:47
11
$\begingroup$

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)$$

| improve this answer | |
$\endgroup$
  • $\begingroup$ I am failing to see why the big-M is necessary and why epsilon - tS <= Y is not sufficient. Am I missing something obvious? $\endgroup$ – Renaud M. Mar 20 at 8:31
  • $\begingroup$ 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. $\endgroup$ – Clement Mar 20 at 9:53
  • $\begingroup$ I updated the answer with a recommended $M$ just now. $\endgroup$ – RobPratt Mar 20 at 12:44
  • $\begingroup$ 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.. $\endgroup$ – Clement Mar 21 at 12:12
  • $\begingroup$ Better not to divide by $\epsilon$. $\endgroup$ – RobPratt Mar 21 at 13:49
1
$\begingroup$

$$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$

| improve this answer | |
$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – RobPratt Mar 21 at 13:54
  • $\begingroup$ yes that is better. $\endgroup$ – anoop Mar 21 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.