Calculates optimal lineups for all franchises in the dataframe based on a table of lineup constraints.
Usage
ffs_optimise_lineups(
roster_scores,
lineup_constraints,
lineup_efficiency_mean = 0.775,
lineup_efficiency_sd = 0.05,
best_ball = FALSE,
pos_filter = c("QB", "RB", "WR", "TE")
)
ffs_optimize_lineups(
roster_scores,
lineup_constraints,
lineup_efficiency_mean = 0.775,
lineup_efficiency_sd = 0.05,
best_ball = FALSE,
pos_filter = c("QB", "RB", "WR", "TE")
)
Arguments
- roster_scores
a dataframe as generated by
ffs_score_rosters()
- should contain columns like: projected_score, pos, and player_id- lineup_constraints
a dataframe as generated by
ffscrapr::ff_starter_positions()
- should contain columns pos, min, max, and offense_starters- lineup_efficiency_mean
the average lineup efficiency to use, defaults to 0.775
- lineup_efficiency_sd
the standard deviation of lineup efficiency, defaults to 0.05
- best_ball
a logical: FALSE will apply a lineup efficiency factor and TRUE uses optimal scores as actual scores, default = FALSE
- pos_filter
a character vector specifying which positions are eligible - defaults to
c("QB","RB","WR","TE)
Details
Lineup efficiency is the percentage of optimal/best-ball score that is used as the actual score - by default, the lineup efficiency for a team in non-best-ball settings is normally distributed around a mean of 77.5% and a standard deviation of 5%.
See also
vignette("custom")
for example usage
Examples
# \donttest{
# cached examples
roster_scores <- .ffs_cache("roster_scores.rds")
lineup_constraints <- .ffs_cache("mfl_lineup_constraints.rds")
ffs_optimise_lineups(roster_scores, lineup_constraints)
#> league_id franchise_id franchise_name season week
#> 1: 22627 0001 Mexico City Space Force 1 1
#> 2: 22627 0001 Mexico City Space Force 1 2
#> 3: 22627 0001 Mexico City Space Force 1 3
#> 4: 22627 0001 Mexico City Space Force 2 1
#> 5: 22627 0001 Mexico City Space Force 2 2
#> 6: 22627 0001 Mexico City Space Force 2 3
#> 7: 22627 0002 Dirty Dgens 1 1
#> 8: 22627 0002 Dirty Dgens 1 2
#> 9: 22627 0002 Dirty Dgens 1 3
#> 10: 22627 0002 Dirty Dgens 2 1
#> 11: 22627 0002 Dirty Dgens 2 2
#> 12: 22627 0002 Dirty Dgens 2 3
#> 13: 22627 0003 Alberta Armadillos 1 1
#> 14: 22627 0003 Alberta Armadillos 1 2
#> 15: 22627 0003 Alberta Armadillos 1 3
#> 16: 22627 0003 Alberta Armadillos 2 1
#> 17: 22627 0003 Alberta Armadillos 2 2
#> 18: 22627 0003 Alberta Armadillos 2 3
#> 19: 22627 0004 Electric Woodies 1 1
#> 20: 22627 0004 Electric Woodies 1 2
#> 21: 22627 0004 Electric Woodies 1 3
#> 22: 22627 0004 Electric Woodies 2 1
#> 23: 22627 0004 Electric Woodies 2 2
#> 24: 22627 0004 Electric Woodies 2 3
#> 25: 22627 0005 Motor City Mutts 1 1
#> 26: 22627 0005 Motor City Mutts 1 2
#> 27: 22627 0005 Motor City Mutts 1 3
#> 28: 22627 0005 Motor City Mutts 2 1
#> 29: 22627 0005 Motor City Mutts 2 2
#> 30: 22627 0005 Motor City Mutts 2 3
#> 31: 22627 0006 Hoth City Tauntauns 1 1
#> 32: 22627 0006 Hoth City Tauntauns 1 2
#> 33: 22627 0006 Hoth City Tauntauns 1 3
#> 34: 22627 0006 Hoth City Tauntauns 2 1
#> 35: 22627 0006 Hoth City Tauntauns 2 2
#> 36: 22627 0006 Hoth City Tauntauns 2 3
#> 37: 22627 0007 Paw Patrol 1 1
#> 38: 22627 0007 Paw Patrol 1 2
#> 39: 22627 0007 Paw Patrol 1 3
#> 40: 22627 0007 Paw Patrol 2 1
#> 41: 22627 0007 Paw Patrol 2 2
#> 42: 22627 0007 Paw Patrol 2 3
#> 43: 22627 0008 Domination Station 1 1
#> 44: 22627 0008 Domination Station 1 2
#> 45: 22627 0008 Domination Station 1 3
#> 46: 22627 0008 Domination Station 2 1
#> 47: 22627 0008 Domination Station 2 2
#> 48: 22627 0008 Domination Station 2 3
#> 49: 22627 0009 Kill Devil Hills Carpetbaggers 1 1
#> 50: 22627 0009 Kill Devil Hills Carpetbaggers 1 2
#> 51: 22627 0009 Kill Devil Hills Carpetbaggers 1 3
#> 52: 22627 0009 Kill Devil Hills Carpetbaggers 2 1
#> 53: 22627 0009 Kill Devil Hills Carpetbaggers 2 2
#> 54: 22627 0009 Kill Devil Hills Carpetbaggers 2 3
#> 55: 22627 0010 [Redacted] 1 1
#> 56: 22627 0010 [Redacted] 1 2
#> 57: 22627 0010 [Redacted] 1 3
#> 58: 22627 0010 [Redacted] 2 1
#> 59: 22627 0010 [Redacted] 2 2
#> 60: 22627 0010 [Redacted] 2 3
#> 61: 22627 0011 TB12 1 1
#> 62: 22627 0011 TB12 1 2
#> 63: 22627 0011 TB12 1 3
#> 64: 22627 0011 TB12 2 1
#> 65: 22627 0011 TB12 2 2
#> 66: 22627 0011 TB12 2 3
#> 67: 22627 0012 Indigo Plateau Elite 1 1
#> 68: 22627 0012 Indigo Plateau Elite 1 2
#> 69: 22627 0012 Indigo Plateau Elite 1 3
#> 70: 22627 0012 Indigo Plateau Elite 2 1
#> 71: 22627 0012 Indigo Plateau Elite 2 2
#> 72: 22627 0012 Indigo Plateau Elite 2 3
#> league_id franchise_id franchise_name season week
#> optimal_score optimal_player_id
#> 1: 189.38 14777,15241,12447,14079,13722,14137,...
#> 2: 180.82 13592,14777,14079,15260,13672,14138,...
#> 3: 198.14 13592,14777,12447,14797,13722,12175,...
#> 4: 185.69 13592,14777,14081,14073,14079,14797,...
#> 5: 220.84 13592,15241,14073,15260,14143,11674,...
#> 6: 260.17 13592,14777,12447,14073,14797,14805,...
#> 7: 127.19 12610,15238,11747,14803,12212,12263,...
#> 8: 69.30 15238,11747,13138,14803,12212,15330,...
#> 9: 97.60 15238,11390,11747,14815,15268,12212,...
#> 10: 106.80 12141,15238,13138,14803,15268,12263,...
#> 11: 134.42 12610,15238,11747,13138,12212,12263,...
#> 12: 128.42 12610,14780,11747,14803,14815,12263,...
#> 13: 187.08 10700,11644,13610,14085,14802,14806,...
#> 14: 135.32 11644,13424,13610,14075,14087,14802,...
#> 15: 128.70 11644,13113,13610,14087,14085,11695,...
#> 16: 124.05 10700,11644,12386,13610,14087,14802,...
#> 17: 165.20 10700,11644,13610,14075,14085,14802,...
#> 18: 154.36 10700,13424,12386,13610,14802,15256,...
#> 19: 158.05 10703,14778,13319,13364,13880,10973,...
#> 20: 163.90 10703,13589,13139,13378,14813,13236,...
#> 21: 168.57 10703,14778,13139,13319,13364,13880,...
#> 22: 150.16 10703,13115,13319,13378,14801,13236,...
#> 23: 159.49 13589,14778,13139,13146,13319,14813,...
#> 24: 149.82 13589,14778,13319,13364,13236,13880,...
#> 25: 131.59 13593,9431,12171,13234,12677,9474,...
#> 26: 174.86 13593,9431,13404,14080,12677,14867,...
#> 27: 144.93 13593,9431,13135,13620,13919,14867,...
#> 28: 151.70 13593,13135,13404,15258,12677,9474,...
#> 29: 172.44 13593,9431,13234,14095,14072,13919,...
#> 30: 169.84 13593,9431,13135,13404,15258,12677,...
#> 31: 121.98 13590,15237,14804,14808,14870,9925,...
#> 32: 146.23 13590,15237,11886,15414,11247,12656,...
#> 33: 198.28 11640,15237,11886,13726,11247,14875,...
#> 34: 104.60 13590,15237,13726,14804,9925,12176,...
#> 35: 168.38 13590,14057,13789,14808,15414,14870,...
#> 36: 88.82 11640,13590,13789,14808,15337,12176,...
#> 37: 175.41 12611,12620,13128,15257,14807,13679,...
#> 38: 106.17 12620,11761,15255,13679,13153,13164,...
#> 39: 150.44 12611,12620,12152,13128,15255,13679,...
#> 40: 158.65 10413,12620,11761,13128,15257,10276,...
#> 41: 175.36 12620,15252,12152,13128,14811,15255,...
#> 42: 163.74 12611,12620,12151,13128,15257,11516,...
#> 43: 191.49 15240,9099,13290,13604,13607,13299,...
#> 44: 173.30 15240,9099,12164,13290,13604,14798,...
#> 45: 188.13 11760,12164,13604,13607,14798,13299,...
#> 46: 158.34 14067,9099,12164,12629,13604,13188,...
#> 47: 153.40 15246,9099,12164,13604,14798,13188,...
#> 48: 199.54 15240,9099,13604,13608,14798,15272,...
#> 49: 219.67 10697,7836,11657,13132,13427,12187,...
#> 50: 163.46 14059,7836,11657,12625,13132,13133,...
#> 51: 189.04 10697,7836,11657,13132,12678,13427,...
#> 52: 120.53 10697,14059,12625,13108,13753,11222,...
#> 53: 176.83 13846,7836,11657,12625,13108,13132,...
#> 54: 181.67 14059,7836,12625,13108,13132,12678,...
#> 55: 165.27 12140,13116,13622,14827,12676,11671,...
#> 56: 104.77 12140,13116,13136,14223,13680,11671,...
#> 57: 123.63 12140,13116,14223,15254,12676,13680,...
#> 58: 166.64 13116,14223,15254,12676,11671,13163,...
#> 59: 105.14 12140,13116,13622,15254,12676,11671,...
#> 60: 173.88 12623,13116,13136,14223,12676,11671,...
#> 61: 149.53 14782,5848,13131,13850,15329,10729,...
#> 62: 164.16 15239,5848,13131,13614,13850,14828,...
#> 63: 220.86 14783,12630,13131,13850,15262,13192,...
#> 64: 236.82 15239,5848,13131,13614,14017,13192,...
#> 65: 174.02 14783,5848,13131,13850,13192,13674,...
#> 66: 152.97 14783,15239,12630,13129,15262,13674,...
#> 67: 205.11 14056,7401,11193,12626,13130,14071,...
#> 68: 173.42 14056,8062,11193,13130,14071,14852,...
#> 69: 190.83 14056,14779,12626,13130,13606,14071,...
#> 70: 195.58 14056,7401,12626,13130,14852,11244,...
#> 71: 172.41 14056,14779,11193,12626,14071,11647,...
#> 72: 162.65 7401,8062,12626,13130,13606,11244,...
#> optimal_score optimal_player_id
#> optimal_player_score lineup_efficiency actual_score
#> 1: 13.88,14.30,23.70, 6.40, 8.55, 6.05,... 0.7313512 138.50330
#> 2: 17.76,28.76,10.10, 8.30,12.85,13.95,... 0.8198630 148.24762
#> 3: 12.14,15.00,15.90,27.80,16.70,22.10,... 0.8227120 163.01216
#> 4: 9.58,20.46,11.30,26.80,24.70, 9.50,... 0.7418977 137.76298
#> 5: 29.60,24.02,21.10,15.10,22.50,23.60,... 0.7544779 166.61890
#> 6: 21.42,19.80,14.70,24.10,27.30,17.00,... 0.7828813 203.68222
#> 7: 10.94,15.15,13.90,22.50, 6.40, 9.40,... 0.7336223 93.30942
#> 8: 9.35, 4.50, 8.40,14.90, 2.45, 3.30,... 0.7661188 53.09204
#> 9: 21.70, 2.80,16.70, 2.70, 7.00, 1.85,... 0.7987932 77.96222
#> 10: 6.84,16.36, 3.20,13.80,12.70,12.75,... 0.7264863 77.58874
#> 11: 21.42,13.00,14.90,15.90, 5.55, 6.05,... 0.7868982 105.77486
#> 12: 13.32,17.50, 5.00,17.10, 8.20, 5.30,... 0.8452298 108.54441
#> 13: 27.54,26.74,11.80,12.20,28.10,15.10,... 0.7443372 139.25061
#> 14: 30.20,17.22,17.50, 6.70, 6.50, 8.40,... 0.7009703 94.85530
#> 15: 23.40, 8.70,10.40,11.30, 6.60, 6.35,... 0.7340937 94.47786
#> 16: 16.34,19.16,13.30, 9.50,12.30,14.90,... 0.7706284 95.59646
#> 17: 14.58,17.02,29.60,17.50, 4.70,13.10,... 0.7935273 131.09071
#> 18: 16.60,18.01,13.30,13.70,22.50,11.30,... 0.8340144 128.73846
#> 19: 29.90,17.30, 8.20,18.50, 7.15, 6.70,... 0.7144740 112.92262
#> 20: 23.12,28.48,27.10, 5.50,11.90, 7.60,... 0.8823744 144.62117
#> 21: 27.80,18.42,27.10, 6.80,21.10, 6.25,... 0.7930090 133.67753
#> 22: 39.00,29.96,22.70,13.20, 4.60, 9.30,... 0.6754767 101.42958
#> 23: 31.92,29.32, 7.00, 7.70,13.40,28.20,... 0.7847287 125.15638
#> 24: 18.32,30.00, 8.80,25.30, 7.85,10.75,... 0.8323953 124.70946
#> 25: 19.50,23.88,13.00, 6.70, 9.50,10.45,... 0.7831298 103.05205
#> 26: 17.52,33.84, 7.90,21.10, 9.50, 8.30,... 0.8018563 140.21260
#> 27: 21.46, 7.62, 4.60, 4.40,17.55, 6.90,... 0.6975240 101.09215
#> 28: 19.9,11.6,13.3, 9.7,15.8, 9.3,... 0.6895782 104.60902
#> 29: 12.94,22.20,18.20, 7.50,12.90,22.30,... 0.8147626 140.49766
#> 30: 18.79,25.40,15.10,16.20, 8.60,11.00,... 0.7835756 133.08247
#> 31: 4.32,17.36,31.70, 3.20, 9.50, 6.90,... 0.7458480 90.97854
#> 32: 26.34,15.74,15.20,11.20, 6.75, 8.80,... 0.7586326 110.93484
#> 33: 21.42,26.56, 4.70,13.10,10.35, 7.15,... 0.8333411 165.23488
#> 34: 11.32,13.58, 2.00, 0.90,19.00, 4.40,... 0.7420375 77.61712
#> 35: 19.26,10.52,18.50,15.30,31.40, 9.50,... 0.6765680 113.92051
#> 36: 10.94,22.38, 1.90, 3.20, 6.00, 3.30,... 0.7159527 63.59092
#> 37: 33.74,20.82,28.90, 5.50, 8.70, 9.75,... 0.7279786 127.69473
#> 38: 14.12,14.40,12.00, 1.65,10.30, 6.40,... 0.7607181 80.76545
#> 39: 33.74,22.90,11.80, 7.80,12.30, 5.00,... 0.8925339 134.27279
#> 40: 16.88,23.12,19.20,13.60, 8.60,15.70,... 0.7652935 121.41382
#> 41: 13.32,29.54,18.40,11.40,19.20,18.20,... 0.7876232 138.11761
#> 42: 22.50,21.44, 9.40,22.30, 7.90, 5.80,... 0.8422117 137.90375
#> 43: 24.38,22.06, 7.30,13.60, 7.10,16.10,... 0.7890450 151.09422
#> 44: 32.66,25.04, 7.70, 9.80,41.10,11.70,... 0.8163739 141.47760
#> 45: 18.03,14.10,22.90,28.00,12.40, 9.20,... 0.7027461 132.20762
#> 46: 12.30,19.44,17.50, 9.00,11.80, 9.50,... 0.7466894 118.23080
#> 47: 23.46,16.34, 8.40,15.10,15.70, 8.65,... 0.7572166 116.15703
#> 48: 19.37,31.35,39.80,15.00,12.20, 9.40,... 0.8252455 164.66950
#> 49: 21.28,36.14, 8.30, 8.00,17.55,37.20,... 0.7045863 154.77647
#> 50: 30.88,14.58, 9.00,11.60,18.30, 7.80,... 0.8820281 144.17632
#> 51: 25.42,18.32, 0.00,32.60,11.75,22.25,... 0.7330796 138.58136
#> 52: 27.96,13.12,14.80, 0.60, 6.85,10.90,... 0.7128832 85.92381
#> 53: 23.83,37.50, 5.90,42.40,12.90,10.50,... 0.7649205 135.26089
#> 54: 23.44,15.68,24.50,15.90,13.50,11.90,... 0.7516265 136.54799
#> 55: 10.40,19.22, 4.30, 0.80, 8.95,31.30,... 0.6682340 110.43904
#> 56: 21.42,42.00, 0.00,10.20, 1.65, 3.40,... 0.8105845 84.92494
#> 57: 10.40,28.08, 4.20,12.20, 7.15, 7.70,... 0.7528745 93.07788
#> 58: 39.64, 9.70,32.40, 0.00,12.60,12.00,... 0.7566677 126.09111
#> 59: 10.98, 3.96, 4.30,15.10, 6.90,12.50,... 0.7400964 77.81373
#> 60: 14.88,42.00, 3.40,10.30, 0.00,23.20,... 0.8039069 139.78333
#> 61: 25.04,24.44, 4.40,14.70,10.05, 6.50,... 0.7546901 112.84881
#> 62: 22.44,22.62,11.80, 8.60,13.40, 9.00,... 0.8137809 133.59027
#> 63: 38.86, 6.70,13.60,26.30, 7.20, 9.20,... 0.8176426 180.58455
#> 64: 25.60,21.12,12.70,17.70,26.40,15.45,... 0.7895464 186.98038
#> 65: 32.88,24.44,20.90, 8.40,12.45,12.35,... 0.7668220 133.44237
#> 66: 31.92,21.60, 7.60, 7.70, 7.90,14.45,... 0.8096864 123.85773
#> 67: 39.61,17.60, 9.70,20.20,22.80,25.30,... 0.8380616 171.89482
#> 68: 29.86,27.51,12.20,19.00, 8.20, 8.40,... 0.8159247 141.49766
#> 69: 19.22,27.96,14.80,23.00,11.70,15.50,... 0.7736918 147.64361
#> 70: 12.94,27.51,17.80,26.80,19.10,18.75,... 0.6935905 135.65242
#> 71: 17.96,39.00,13.30,15.90,11.90,12.75,... 0.7618820 131.35608
#> 72: 14.56,21.64,10.40,19.20,20.50,14.20,... 0.7169082 116.60511
#> optimal_player_score lineup_efficiency actual_score
# }