Skip to content

Instantly share code, notes, and snippets.

@swanson
Created December 8, 2016 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swanson/2081c9031ac9d5574e4e8d9ec9ae95d8 to your computer and use it in GitHub Desktop.
Save swanson/2081c9031ac9d5574e4e8d9ec9ae95d8 to your computer and use it in GitHub Desktop.
for position, min_limit, max_limit in POSITION_LIMITS:
position_cap = solver.Constraint(min_limit, max_limit)
for i, player in enumerate(all_players):
if position == player.position:
position_cap.SetCoefficient(variables[i], 1)
# add this section
flex_spot = solver.Constraint(1, 1)
for i, player in enumerate(all_players):
if player.position == "SG" or player.position == "PG":
flex_spot.SetCoefficient(variables[i], 1)
# and make sure to tweak ROSTER_SIZE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment