# How can one model a binary variable?

I am looking for the formulation of a constraint that does the following. I want to introduce a new binary variable $$\kappa_{it}$$ that takes the value 1 if the sum of the other binary variable $$\omega_{it}$$ is greater than or equal to the number $$N_{\max}$$ by time $$t$$. Otherwise, it is to become zero. My suggestion would be:

$$\sum_{k=1}^{t}\omega_{ik}\le N_{\max} + M \cdot \kappa_{it}\\ N_{\max}+\mu\le\sum_{k=1}^{t}\omega_{ik}+\left( 1-\kappa_{it} \right) \cdot M$$

where $$\mu$$ is a small value. Is that correct?

• This looks correct to me. A small suggestion. Since you are dealing with all the binaries, $\mu$ can just be 1. Jul 4 at 11:55
• The text of the question says $\kappa_{it}$ should be 1 if the sum is greater than or equal to $N_{max}.$ The formulation (with $\mu=1$) would be for greater than $N_{max}.$
– prubin
Jul 4 at 15:19
• Related Oct 5 at 13:09

You want to enforce $$\sum_{k=1}^t \omega_{ik} \ge N_{max} \iff \kappa_{it}=1$$ Or equivalently \begin{align} \left( \kappa_{it}=1 \implies \sum_{k=1}^t \omega_{ik} \ge N_{max} \right) \wedge \left( \kappa_{it}=0 \implies \sum_{k=1}^t \omega_{ik} \le N_{max}-1\right) \end{align}
You can enforce this with big-M constraints: $$N_{max}\kappa_{it} \le \sum_{k=1}^t \omega_{ik} \le N_{max}-1+(t+1-N_{max})\kappa_{it}$$