I am totally new to pulp, and am wondering that if I need to optimize the following:
x = pulp.LpVariable.dicts("Volume", range(0, 7), cat='Binary')
where whenever there is a 0, it needs to be at least 3 of them.
so the solution can be [0,0,0,0,0,0,1], [0,0,0,1,0,0,0], [1,1,1,0,0,0,1] but not [1,0,1,0,1,0,0].
I tried to add a constraint as follows:
prob += min([len(list(g)) for k, g in itertools.groupby(x.values()) if k == 0]) >= 3
but it didn't work.
How can I formulate that?