BenBrostoff / draftfast

A tool to automate and optimize DraftKings and FanDuel lineup construction.
286 stars 112 forks source link

If play a then play b #185

Closed revdarr closed 2 years ago

revdarr commented 2 years ago

The test seems to only allow for multiple players on b.

For example:

CustomRule(
             group_a=lambda p: p.name=='Gary Payton II',
             group_b=lambda p: p.name=='Jayson Tatum' or p.name=='Jaylen Brown',
         )

works but always has both Tatum and Brown

but

CustomRule( group_a=lambda p: p.name=='Gary Payton II', group_b=lambda p: p.name=='Jayson Tatum' )

Results in no solution found

BenBrostoff commented 2 years ago

@revdarr Can look into this - do you have a CSV with projections you can send here so I can replicate? Additionally, it's worth mentioning here on CustomRule the default comparison is here. You may need to override the default comparison such that solver_sum(g_a) == solver_sum(g_b). I can check this tomorrow and add a test with this exact condition (given player A is in the lineup, player B must be in the lineup and vice versa). This is definitely a very common use case so if there's a bug here I want to fix it ASAP.

revdarr commented 2 years ago

Thanks! Here's my CSV. TestDK.csv

BenBrostoff commented 2 years ago

@revdarr This should be fixed by just changing the comparison function to solver_sum(g_a) == solver_sum(g_b). I updated tests to show this scenario in https://github.com/BenBrostoff/draftfast/commit/bf209c80727dbb334a2fd4c8e9ea7501aadbdce9 . If you use this rule, my testing shows:

Let me know if this fixes your issue and I can close this out if so.

BenBrostoff commented 2 years ago

Closing this issue as I think the test I added proves this works as expected.