3
$\begingroup$

How can I formulate the following conditional constraint to a linear constraint using indicator variables? Please note that all variables are continuous and $c \ge 0$

$\text{1: if} \ c=0 \ \& \ w \geq 0 \quad \text{then} \; u=w; d=0\\ \text{2: if} \ c=0 \ \& \ w < 0 \quad \text{then} \; u=0; d=0\\ \text{3: if} \ c > 0 \ \& \ w \geq c \quad \text{then} \ u=w-c; d=0 \\ \text{4: if} \ c>0 \ \& \ w<c \quad \text{then} \ d=0, d=c-w\\$

The decision variables d and u are directly appeared with a negative and positive coefficients in the objective function. Also, the abs of coefficient d is greater than the coefficient of u $(e.g. -40 d + 30 u)$. Therefore, the following constraint satisfies conditions 1,3 and 4.

$c-w - d + u = 0;\\ c, d, u \geq 0;\\$

Nevertheless, I am still wonder how to include condition 2 as a linear constraint in my model.

$\endgroup$
5
  • 1
    $\begingroup$ I think first you should modify the conditions a little bit, e.g., $c=0, w=0$ is common in conditions 1 and 2. Also for conditions 3 and 4 when $c>0, w=0$. $\endgroup$
    – Mostafa
    May 13 '20 at 13:25
  • $\begingroup$ Applied your comment and added my try. @Mostafa $\endgroup$
    – SAH
    May 13 '20 at 14:32
  • $\begingroup$ You still have some overlapping cases. Maybe restrict 4 to have $c>0$? $\endgroup$
    – RobPratt
    May 13 '20 at 15:14
  • $\begingroup$ I restated the conditions and I think they have no overlap now. @RobPratt $\endgroup$
    – SAH
    May 13 '20 at 15:32
  • 1
    $\begingroup$ Yes, but you could simplify by merging 1 and 3 to $c\ge 0$. $\endgroup$
    – RobPratt
    May 13 '20 at 15:35
5
$\begingroup$

Here's a big-M formulation that does not depend on the objective. (Minimization with positive objective coefficients for $u$ and $d$ could be exploited, but you don't have that here.) Let $\epsilon > 0$ be a small tolerance for positivity of $c$. Let $\underline{c}$ and $\overline{c}$ be bounds for $c$, with similar notation for $w$, $u$, and $d$. Let binary decision variable $x$ indicate whether $c>0$, and let binary decision variable $y$ indicate whether $c>w$. The constraints are: \begin{align} \epsilon x \le c &\le \overline{c} x \\ 0 \le d &\le \overline{d} x \\ c-w &\le (\overline{c}-\underline{w}) y \\ 0 \le u - (w-c) &\le (0-\underline{w}+\overline{c})y \\ 0 \le d &\le \overline{d} y \\ w-c &\le (\overline{w}-\underline{c})(1-y) \\ 0 \le u &\le \overline{u} (1-y) \\ (0-\overline{c}+\underline{w})(2-x-y) \le d - (c-w) &\le (0-\underline{c}+\overline{w})(2-x-y) \end{align} Just check the four cases for $(x,y)$.

$\endgroup$
4
  • $\begingroup$ Thank you. But there is a problem. This set of constrains doesn't let c to be zero in any case. This is due to the left hand side of the last constraint d-c+w >= 0. let say c= 0 and w = -1. We expect to get d=0 (second condition). However d-0-1>= 0 is only satisfied by d=1 or larger (however d=1 is optimal). Therefore the value of x is equal to 1 due to the constraint 2. As a result x is always 1 and do not let c to be zero. In the optimal case c will be set to epsilon and not zero. @RobPratt $\endgroup$
    – SAH
    May 13 '20 at 19:14
  • 1
    $\begingroup$ Yes, that constraint should have been active only when $x=y=1$. Corrected now. $\endgroup$
    – RobPratt
    May 13 '20 at 19:51
  • $\begingroup$ Thank you. Would you introduce some references to learn this technique. $\endgroup$
    – SAH
    May 13 '20 at 21:29
  • 1
    $\begingroup$ H. Paul Williams, Model Building in Mathematical Programming. Also, Raman and Grossmann, Relation between MILP modelling and logical inference for chemical process synthesis $\endgroup$
    – RobPratt
    May 13 '20 at 21:41

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.