Skip to content

Commit

Permalink
Do not iterate when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBrostoff committed Dec 27, 2023
1 parent cbfd954 commit 99fadf8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions draftfast/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def __init__(
raise PlayerBanAndLockException(player.name)

self.teams = set([p.team for p in self.players])
self.matchups = set([p.matchup for p in self.players])
if self.min_matchups:
self.matchups = set([p.matchup for p in self.players])
self.objective = self.solver.Objective()
self.objective.SetMaximization()

Expand Down Expand Up @@ -413,7 +414,7 @@ def _set_min_matchups(self):
generally two for classic sports
"""
matchups = []
if self.min_matchups > 1:
if self.min_matchups and self.min_matchups > 1:
for matchup in self.matchups:
if matchup:
matchup_var = self.solver.IntVar(0, 1, matchup)
Expand Down
7 changes: 6 additions & 1 deletion draftfast/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,14 @@ def __init__(
no_defense_against_captain=False,
showdown_teams=None,
min_teams=2,
min_matchups=1,
min_matchups=None,
custom_rules=None,
):
"""
A note on defaults:
- min_teams 2 - this constraint is common across Classic and Showdown.
"""
self.stacks = stacks
self.existing_rosters = existing_rosters or []
self.force_combo = force_combo
Expand Down

0 comments on commit 99fadf8

Please sign in to comment.