gurobi constraint to prevent repeated solution

19 views Asked by At

i want to create multiple optimal solutions from my gurobi optimization MIP model but not using the PoolMode. instead, i have a model that creates the optimal NBA DFS lineup. one of my constraints makes sure that a player isnt in more than 1/3 of all solutions. i am trying to add another constraint that checks if the current solution already exists in another list called created_lineups. how do i do that?

i am trying this: m.addConstrs((set([x for x in player_pos_map if y[x].X == 1]) != set(i) for i in created_lineups), name='unique_lineup')

but i get the error: enter image description here

1

There are 1 answers

0
J_H On

You are complaining that set( ... ) is not hashable.

Trivially, we could use the expression tuple(sorted(set( ... )))

But you might want to examine how your higher level goals work into that.