Skip to content

Instantly share code, notes, and snippets.

@sertalpbilal
Last active March 4, 2022 19:20
Show Gist options
  • Save sertalpbilal/3135a08cde74b590c237b18d95ea744c to your computer and use it in GitHub Desktop.
Save sertalpbilal/3135a08cde74b590c237b18d95ea744c to your computer and use it in GitHub Desktop.
Bench boost changes (replace lines 244 to 255)
bb_gw = 29
model.add_constraints((so.expr_sum(lineup[p,w] for p in players) == 11 + (4 if bb_gw == w else 0) for w in gameweeks), name='lineup_count')
model.add_constraints((so.expr_sum(bench[p,w,0] for p in players if player_type[p] == 1) == 1 - (1 if bb_gw == w else 0) for w in gameweeks), name='bench_gk')
model.add_constraints((so.expr_sum(bench[p,w,o] for p in players) == 1 - (1 if bb_gw == w else 0) for w in gameweeks for o in [1,2,3]), name='bench_count')
model.add_constraints((so.expr_sum(captain[p,w] for p in players) == 1 for w in gameweeks), name='captain_count')
model.add_constraints((so.expr_sum(vicecap[p,w] for p in players) == 1 for w in gameweeks), name='vicecap_count')
model.add_constraints((lineup[p,w] <= squad[p,w] for p in players for w in gameweeks), name='lineup_squad_rel')
model.add_constraints((bench[p,w,o] <= squad[p,w] for p in players for w in gameweeks for o in order), name='bench_squad_rel')
model.add_constraints((captain[p,w] <= lineup[p,w] for p in players for w in gameweeks), name='captain_lineup_rel')
model.add_constraints((vicecap[p,w] <= lineup[p,w] for p in players for w in gameweeks), name='vicecap_lineup_rel')
model.add_constraints((captain[p,w] + vicecap[p,w] <= 1 for p in players for w in gameweeks), name='cap_vc_rel')
model.add_constraints((lineup[p,w] + so.expr_sum(bench[p,w,o] for o in order) <= 1 for p in players for w in gameweeks), name='lineup_bench_rel')
model.add_constraints((lineup_type_count[t,w] == [type_data.loc[t, 'squad_min_play'], type_data.loc[t, 'squad_max_play'] + (1 if bb_gw == w else 0)] for t in element_types for w in gameweeks), name='valid_formation')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment