I have the decision variable $X_{iz}$

And I have two parameters $T_i\in\{0,1\}$ and $IT_z\in\{0,1,2\}$. I can only assign $i$ to $z$ if the following holds:

  • for $T_i=0$, $IT_z$ needs to be $0$ or $2$
  • for $T_i=1$, $IT_z$ needs to be $1$ or $2$
  • So for every value of $T_i$, a value of $2$ for $IT_z$ must satisfy the constraint
  • Or $T_i$ needs to be equal to $IT_z$

I cannot seem to figure out how to make a valid constraint for this problem, any tips?

  • $\begingroup$ Do you have 2 $T$ and 3 $IT$ or do you have one $T$ and one $IT$ where $T$ can be $\{0, 1\}$ and $IT$ can be $\{0, 1, 2\}$. If the latter, then you don't need the indices. Just say $T \in \{0,1\}$ and $IT \in \{0,1,2\}$ $\endgroup$
    – EhsanK
    Nov 22, 2019 at 14:50
  • 1
    $\begingroup$ No I have multiple $i$'s and multiple $z$'s, each has their own value of $T\in\{0,1\}$ and $IT\in\{0,1,2\}$. $\endgroup$ Nov 22, 2019 at 14:53
  • 1
    $\begingroup$ Check this answer from Decision Variable Value from a Set $\endgroup$
    – EhsanK
    Nov 22, 2019 at 15:01

2 Answers 2


For the new problem description, it seems like you just want to fix $X_{i,z}=0$ for some disallowed $(i,z)$ pairs. An even better approach is to avoid defining $X_{i,z}$ in those cases.


Introduce a new binary variable $z_i$ and linear constraints: \begin{align} -z_i \le \text{IT}_i - \text{T}_i &\le 2 z_i \\ \text{IT}_i &\ge 2 z_i \end{align} If $z_i=0$ then $\text{IT}_i = \text{T}_i$. If $z_i=1$ then $\text{IT}_i \ge 2$, hence $=2$.

  • $\begingroup$ I think this is not correct, because when $T_i=0$ and $IT_i=1$ the constraint also satisfies. And this should not be the case. That is what I am struggling with. $\endgroup$ Nov 22, 2019 at 14:25
  • $\begingroup$ Sorry, I misread $0$ or $2$ as $0$ to $2$. $\endgroup$
    – RobPratt
    Nov 22, 2019 at 14:54
  • $\begingroup$ Corrected just now. $\endgroup$
    – RobPratt
    Nov 22, 2019 at 15:04
  • $\begingroup$ Note: all your indices are of type $i$, but actually $IT$ has index $z$. Is the $z$ (you introduced) of type $i$ or of type $z$? I tried some things now, but the model seems infeasible $\endgroup$ Nov 22, 2019 at 16:44
  • 2
    $\begingroup$ Hmm, you changed the question after I posted my answer, and I don't quite understand the new question. My binary variable $z_i$ has nothing to do with your new index $z$. Is $X_{i,z}$ a binary decision variable? Are $\text{T}_i$ and $\text{IT}_{z}$ now decision variables or constants? $\endgroup$
    – RobPratt
    Nov 22, 2019 at 18:18

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.