I am working on an MILP model currently. I want to ensure that the consecutive presence of any variable within a specified time period T cannot exceed a certain limit, even if that would be optimal. In this specific case, the variable is a unit of equipment and the time limit its lifetime. So I must ensure that the continuous presence of the equipment within a 30 year period has to be limited to its lifetime of 10 years.
I was thinking of this approach: ${\sum_{i=1}^{I}\sum_{t=1}^{T}n_{it}} <= LT_i $, where $n_{it}$ is the equipment and $LT_i$ its lifetime, but this only ensures that the total number of times the variable appears within the period T will not be greater than its lifetime and not what I described above. I have been trying to find a solution for quite some time now so any help is welcome!
I'm still unclear on parts of this, but I might understand enough to provide the answer you need. You need to introduce binary variables $z_{it}$, where $z_{it}=1$ if and only if $n_{it} > 0$. Assuming that there is a constant a priori upper bound $N_{it}$ for each $n_{it}$, the connection between $z$ and $n$ is established by the constraints $z_{it}\le n_{it} \le N_{it} z_{it}$ for all pairs $i,t$. With that in place, your limit on consecutive nonzero values is enforced via constraints $$\sum_{t=\tau}^{\tau+LT_{i}}z_{it}\le LT_{i}$$for all $i$ and for all start times $\tau$ that make sense (meaning the upper limit of summation does not exceed the horizon of the problem).