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)
#> Key: <league_id, franchise_id, franchise_name, season, week>
#> league_id franchise_id franchise_name season week
#> <char> <char> <char> <int> <int>
#> 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
#> <num> <list>
#> 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
#> <list> <num> <num>
#> 1: 13.88,14.30,23.70, 6.40, 8.55, 6.05,... 0.7551795 143.01590
#> 2: 17.76,28.76,10.10, 8.30,12.85,13.95,... 0.8073837 145.99111
#> 3: 12.14,15.00,15.90,27.80,16.70,22.10,... 0.8223362 162.93770
#> 4: 9.58,20.46,11.30,26.80,24.70, 9.50,... 0.8032132 149.14867
#> 5: 29.60,24.02,21.10,15.10,22.50,23.60,... 0.7041697 155.50884
#> 6: 21.42,19.80,14.70,24.10,27.30,17.00,... 0.7573864 197.04923
#> 7: 10.94,15.15,13.90,22.50, 6.40, 9.40,... 0.7969799 101.36788
#> 8: 9.35, 4.50, 8.40,14.90, 2.45, 3.30,... 0.8452729 58.57741
#> 9: 21.70, 2.80,16.70, 2.70, 7.00, 1.85,... 0.9275697 90.53080
#> 10: 6.84,16.36, 3.20,13.80,12.70,12.75,... 0.7709032 82.33246
#> 11: 21.42,13.00,14.90,15.90, 5.55, 6.05,... 0.7924537 106.52162
#> 12: 13.32,17.50, 5.00,17.10, 8.20, 5.30,... 0.8297639 106.55828
#> 13: 27.54,26.74,11.80,12.20,28.10,15.10,... 0.8114225 151.80092
#> 14: 30.20,17.22,17.50, 6.70, 6.50, 8.40,... 0.6866336 92.91526
#> 15: 23.40, 8.70,10.40,11.30, 6.60, 6.35,... 0.7839974 100.90046
#> 16: 16.34,19.16,13.30, 9.50,12.30,14.90,... 0.8288231 102.81550
#> 17: 14.58,17.02,29.60,17.50, 4.70,13.10,... 0.7703499 127.26180
#> 18: 16.60,18.01,13.30,13.70,22.50,11.30,... 0.6628699 102.32059
#> 19: 29.90,17.30, 8.20,18.50, 7.15, 6.70,... 0.7788445 123.09637
#> 20: 23.12,28.48,27.10, 5.50,11.90, 7.60,... 0.7458998 122.25297
#> 21: 27.80,18.42,27.10, 6.80,21.10, 6.25,... 0.8292495 139.78659
#> 22: 39.00,29.96,22.70,13.20, 4.60, 9.30,... 0.7540206 113.22374
#> 23: 31.92,29.32, 7.00, 7.70,13.40,28.20,... 0.7480301 119.30332
#> 24: 18.32,30.00, 8.80,25.30, 7.85,10.75,... 0.7952088 119.13819
#> 25: 19.50,23.88,13.00, 6.70, 9.50,10.45,... 0.7209448 94.86912
#> 26: 17.52,33.84, 7.90,21.10, 9.50, 8.30,... 0.8092048 141.49754
#> 27: 21.46, 7.62, 4.60, 4.40,17.55, 6.90,... 0.7632329 110.61535
#> 28: 19.9,11.6,13.3, 9.7,15.8, 9.3,... 0.7670840 116.36664
#> 29: 12.94,22.20,18.20, 7.50,12.90,22.30,... 0.7556197 130.29905
#> 30: 18.79,25.40,15.10,16.20, 8.60,11.00,... 0.8365792 142.08461
#> 31: 4.32,17.36,31.70, 3.20, 9.50, 6.90,... 0.7353865 89.70245
#> 32: 26.34,15.74,15.20,11.20, 6.75, 8.80,... 0.8453083 123.60944
#> 33: 21.42,26.56, 4.70,13.10,10.35, 7.15,... 0.7518762 149.08201
#> 34: 11.32,13.58, 2.00, 0.90,19.00, 4.40,... 0.8109742 84.82790
#> 35: 19.26,10.52,18.50,15.30,31.40, 9.50,... 0.7211247 121.42298
#> 36: 10.94,22.38, 1.90, 3.20, 6.00, 3.30,... 0.7322017 65.03415
#> 37: 33.74,20.82,28.90, 5.50, 8.70, 9.75,... 0.7662298 134.40437
#> 38: 14.12,14.40,12.00, 1.65,10.30, 6.40,... 0.8311225 88.24027
#> 39: 33.74,22.90,11.80, 7.80,12.30, 5.00,... 0.8122443 122.19403
#> 40: 16.88,23.12,19.20,13.60, 8.60,15.70,... 0.6744166 106.99619
#> 41: 13.32,29.54,18.40,11.40,19.20,18.20,... 0.8302703 145.59621
#> 42: 22.50,21.44, 9.40,22.30, 7.90, 5.80,... 0.8489833 139.01253
#> 43: 24.38,22.06, 7.30,13.60, 7.10,16.10,... 0.7693816 147.32888
#> 44: 32.66,25.04, 7.70, 9.80,41.10,11.70,... 0.8131004 140.91030
#> 45: 18.03,14.10,22.90,28.00,12.40, 9.20,... 0.7218595 135.80343
#> 46: 12.30,19.44,17.50, 9.00,11.80, 9.50,... 0.8165061 129.28558
#> 47: 23.46,16.34, 8.40,15.10,15.70, 8.65,... 0.8371686 128.42166
#> 48: 19.37,31.35,39.80,15.00,12.20, 9.40,... 0.7166681 143.00394
#> 49: 21.28,36.14, 8.30, 8.00,17.55,37.20,... 0.7999436 175.72360
#> 50: 30.88,14.58, 9.00,11.60,18.30, 7.80,... 0.8778139 143.48746
#> 51: 25.42,18.32, 0.00,32.60,11.75,22.25,... 0.7906442 149.46338
#> 52: 27.96,13.12,14.80, 0.60, 6.85,10.90,... 0.7300135 87.98852
#> 53: 23.83,37.50, 5.90,42.40,12.90,10.50,... 0.8117005 143.53300
#> 54: 23.44,15.68,24.50,15.90,13.50,11.90,... 0.7973836 144.86068
#> 55: 10.40,19.22, 4.30, 0.80, 8.95,31.30,... 0.8424129 139.22558
#> 56: 21.42,42.00, 0.00,10.20, 1.65, 3.40,... 0.7078126 74.15753
#> 57: 10.40,28.08, 4.20,12.20, 7.15, 7.70,... 0.7434213 91.90917
#> 58: 39.64, 9.70,32.40, 0.00,12.60,12.00,... 0.7776615 129.58951
#> 59: 10.98, 3.96, 4.30,15.10, 6.90,12.50,... 0.8165619 85.85331
#> 60: 14.88,42.00, 3.40,10.30, 0.00,23.20,... 0.7854472 136.57357
#> 61: 25.04,24.44, 4.40,14.70,10.05, 6.50,... 0.6918161 103.44726
#> 62: 22.44,22.62,11.80, 8.60,13.40, 9.00,... 0.7118499 116.85728
#> 63: 38.86, 6.70,13.60,26.30, 7.20, 9.20,... 0.8344994 184.30754
#> 64: 25.60,21.12,12.70,17.70,26.40,15.45,... 0.7825704 185.32832
#> 65: 32.88,24.44,20.90, 8.40,12.45,12.35,... 0.6982738 121.51360
#> 66: 31.92,21.60, 7.60, 7.70, 7.90,14.45,... 0.7470317 114.27344
#> 67: 39.61,17.60, 9.70,20.20,22.80,25.30,... 0.8222765 168.65714
#> 68: 29.86,27.51,12.20,19.00, 8.20, 8.40,... 0.8159712 141.50572
#> 69: 19.22,27.96,14.80,23.00,11.70,15.50,... 0.8694654 165.92009
#> 70: 12.94,27.51,17.80,26.80,19.10,18.75,... 0.7726028 151.10566
#> 71: 17.96,39.00,13.30,15.90,11.90,12.75,... 0.7965830 137.33888
#> 72: 14.56,21.64,10.40,19.20,20.50,14.20,... 0.8169261 132.87302
#> optimal_player_score lineup_efficiency actual_score
# }