Calculates optimal lineups for all franchises in the dataframe based on a table of lineup constraints.

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)

Value

a dataframe of what each team scored for each week

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.7865282 148.95270 #> 2: 17.76,28.76,10.10, 8.30,12.85,13.95,... 0.8189216 148.07741 #> 3: 12.14,15.00,15.90,27.80,16.70,22.10,... 0.6723254 133.21456 #> 4: 9.58,20.46,11.30,26.80,24.70, 9.50,... 0.8270808 153.58064 #> 5: 29.60,24.02,21.10,15.10,22.50,23.60,... 0.7448384 164.49010 #> 6: 21.42,19.80,14.70,24.10,27.30,17.00,... 0.7195359 187.20166 #> 7: 10.94,15.15,13.90,22.50, 6.40, 9.40,... 0.6608369 84.05184 #> 8: 9.35, 4.50, 8.40,14.90, 2.45, 3.30,... 0.8102531 56.15054 #> 9: 21.70, 2.80,16.70, 2.70, 7.00, 1.85,... 0.7720178 75.34893 #> 10: 6.84,16.36, 3.20,13.80,12.70,12.75,... 0.6958742 74.31936 #> 11: 21.42,13.00,14.90,15.90, 5.55, 6.05,... 0.8746755 117.57389 #> 12: 13.32,17.50, 5.00,17.10, 8.20, 5.30,... 0.8444248 108.44104 #> 13: 27.54,26.74,11.80,12.20,28.10,15.10,... 0.7855831 146.96689 #> 14: 30.20,17.22,17.50, 6.70, 6.50, 8.40,... 0.7181292 97.17724 #> 15: 23.40, 8.70,10.40,11.30, 6.60, 6.35,... 0.7807658 100.48456 #> 16: 16.34,19.16,13.30, 9.50,12.30,14.90,... 0.7618628 94.50908 #> 17: 14.58,17.02,29.60,17.50, 4.70,13.10,... 0.8461837 139.78954 #> 18: 16.60,18.01,13.30,13.70,22.50,11.30,... 0.7757558 119.74567 #> 19: 29.90,17.30, 8.20,18.50, 7.15, 6.70,... 0.8500444 134.34952 #> 20: 23.12,28.48,27.10, 5.50,11.90, 7.60,... 0.7353970 120.53158 #> 21: 27.80,18.42,27.10, 6.80,21.10, 6.25,... 0.8054114 135.76820 #> 22: 39.00,29.96,22.70,13.20, 4.60, 9.30,... 0.8321519 124.95592 #> 23: 31.92,29.32, 7.00, 7.70,13.40,28.20,... 0.8519043 135.87022 #> 24: 18.32,30.00, 8.80,25.30, 7.85,10.75,... 0.7510978 112.52948 #> 25: 19.50,23.88,13.00, 6.70, 9.50,10.45,... 0.8554243 112.56528 #> 26: 17.52,33.84, 7.90,21.10, 9.50, 8.30,... 0.7963377 139.24761 #> 27: 21.46, 7.62, 4.60, 4.40,17.55, 6.90,... 0.7470870 108.27531 #> 28: 19.9,11.6,13.3, 9.7,15.8, 9.3,... 0.7359120 111.63784 #> 29: 12.94,22.20,18.20, 7.50,12.90,22.30,... 0.7636274 131.67990 #> 30: 18.79,25.40,15.10,16.20, 8.60,11.00,... 0.8208841 139.41895 #> 31: 4.32,17.36,31.70, 3.20, 9.50, 6.90,... 0.7377123 89.98614 #> 32: 26.34,15.74,15.20,11.20, 6.75, 8.80,... 0.8397085 122.79058 #> 33: 21.42,26.56, 4.70,13.10,10.35, 7.15,... 0.7103455 140.84731 #> 34: 11.32,13.58, 2.00, 0.90,19.00, 4.40,... 0.6448036 67.44645 #> 35: 19.26,10.52,18.50,15.30,31.40, 9.50,... 0.7891606 132.87885 #> 36: 10.94,22.38, 1.90, 3.20, 6.00, 3.30,... 0.8209823 72.91965 #> 37: 33.74,20.82,28.90, 5.50, 8.70, 9.75,... 0.8504444 149.17646 #> 38: 14.12,14.40,12.00, 1.65,10.30, 6.40,... 0.7117556 75.56709 #> 39: 33.74,22.90,11.80, 7.80,12.30, 5.00,... 0.7072452 106.39796 #> 40: 16.88,23.12,19.20,13.60, 8.60,15.70,... 0.8018341 127.21098 #> 41: 13.32,29.54,18.40,11.40,19.20,18.20,... 0.7432857 130.34258 #> 42: 22.50,21.44, 9.40,22.30, 7.90, 5.80,... 0.8063561 132.03275 #> 43: 24.38,22.06, 7.30,13.60, 7.10,16.10,... 0.8573654 164.17691 #> 44: 32.66,25.04, 7.70, 9.80,41.10,11.70,... 0.7738516 134.10849 #> 45: 18.03,14.10,22.90,28.00,12.40, 9.20,... 0.6970357 131.13332 #> 46: 12.30,19.44,17.50, 9.00,11.80, 9.50,... 0.8144765 128.96421 #> 47: 23.46,16.34, 8.40,15.10,15.70, 8.65,... 0.7729428 118.56942 #> 48: 19.37,31.35,39.80,15.00,12.20, 9.40,... 0.6933036 138.34180 #> 49: 21.28,36.14, 8.30, 8.00,17.55,37.20,... 0.6809026 149.57387 #> 50: 30.88,14.58, 9.00,11.60,18.30, 7.80,... 0.8180193 133.71343 #> 51: 25.42,18.32, 0.00,32.60,11.75,22.25,... 0.8194340 154.90580 #> 52: 27.96,13.12,14.80, 0.60, 6.85,10.90,... 0.7605647 91.67086 #> 53: 23.83,37.50, 5.90,42.40,12.90,10.50,... 0.8276340 146.35052 #> 54: 23.44,15.68,24.50,15.90,13.50,11.90,... 0.7540211 136.98300 #> 55: 10.40,19.22, 4.30, 0.80, 8.95,31.30,... 0.7854980 129.81925 #> 56: 21.42,42.00, 0.00,10.20, 1.65, 3.40,... 0.8690298 91.04825 #> 57: 10.40,28.08, 4.20,12.20, 7.15, 7.70,... 0.8589199 106.18827 #> 58: 39.64, 9.70,32.40, 0.00,12.60,12.00,... 0.7753603 129.20604 #> 59: 10.98, 3.96, 4.30,15.10, 6.90,12.50,... 0.8275641 87.01009 #> 60: 14.88,42.00, 3.40,10.30, 0.00,23.20,... 0.8607372 149.66499 #> 61: 25.04,24.44, 4.40,14.70,10.05, 6.50,... 0.7266549 108.65670 #> 62: 22.44,22.62,11.80, 8.60,13.40, 9.00,... 0.7720679 126.74267 #> 63: 38.86, 6.70,13.60,26.30, 7.20, 9.20,... 0.7413397 163.73228 #> 64: 25.60,21.12,12.70,17.70,26.40,15.45,... 0.8503974 201.39111 #> 65: 32.88,24.44,20.90, 8.40,12.45,12.35,... 0.8083447 140.66815 #> 66: 31.92,21.60, 7.60, 7.70, 7.90,14.45,... 0.7919140 121.13909 #> 67: 39.61,17.60, 9.70,20.20,22.80,25.30,... 0.8051506 165.14443 #> 68: 29.86,27.51,12.20,19.00, 8.20, 8.40,... 0.8444128 146.43806 #> 69: 19.22,27.96,14.80,23.00,11.70,15.50,... 0.8108535 154.73518 #> 70: 12.94,27.51,17.80,26.80,19.10,18.75,... 0.8290916 162.15374 #> 71: 17.96,39.00,13.30,15.90,11.90,12.75,... 0.7380724 127.25106 #> 72: 14.56,21.64,10.40,19.20,20.50,14.20,... 0.7649794 124.42390 #> optimal_player_score lineup_efficiency actual_score
# }