3
$\begingroup$

I am trying to write an ILP for a problem but I have this logical constraint and I'm stuck.

In my model I have:

two binary variables: $x$ and $y$

One Integer variable: $z$

The logical constraint I am trying to write is:

if $x = 1$ and $y = 1$ then $z \le Mx$, else $z = 0$

Thank you for your help.

$\endgroup$
2
  • $\begingroup$ Oh, I think I was assuming $z \ge 0$. Is that correct? $\endgroup$
    – RobPratt
    Aug 14, 2020 at 22:10
  • $\begingroup$ yes that is correct but also $z$ has an upper bound Big-M , so $0 \leq z \leq M$ . $\endgroup$
    – che
    Aug 14, 2020 at 22:33

1 Answer 1

6
$\begingroup$

You always want $$z \ge 0 \tag1$$ You want $x = 0 \implies z \le 0$: $$z \le M x \tag2$$ Similarly, you want $y = 0 \implies z \le 0$: $$z \le M y \tag3$$

$\endgroup$
4
  • $\begingroup$ Thank you so much for your answer. Do yo think expressing it like this would work : $ z \leq M (x + y - 1) $ ? $\endgroup$
    – che
    Aug 14, 2020 at 19:08
  • 2
    $\begingroup$ No. Consider the $(x,y)=(0,0)$ case. $\endgroup$
    – RobPratt
    Aug 14, 2020 at 20:06
  • $\begingroup$ Hello again , regarding the constraint that I have asked about in my previous question, I have a slight modification. I want to write the following constraint : let z be an integer variable, and t a binary variable, and a big-M. z is $0\leq z \leq M$. the logical constraint is as following : if $ z \leq M$ and $z > 0 \Rightarrow t = 1 $ ; and if $ z = 0 \Rightarrow t = 0$. Is this $ z \leq M t $ sufficient? the t and z variables are not in my objective function but , variable t is connected to another variable in the objective function? Thank you very much, I appreciate your help. $\endgroup$
    – che
    Aug 15, 2020 at 17:14
  • $\begingroup$ Please start a new post for this question. $\endgroup$
    – RobPratt
    Aug 15, 2020 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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