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

total_salary Parameter not observed #44

Open bvoorhees13 opened 1 year ago

bvoorhees13 commented 1 year ago

I'm sure this is user error but I'm trying to use the generic functions to build a DK CFB optimizer but it outputs the optimal lineup considering positional constraints but goes over the salary_total. In the example below the optimal lineup is $53,600. It appears as though my data tibble is in the correct format with the correct data types and column names for the 10 columns. Using R version 4.2.2 here is the code with the output below it. Strangely, when I reduce the total_salary to 27,000ish or below it starts to constrain based on salary. Any suggestions to help me de-bug would be appreciated.

`model<- model_generic(DK_Projections, total_salary=50E3, roster_size=8, max_from_team = 5, type = "binary") constraints <- list( "QB" = 2, "RB" = 2, "WR" = 3, "RB/WR" = 1 )

model <- add_generic_positions_constraint(model, DK_Projections, constraints)

optimal<-optimize_generic(DK_Projections, model, L = 1, solver="glpk", bans=NULL, locks=NULL, stack_sizes = NULL, stack_teams = NULL, min_salary = 49000, randomness = NULL) optimal sum(optimal[[1]]$salary) `

Here is the output:

sessionInfo()$R.version$version.string [1] "R version 4.2.2 (2022-10-31 ucrt)" optimal [[1]]

A tibble: 8 x 10

row_id player_id player team opp_team location position salary fpts_avg fpts_proj

1 291 29028065 Austin Jones USC SJSU USC RB 7800 12.9 16.9 2 313 29027947 Caleb Williams USC SJSU USC QB 9900 33.2 34.4 3 83 29028098 Charvis Thornton LT FIU LT RB 5400 6.24 16.1 4 99 29028317 Cyrus Allen LT FIU LT WR 5700 11.4 13.6 5 290 29028290 Dorian Singer USC SJSU USC WR 7700 18.6 15.7 6 85 29027975 Hank Bachmeier LT FIU LT QB 5800 9.07 21.9 7 76 29028302 Smoke Harris LT FIU LT WR 6600 13.6 16.0 8 53 29028119 Tylan Hines HAW VAND VAN RB 4700 8.6 16.0

sum(optimal[[1]]$salary) [1] 53600