# How to express this logical constraint for an ILP?

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

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

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$$
• Thank you so much for your answer. Do yo think expressing it like this would work : $z \leq M (x + y - 1)$ ?
• No. Consider the $(x,y)=(0,0)$ case. Aug 14, 2020 at 20:06
• 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.