I'm working on a problem and I can't seem to find an easy solution to it. It's about an optimization problem, concerning a time series.
I have a binary variable $\alpha_t$ for $t \in [0, 24[$. I also have an extra constraint, which states that $$\sum_{t=0}^{23} \alpha_t \geq 14.$$ The problem is that I want to add an extra constraint that if a certain $\alpha_t = 1$, then either $$\alpha_{t-1} = \alpha_{t+1} = 1$$ or $$\alpha_{t-1} = \alpha_{t-2} = 1$$ or $$\alpha_{t+1} = \alpha_{t+2} = 1, $$ i.e. at least 3 consecutive times $\alpha$ needs to be 1. It can be 4 times, it can be 5, but it has to be at least 3 times.
The most intuitive idea is probably this: $$\alpha_t = 1 \Rightarrow \alpha_t + \alpha_{t+1} + \alpha_{t + 2} = 3,$$ but from a certain $t$, this will result that all $\alpha_t = 1$.
I also tried big M constraints, but for larger consecutive times ( $\geq 3)$, this becomes almost impossible to write down/implement.
One simple way to enforce a run length of at least three, is to forbid patterns
010and0110. This can be modeled as:$$ -x_t + x_{t+1} - x_{t+2} \le 0 $$
and
$$ -x_t + x_{t+1} + x_{t+2} - x_{t+3} \le 1 $$
A little bit of thought is needed to decide what to do at the borders, especially the first time period.
A different approach is detailed here.