I've been using the PuLP library
for a side project (daily fantasy sports) where I optimize the projected value of a lineup based on a series of constraints.
I've implemented most of them, but one constraint is that players must come from at least three separate teams.
This paper has an implementation (page 18, 4.2), which I've attached as an image:
It seems that they somehow derive an indicator variable for each team that's one if a given team has at least one player in the lineup, and then it constrains the sum of those indicators to be greater than or equal to 3.
Does anybody know how this would be implemented in PuLP
?
Similar examples would also be helpful.
Any assistance would be super appreciated!
In this case you would define a binary variable
t
that sets an upper limit of thex
variables. In python I don't like to name variables with a single letter but as I have nothing else to go on here is how I would do it in pulp.assume that the variables
lineups
,players
,players_by_team
andteams
are set somewhere else