DimaKudosh / pydfs-lineup-optimizer

Daily Fantasy Sports lineup optimzer for all popular daily fantasy sports sites
MIT License
424 stars 157 forks source link

Using GameStack and TeamStack together #406

Open austinjohnson opened 1 year ago

austinjohnson commented 1 year ago

I am using GameStack and TeamStack together. I aim to create a 5-3 stack from the same game. Here is my code:

from pydfs_lineup_optimizer import Site, Sport, get_optimizer, TeamStack
from pydfs_lineup_optimizer.stacks import GameStack

optimizer = get_optimizer(Site.DRAFTKINGS, Sport.BASEBALL)
optimizer.load_players_from_csv("/Users/aus10/Downloads/DKSalaries.csv")
optimizer.add_stack(GameStack(8, min_from_team=3))
optimizer.add_stack(TeamStack(5, for_teams=['TEX', 'STL', 'TOR', 'TB', 'WAS'], for_positions=['C', 'SS', 'OF', '1B', '2B', '3B']))
optimizer.add_stack(TeamStack(3, for_positions=['C', 'SS', 'OF', '1B', '2B', '3B']))
optimizer.restrict_positions_for_opposing_team(['SP', 'RP', 'P'], ['C', 'SS', 'OF', '1B', '2B', '3B'])

lineup_generator = optimizer.optimize(1)
for lineup in lineup_generator:
    print(lineup)

raise SolverInfeasibleSolutionException(invalid_constraints) pydfs_lineup_optimizer.solvers.exceptions.SolverInfeasibleSolutionException: ['_C21', '_C167', '_C196', '_C445', '_C615', '_C781', '_C786', '_C811', '_C817', '_C823', 'budget', 'total_players', 'positions_2B_OF', 'positions_2B_C_OF', 'positions_2B_3B_OF', 'positions_2B_OF_SS', 'positions_2B_3B_C_OF', 'positions_2B_C_OF_SS', 'positions_1B_2B_3B_OF', 'positions_2B_3B_OF_SS', 'positions_1B_2B_3B_C_OF', 'positions_2B_3B_C_OF_SS', 'positions_1B_2B_3B_OF_SS', 'positions_1B_2B_3B_C_OF_SS']

raise GenerateLineupException(solver_exception.get_user_defined_constraints()) pydfs_lineup_optimizer.exceptions.GenerateLineupException: Can't generate lineups. Following constraints are not valid: budget,total_players,positions_2B_OF,positions_2B_C_OF,positions_2B_3B_OF,positions_2B_OF_SS,positions_2B_3B_C_OF,positions_2B_C_OF_SS,positions_1B_2B_3B_OF,positions_2B_3B_OF_SS,positions_1B_2B_3B_C_OF,positions_2B_3B_C_OF_SS,positions_1B_2B_3B_OF_SS,positions_1B_2B_3B_C_OF_SS

BenikaH commented 1 year ago

If you're doing a GameStack, do you need to specify the TeamStacks as well??? Have you tried using only GameStack and without the two TeamStacks? I was able to do this with only GameStack before.