def get_sg_alternates(roster, data, cap, roster_cap, position_limits): """Get alternates to optimal roster by removing each player, re-running optimizer. First we remove MVP player from flex consideration and re-run optimizer with that data. Then remove flex players from MVP consideration.""" rosters = [roster] for player in roster: new_data = [p for p in data if p != player] roster = opti.find_optimal(new_data, cap, roster_cap, position_limits, None) if roster: roster.sort(key=lambda x: x[0]) rosters.append(roster) # remove MVP from Flx consideration data2 = [p for p in new_data if p[1] != roster[0][1].replace('MVP', '')] roster2 = opti.find_optimal(data2, cap, roster_cap, position_limits, None) if roster2: rosters.append(roster2) # remove Flx from MVP consideration for plyr in roster: data3 = [p for p in new_data if p[1] != f'{plyr[1]}MVP'] roster3 = opti.find_optimal(data3, cap, roster_cap, position_limits, None) rosters.append(roster3) rosters = uni.unique_rosters(rosters) valid_rosters = check_duplicates(rosters) return valid_rosters
def get_alternates(roster, data, cap, roster_cap, position_limits): """Get alternates to optimal roster by removing each player, re-running optimizer, then repeating for a second player roster. Can give up to 91 unique rosters. Many will be duplicates and these are removed by unique roster function before returning.""" rosters = [roster] for player in roster: new_data = [p for p in data if p != player] roster = opti.find_optimal(new_data, cap, roster_cap, position_limits, None) if roster: rosters.append(roster) for player2 in roster: data2 = [p for p in new_data if p != player2] roster2 = opti.find_optimal(data2, cap, roster_cap, position_limits, None) if roster2: rosters.append(roster2) rosters = unique_rosters(rosters) return rosters
def __init__(self, projections, remove_teams, remove_players, include): self.salaries = 'C:/DF/MLB/MLB_CSVs/singleFD.csv' self.cap = 35000 self.roster_cap = 5 self.position_limits = [["1B", 0, 5], ["2B", 0, 5], ["3B", 0, 5], ["OF", 0, 5], ["P", 0, 5], ["SS", 0, 5]] self.data = fd.clean(projections, self.salaries, remove_teams, remove_players, include) self.optimal = opti.find_optimal(self.data, self.cap, self.roster_cap, self.position_limits, None)
def __init__(self, projections, remove_teams, remove_players, include): self.salaries = fd.get_csv() self.cap = 60000 self.roster_cap = 9 self.position_limits = [['PG', 2, 2], ['SG', 2, 2], ['SF', 2, 2], ['PF', 2, 2], ['C', 1, 1]] # Clean and combine salary and projection csvs self.data = fd.clean(projections, self.salaries, remove_teams, remove_players, include) # Optimized lineup self.optimal = opti.find_optimal(self.data, self.cap, self.roster_cap, self.position_limits, None)
def __init__(self, projections, remove_teams, remove_players, include): self.salaries = 'C:/DF/NBA/NBA_CSVs/Yahoo_DF_player_export.csv' self.cap = 200 self.roster_cap = 8 self.position_limits = [['PG', 1, 3], ['SG', 1, 3], ['SF', 1, 3], ['PF', 1, 3], ['C', 1, 2]] # Clean and combine salary and projection csvs self.data = ya.clean(projections, self.salaries, remove_teams, remove_players, include) # Optimized lineup self.optimal = opti.find_optimal(self.data, self.cap, self.roster_cap, self.position_limits, None)
def __init__(self, projections, remove_players, remove_teams, include): self.salaries = 'C:/DF/MLB/MLB_CSVs/singleDK.csv' self.cap = 50000 self.roster_cap = 6 self.position_limits = [['MVP', 1, 1], ["1B", 0, 5], ["2B", 0, 5], ["3B", 0, 5], ["C", 0, 5], ["OF", 0, 5], ["P", 0, 5], ["SS", 0, 5]] # Clean and combine salary and projection csvs self.data = dk.clean(projections, self.salaries, remove_teams, remove_players, include) self.data = mvps.fix_mvps(self.data) # Optimized lineup self.optimal = opti.find_optimal(self.data, self.cap, self.roster_cap, self.position_limits, None)
def __init__(self, projections, remove_players, remove_teams, include): self.salaries = 'C:/DF/NFL/NFL_CSVs/singleFD.csv' self.cap = 60000 self.roster_cap = 5 self.position_limits = [ ['QB', 0, 5], ['RB', 0, 5], ['WR', 0, 5], ['TE', 0, 5], ['D', 0, 5] ] # Clean and combine salary and projection csvs self.data = fd.clean(projections, self.salaries, remove_teams, remove_players, include) # Optimized lineup self.optimal = opti.find_optimal(self.data, self.cap, self.roster_cap, self.position_limits, None)
def __init__(self, salaries, projections, remove_teams, remove_players, include): self.cap = 50000 self.roster_cap = 9 self.position_limits = [ ['QB', 1, 1], ['RB', 2, 3], ['WR', 3, 4], ['TE', 1, 2], ['DST', 1, 1] ] # Clean and combine salary and projection csvs self.data = dk.clean(salaries, projections, remove_teams, remove_players, include) # Optimized lineup self.optimal = opti.find_optimal(self.data, self.cap, self.roster_cap, self.position_limits)
def __init__(self, projections, remove_teams, remove_players, include): self.salaries = 'C:/DF/MLB/MLB_CSVs/Yahoo_DF_player_export.csv' self.cap = 200 self.roster_cap = 10 self.position_limits = [["1B", 1, 1], ["2B", 1, 1], ["3B", 1, 1], ["C", 1, 1], ["OF", 3, 3], ["P", 2, 2], ["SS", 1, 1]] self.team_limits = [['ARI', 5], ['ATL', 5], ['BAL', 5], ['BOS', 5], ['CHC', 5], ['CWS', 5], ['CIN', 5], ['CLE', 5], ['COL', 5], ['DET', 5], ['FLA', 5], ['HOU', 5], ['KAN', 5], ['LAA', 5], ['LAD', 5], ['MIL', 5], ['MIN', 5], ['NYM', 5], ['NYY', 5], ['OAK', 5], ['PHI', 5], ['PIT', 5], ['SD', 5], ['SF', 5], ['SEA', 5], ['STL', 5], ['TB', 5], ['TEX', 5], ['TOR', 5], ['WAS', 5]] self.data = ya.clean(projections, self.salaries, remove_teams, remove_players, include) self.optimal = opti.find_optimal(self.data, self.cap, self.roster_cap, self.position_limits, self.team_limits)
def __init__(self, projections, remove_teams, remove_players, include): self.salaries = fd.get_csv() self.cap = 35000 self.roster_cap = 9 self.position_limits = [["1B", 1, 2], ["2B", 1, 2], ["3B", 1, 2], ["OF", 3, 4], ["P", 1, 1], ["SS", 1, 2]] self.team_limits = [['ARI', 4], ['ATL', 4], ['BAL', 4], ['BOS', 4], ['CHC', 4], ['CWS', 4], ['CIN', 4], ['CLE', 4], ['COL', 4], ['DET', 4], ['FLA', 4], ['HOU', 4], ['KAN', 4], ['LAA', 4], ['LOS', 4], ['MIL', 4], ['MIN', 4], ['NYM', 4], ['NYY', 4], ['OAK', 4], ['PHI', 4], ['PIT', 4], ['SD', 4], ['SF', 4], ['SEA', 4], ['STL', 4], ['TB', 4], ['TEX', 4], ['TOR', 4], ['WAS', 4]] self.data = fd.clean(projections, self.salaries, remove_teams, remove_players, include) self.optimal = opti.find_optimal(self.data, self.cap, self.roster_cap, self.position_limits, self.team_limits)