A binary array $x = [x_1, x_2, x_3, x_4, x_5]$ with each element a binary integer variable taking values 0 or 1. One constraint: $$x_1 + x_2 + x_3 + x_4 + x_5 == 1$$ Basically one of the variables must be 1. I am trying to maximize the number of consecutive zeros in this array. The optimal result would be $x_1 = 1$ or $x_5 = 1$. In either case, it yields a result with 4 consecutive zeros.
In practice, I want to allocate some slots but leave some long-range of empty slots for future allocation. Another example is: If I have to allocate one slot with length 1 and another slot with length 2. I will allocate $x_1, x_2, x_3$ so that the remaining empty slot is $x_4, x_5$ (Or allocate $x_3,x_4,x_5$ and leave $x_1,x_2$).
Any suggestion to formulate in a way an optimization solver can solve? Or any suboptimal formulation? Thanks!