Having an integer variable $D \in \{-k,-k+1,...,-1,0,1,...,k-1,k\}$, how do I make it affect another variable only when $D = 0$?
Specifically, I have a binary variable $U$ in my model. I want it to be set to $1$ when $D = 0$, but leave it free in other cases.
What constraint or constraints can I add in order to achieve this?
This is not so easy with a variable $D$ that can be positive and negative. We could do: $$ U + |D| \ge 1 $$
To linearize this we can use a variable splitting technique. Something like: $$\begin{align} &D_{plus} \ge 0 \\ &D_{min} \ge 0 \\ &D = D_{plus}-D_{min} \\ &D_{abs} = D_{plus}+D_{min} \\ &D_{plus} \le k \delta \\ &D_{min} \le k (1-\delta) \\ & \delta \in \{0,1\}\\ & U \in \{0,1\}\\ &U + D_{abs} \ge 1 \end{align}$$