Setting Pyomo Constraints to list of values

23 Views Asked by At

I have a minimization model where individuals are getting grouped by how they ranked a selection.

I would like the group sizes to be equal to 0,3,4,5. This is what I tried a series of "or" statements, but it didn't like that.

for title in Title:
    model.cons.add(sum(model.x[name, title] for name in Name) == 0 or
                   sum(model.x[name, title] for name in Name) == 3 or
                   sum(model.x[name, title] for name in Name) == 4 or
                   sum(model.x[name, title] for name in Name) == 5)

Does anyone have any recommendations?

0

There are 0 best solutions below