DimaKudosh / pydfs-lineup-optimizer

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

Adding CSGO Showdown Custom Settings #347

Open bimpyinu opened 2 years ago

bimpyinu commented 2 years ago

Hi, I tried adding a custom settings class to support the CSGO single game variant on DraftKings, but I get the following error:

`
SolverInfeasibleSolutionException         Traceback (most recent call last)
~\anaconda3\lib\site-packages\pydfs_lineup_optimizer\lineup_optimizer.py in optimize(self, n, max_exposure, randomness, with_injured, exposure_strategy)
    387             try:
--> 388                 solved_variables = solver.solve()
    389                 lineup_players = []

~\anaconda3\lib\site-packages\pydfs_lineup_optimizer\solvers\pulp_solver.py in solve(self)
     55             invalid_constraints = [name for name, constraint in self.prob.constraints.items() if not constraint.valid()]
---> 56             raise SolverInfeasibleSolutionException(invalid_constraints)

SolverInfeasibleSolutionException: ['_C3', 'total_players']

During handling of the above exception, another exception occurred:

GenerateLineupException                   Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_23440/3430251669.py in <module>
     93     # optimizer.set_players_from_one_team({'EG': 4})
     94 
---> 95     for lineup in optimizer.optimize(n = 1):
     96         0
     97 

~\anaconda3\lib\site-packages\pydfs_lineup_optimizer\lineup_optimizer.py in optimize(self, n, max_exposure, randomness, with_injured, exposure_strategy)
    403                     constraint.post_optimize(variables_names)
    404             except SolverInfeasibleSolutionException as solver_exception:
--> 405                 raise GenerateLineupException(solver_exception.get_user_defined_constraints())
    406         self.last_context = context
    407 

GenerateLineupException: Can't generate lineups. Following constraints are not valid: total_players`

The variant requires 2 captains and 2 flex players for a roster of 4 players total. Is there something I did wrong in creating the new class? I had it as

@SitesRegistry.register_settings class DraftKingsCSGOSDSettings(DraftKingsCaptainModeSettings): sport = Sport.CS max_from_one_team = 3 positions = [ LineupPosition('CPT', ('CPT', )), LineupPosition('CPT', ('CPT', )), LineupPosition('FLEX', ('FLEX', )), LineupPosition('FLEX', ('FLEX', )), ]