i have this constraint right here, which is not linear. How would i linearize such a product. $number_t$ is a positive integer and $new_t$ and $reset_t$ are binary.

$$number_t = (number_{t-1}+new_t)\cdot (1-reset_t)$$


1 Answer 1


Some comments already hinted at questions that give you the answer. In your specific example, this translates to the following:

\begin{align} 0 \leq number_t \leq (number_{t−1}+new_t) \newline number_t \geq (number_{t−1}+new_t)-reset_tM \newline number_t \leq M(1−reset_t) \end{align}

If $reset_t = 0$, through the first and second constraint we force $number_t$ to take value $number_{t-1}+new_t$. If $reset_t=1$, through the first and third constraint, we force $number_t$ to be 0. Where $M$ is a large enough number.

  • $\begingroup$ Thank you @PeterD. Assuming i also have $number_t = (number_{t-1}+new_t)\cdot (1-reset_t)-c_t + b_t$, which of both are also binary, how would i need to modify the constraints then? Thanks in advance? $\endgroup$
    – Uni ewr
    Feb 13 at 14:38
  • 1
    $\begingroup$ Would it work if, for example, I replace $number_t$ with $nr_t$ in your solution and then calculate $number_t=nr_t-c_t+b_t$? $\endgroup$
    – Uni ewr
    Feb 13 at 15:17
  • $\begingroup$ @Uniewr yes that would work. $\endgroup$
    – PeterD
    Feb 13 at 19:29

Your Answer

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

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