dfs-with-r / coach

Lineup optimization for daily fantasy sports
https://dfs-with-r.github.io/coach/
GNU General Public License v3.0
46 stars 14 forks source link

Unique Lineups not working #31

Closed bkertz closed 2 years ago

bkertz commented 3 years ago

The following code results in numerous repeated lineups:

` library(coach) setwd("/dfs")

data <- read_dk("bkertz_coach_draftkings_1_20210823.csv")

model <- model_dk_mlb(data) results <- optimize_generic(data, model, L = 20, solver = "glpk", bans = NULL, locks = NULL, stack_sizes = NULL, stack_teams = NULL, min_salary = NULL, max_exposure = 1, randomness = NULL)

write_lineups(results, "coachLineups.csv", site="draftkings", sport = "mlb") `

bkertz_coach_draftkings_1_20210823.csv

evanjpatton commented 2 years ago

Hey, first and foremost I have 0 relationships with this project. I was about to build something like this myself and googled for examples and stumbled upon this. I had the same issue and it appears (at least with NFL) that the issue is with the row_id column.

If any rows get removed and the row ids aren't in sequential order the function gives some warnings and the same lineup gets repeated.

So essentially you just assign new values to the row_id column and you should be good to go.

zamorarr commented 2 years ago

Ah sorry I missed this. Thanks @ejpatton4. The answer you provided is correct. The row_ids have to be in sequential order, so make sure you number them after you have done any filtering on the dataset.

bkertz commented 2 years ago

Thanks. R isn't my strong suit so I will have to pick this back up and look at it again when I have a bit of time.