Clarification Around Locking Players into Lineups
Locking Methodology Clarification
It has come to my attention that I mispoke in a previous video regarding how to lock players into lineups with this optimizer. We will clarify this now.
import pydfs_lineup_optimizer
from pydfs_lineup_optimizer import get_optimizer, Site, Sport, Player
optimizer = get_optimizer(Site.FANDUEL, Sport.BASKETBALL)
optimizer.load_players_from_csv(r"C:\Users\nfwya\Downloads\FanDuel-NBA-2021 ET-02 ET-27 ET-55110-players-list.csv")
for lineup in optimizer.optimize(n=10):
print(lineup)
D:\Anaconda\lib\site-packages\pulp\pulp.py:1190: UserWarning: Spaces are not permitted in the name. Converted to '_'
warnings.warn("Spaces are not permitted in the name. Converted to '_'")
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Julius Randle PF NY IND@NY 44.039 8900.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 319.70
Salary 59900.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 319.26
Salary 60000.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Isaiah Roby PF OKC DEN@OKC 19.648 4200.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 319.12
Salary 60000.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Jordan Clarkson SG UTA UTA@ORL 27.852 5500.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Julius Randle PF NY IND@NY 44.039 8900.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 318.98
Salary 60000.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Julius Randle PF NY IND@NY 44.039 8900.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.92
Salary 59800.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Julius Randle PF NY IND@NY 44.039 8900.0$
9. C Al Horford C OKC DEN@OKC 32.259 6300.0$
Fantasy Points 318.67
Salary 60000.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.48
Salary 59900.00
1. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Julius Randle PF NY IND@NY 44.039 8900.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.44
Salary 59800.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Eric Bledsoe SG NO NO@SA 23.258 4900.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Julius Randle PF NY IND@NY 44.039 8900.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.38
Salary 60000.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Khem Birch PF ORL UTA@ORL 17.891 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.34
Salary 60000.00
optimizer.print_statistic()
Top Teams
NO - 10
OKC - 10
NY - 10
DAL - 9
DEN - 8
PHI - 7
BKN - 7
WAS - 6
UTA - 4
CLE - 3
SA - 3
ORL - 1
Used 12/14
Top Players
Ty Jerome - 10
Brandon Ingram - 10
RJ Barrett - 10
Luka Doncic - 9
Nikola Jokic - 8
Shake Milton - 7
Nicolas Claxton - 7
Julius Randle - 6
Bradley Beal - 6
Royce O'Neale - 3
Patty Mills - 3
Tim Hardaway - 2
JaVale McGee - 2
Isaiah Roby - 1
Jordan Clarkson - 1
Joel Embiid - 1
Al Horford - 1
Darius Garland - 1
Eric Bledsoe - 1
Khem Birch - 1
Used 20/229
Top Players Per Team
NY(16) - RJ Barrett(10),Julius Randle(6)
OKC(12) - Ty Jerome(10),Isaiah Roby(1),Al Horford(1)
NO(11) - Brandon Ingram(10),Eric Bledsoe(1)
DAL(11) - Luka Doncic(9),Tim Hardaway(2)
DEN(8) - Nikola Jokic(8)
PHI(8) - Shake Milton(7),Joel Embiid(1)
BKN(7) - Nicolas Claxton(7)
WAS(6) - Bradley Beal(6)
UTA(4) - Royce O'Neale(3),Jordan Clarkson(1)
SA(3) - Patty Mills(3)
CLE(3) - JaVale McGee(2),Darius Garland(1)
ORL(1) - Khem Birch(1)
optimizer.add_player_to_lineup(player)
This command is the command I mispoke on previously. I incorrectly stated that using this command would essentially set the minimum exposure for said player to a full 100%, locking them into every single lineup. This is not true. Plain and simple. We will run through a few examples below to identify and clarify what the locking methods are, and the priority in which they are used.
First up, we will dispel the notion that using the add_player_to_lineup command actually locks your player in to ALL lineups.:
optimizer = get_optimizer(Site.FANDUEL, Sport.BASKETBALL)
optimizer.load_players_from_csv(r"C:\Users\nfwya\Downloads\FanDuel-NBA-2021 ET-02 ET-27 ET-55110-players-list.csv")
#add player to lineup
luka = optimizer.get_player_by_name("Tim Hardaway")
optimizer.add_player_to_lineup(luka)
for lineup in optimizer.optimize(n=10, max_exposure= .5):
print(lineup)
optimizer.print_statistic()
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Julius Randle PF NY IND@NY 44.039 8900.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 319.70
Salary 59900.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Julius Randle PF NY IND@NY 44.039 8900.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.92
Salary 59800.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.92
Salary 59900.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 317.49
Salary 60000.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Julius Randle PF NY IND@NY 44.039 8900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.11
Salary 59700.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
3. SG DeMar DeRozan SG SA NO@SA 37.72 7600.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Joe Harris SF BKN DAL@BKN 23.406 4800.0$
6. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF Julius Randle PF NY IND@NY 44.039 8900.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 303.16
Salary 60000.00
1. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG DeMar DeRozan SG SA NO@SA 37.72 7600.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Joe Harris SF BKN DAL@BKN 23.406 4800.0$
6. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
7. PF Julius Randle PF NY IND@NY 44.039 8900.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 300.94
Salary 60000.00
1. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG DeMar DeRozan SG SA NO@SA 37.72 7600.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Joe Harris SF BKN DAL@BKN 23.406 4800.0$
6. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
7. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 299.15
Salary 60000.00
1. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG DeMar DeRozan SG SA NO@SA 37.72 7600.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Joe Harris SF BKN DAL@BKN 23.406 4800.0$
6. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
7. PF Khem Birch PF ORL UTA@ORL 17.891 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 298.23
Salary 60000.00
1. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG DeMar DeRozan SG SA NO@SA 37.72 7600.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Joe Harris SF BKN DAL@BKN 23.406 4800.0$
6. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
7. PF Zion Williamson PF NO NO@SA 41.239 8800.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 298.14
Salary 59900.00
Top Teams
BKN - 9
PHI - 7
NY - 7
CLE - 7
WAS - 7
NO - 6
SA - 6
OKC - 5
DEN - 5
DAL - 5
UTA - 5
IND - 5
ORL - 1
Used 13/14
Top Players
Luka Doncic - 5
Ty Jerome - 5
Tim Hardaway - 5
Brandon Ingram - 5
RJ Barrett - 5
Nicolas Claxton - 5
Julius Randle - 5
Nikola Jokic - 5
Royce O'Neale - 5
Joel Embiid - 5
Darius Garland - 5
DeMar DeRozan - 5
Bradley Beal - 5
Joe Harris - 5
Justin Holiday - 5
Shake Milton - 4
Russell Westbrook - 4
JaVale McGee - 3
Patty Mills - 2
Khem Birch - 1
Zion Williamson - 1
Used 21/229
Top Players Per Team
DAL(10) - Luka Doncic(5),Tim Hardaway(5)
NY(10) - RJ Barrett(5),Julius Randle(5)
BKN(10) - Nicolas Claxton(5),Joe Harris(5)
PHI(9) - Joel Embiid(5),Shake Milton(4)
WAS(9) - Bradley Beal(5),Russell Westbrook(4)
CLE(8) - Darius Garland(5),JaVale McGee(3)
SA(7) - DeMar DeRozan(5),Patty Mills(2)
NO(6) - Brandon Ingram(5),Zion Williamson(1)
OKC(5) - Ty Jerome(5)
DEN(5) - Nikola Jokic(5)
UTA(5) - Royce O'Neale(5)
IND(5) - Justin Holiday(5)
ORL(1) - Khem Birch(1)
Now we are going to be using Javale McGee as an example scenario so this code below is just to establish a baseline level of usage for him. He shows up on 2/10 lineups with no additional parameters to influence selection.
optimizer = get_optimizer(Site.FANDUEL, Sport.BASKETBALL)
optimizer.load_players_from_csv(r"C:\Users\nfwya\Downloads\FanDuel-NBA-2021 ET-02 ET-27 ET-55110-players-list.csv")
#add player specific exposure
for lineup in optimizer.optimize(n=10):
print(lineup)
optimizer.print_statistic()
Next, we will investigate how we can functionally lock a player onto ALL of our lineups. We will start by simply declaring a minimum exposure for the player in question.
optimizer = get_optimizer(Site.FANDUEL, Sport.BASKETBALL)
optimizer.load_players_from_csv(r"C:\Users\nfwya\Downloads\FanDuel-NBA-2021 ET-02 ET-27 ET-55110-players-list.csv")
#add player specific exposure
javale = optimizer.get_player_by_name("JaVale McGee")
javale.min_exposure = 1
for lineup in optimizer.optimize(n=10):
print(lineup)
optimizer.print_statistic()
D:\Anaconda\lib\site-packages\pulp\pulp.py:1190: UserWarning: Spaces are not permitted in the name. Converted to '_'
warnings.warn("Spaces are not permitted in the name. Converted to '_'")
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 319.26
Salary 60000.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.48
Salary 59900.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.28
Salary 59500.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.92
Salary 59900.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.50
Salary 59400.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Jordan Clarkson SG UTA UTA@ORL 27.852 5500.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 317.20
Salary 60000.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
3. SG Shai Gilgeous-Alexander SG OKC DEN@OKC 40.607 8300.0$
4. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.15
Salary 59700.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Julius Randle PF NY IND@NY 44.039 8900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.11
Salary 59700.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Michael Carter-Williams PG ORL UTA@ORL 20.157 4600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.00
Salary 59900.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Julius Randle PF NY IND@NY 44.039 8900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Al Horford C OKC DEN@OKC 32.259 6300.0$
Fantasy Points 316.87
Salary 59900.00
Top Teams
CLE - 10
NO - 10
NY - 10
OKC - 10
DAL - 10
DEN - 8
WAS - 8
BKN - 6
PHI - 5
UTA - 3
SA - 2
ORL - 1
Used 12/14
Top Players
Luka Doncic - 10
Ty Jerome - 10
Brandon Ingram - 10
RJ Barrett - 10
JaVale McGee - 10
Nikola Jokic - 8
Bradley Beal - 6
Nicolas Claxton - 6
Shake Milton - 4
Royce O'Neale - 2
Patty Mills - 2
Russell Westbrook - 2
Tim Hardaway - 2
Julius Randle - 2
Jordan Clarkson - 1
Joel Embiid - 1
Darius Garland - 1
Shai Gilgeous-Alexander - 1
Michael Carter-Williams - 1
Al Horford - 1
Used 20/229
Top Players Per Team
DAL(12) - Luka Doncic(10),Tim Hardaway(2)
OKC(12) - Ty Jerome(10),Shai Gilgeous-Alexander(1),Al Horford(1)
NY(12) - RJ Barrett(10),Julius Randle(2)
CLE(11) - JaVale McGee(10),Darius Garland(1)
NO(10) - Brandon Ingram(10)
DEN(8) - Nikola Jokic(8)
WAS(8) - Bradley Beal(6),Russell Westbrook(2)
BKN(6) - Nicolas Claxton(6)
PHI(5) - Shake Milton(4),Joel Embiid(1)
UTA(3) - Royce O'Neale(2),Jordan Clarkson(1)
SA(2) - Patty Mills(2)
ORL(1) - Michael Carter-Williams(1)
As shown above, we can see Javale Mcgee has in fact been added to 100% (10/10) lineups as our minimum exposure is the controlling factor here.
However, if you are creating enough lineups to be using an optmizer such as this, you are probably concerned with seing Ty Jerome also on all 10 lineups. To avoid this, we will simply add our max_exposure to the optimizer as a whole.
optimizer = get_optimizer(Site.FANDUEL, Sport.BASKETBALL)
optimizer.load_players_from_csv(r"C:\Users\nfwya\Downloads\FanDuel-NBA-2021 ET-02 ET-27 ET-55110-players-list.csv")
#add player specific exposure
javale = optimizer.get_player_by_name("JaVale McGee")
javale.min_exposure = 1
for lineup in optimizer.optimize(n=10, max_exposure = .5):
print(lineup)
optimizer.print_statistic()
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 319.26
Salary 60000.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.48
Salary 59900.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.28
Salary 59500.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.92
Salary 59900.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.50
Salary 59400.00
---------------------------------------------------------------------------
SolverException Traceback (most recent call last)
D:\Anaconda\lib\site-packages\pydfs_lineup_optimizer\lineup_optimizer.py in optimize(self, n, max_exposure, randomness, with_injured, exposure_strategy)
401 try:
--> 402 solved_variables = solver.solve()
403 lineup_players = []
D:\Anaconda\lib\site-packages\pydfs_lineup_optimizer\solvers\pulp_solver.py in solve(self)
54 else:
---> 55 raise SolverException('Unable to solve')
SolverException: Unable to solve
During handling of the above exception, another exception occurred:
LineupOptimizerException Traceback (most recent call last)
<ipython-input-4-10ed42bfb8b5> in <module>
5 javale = optimizer.get_player_by_name("JaVale McGee")
6 javale.min_exposure = 1
----> 7 for lineup in optimizer.optimize(n=10, max_exposure = .5):
8 print(lineup)
9 optimizer.print_statistic()
D:\Anaconda\lib\site-packages\pydfs_lineup_optimizer\lineup_optimizer.py in optimize(self, n, max_exposure, randomness, with_injured, exposure_strategy)
417 constraint.post_optimize(variables_names)
418 except SolverException:
--> 419 raise LineupOptimizerException('Can\'t generate lineups')
420 self.last_context = context
421
LineupOptimizerException: Can't generate lineups
UH-OH
That's an error. Through my testing I have discovered that if the declared minimum exposure value is HIGHER than the optimizer max exposure value, the optimizer breaks when that discrepancy point is reached. The only method I have discovered that bypasses this is to also declare a max exposure for your specific player. This will need to be declared as 100% as well so that it doesn't conflict with your minimum exposure.
optimizer = get_optimizer(Site.FANDUEL, Sport.BASKETBALL)
optimizer.load_players_from_csv(r"C:\Users\nfwya\Downloads\FanDuel-NBA-2021 ET-02 ET-27 ET-55110-players-list.csv")
#add player specific exposure
javale = optimizer.get_player_by_name("JaVale McGee")
javale.min_exposure = 1
javale.max_exposure = 1
for lineup in optimizer.optimize(n=10, max_exposure = .5):
print(lineup)
optimizer.print_statistic()
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 319.26
Salary 60000.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
8. PF Royce O'Neale PF UTA UTA@ORL 22.385 4400.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.48
Salary 59900.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 318.28
Salary 59500.00
1. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Tim Hardaway SG DAL DAL@BKN 24.577 4800.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.92
Salary 59900.00
1. PG Patty Mills PG SA NO@SA 20.65 4100.0$
2. PG Luka Doncic PG DAL DAL@BKN 53.137 10600.0$
3. SG Ty Jerome SG OKC DEN@OKC 30.5 3500.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Brandon Ingram SF NO NO@SA 39.603 7700.0$
6. SF RJ Barrett SF NY IND@NY 28.7 5400.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Nikola Jokic C DEN DEN@OKC 56.312 10900.0$
Fantasy Points 317.50
Salary 59400.00
1. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG Shai Gilgeous-Alexander SG OKC DEN@OKC 40.607 8300.0$
4. SG Bradley Beal SG WAS MIN@WAS 48.382 9600.0$
5. SF Joe Harris SF BKN DAL@BKN 23.406 4800.0$
6. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
7. PF Julius Randle PF NY IND@NY 44.039 8900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 300.25
Salary 60000.00
1. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG James Harden SG BKN DAL@BKN 51.686 10900.0$
4. SG Shai Gilgeous-Alexander SG OKC DEN@OKC 40.607 8300.0$
5. SF Joe Harris SF BKN DAL@BKN 23.406 4800.0$
6. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
7. PF Nicolas Claxton PF BKN DAL@BKN 21.4 3900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 297.71
Salary 60000.00
1. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
2. PG Shake Milton PG PHI CLE@PHI 21.432 4200.0$
3. SG DeMar DeRozan SG SA NO@SA 37.72 7600.0$
4. SG Collin Sexton SG CLE CLE@PHI 33.118 6900.0$
5. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
6. SF Josh Richardson SF DAL DAL@BKN 21.995 4500.0$
7. PF Julius Randle PF NY IND@NY 44.039 8900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 297.49
Salary 60000.00
1. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG Shai Gilgeous-Alexander SG OKC DEN@OKC 40.607 8300.0$
4. SG Jordan Clarkson SG UTA UTA@ORL 27.852 5500.0$
5. SF Jarrett Culver SF MIN MIN@WAS 17.406 3700.0$
6. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
7. PF Julius Randle PF NY IND@NY 44.039 8900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 297.16
Salary 60000.00
1. PG Darius Garland PG CLE CLE@PHI 28.076 5700.0$
2. PG Russell Westbrook PG WAS MIN@WAS 44.874 9400.0$
3. SG DeMar DeRozan SG SA NO@SA 37.72 7600.0$
4. SG Jordan Clarkson SG UTA UTA@ORL 27.852 5500.0$
5. SF Justin Holiday SF IND IND@NY 23.177 4500.0$
6. SF Danny Green SF PHI CLE@PHI 20.282 4400.0$
7. PF Julius Randle PF NY IND@NY 44.039 8900.0$
8. PF JaVale McGee PF CLE CLE@PHI 18.812 3700.0$
9. C Joel Embiid C PHI CLE@PHI 52.319 10300.0$
Fantasy Points 297.15
Salary 60000.00
Top Teams
CLE - 10
WAS - 10
NY - 9
OKC - 8
PHI - 7
DAL - 6
NO - 5
DEN - 5
BKN - 5
IND - 5
UTA - 4
SA - 4
MIN - 1
Used 13/14
Top Players
JaVale McGee - 10
Luka Doncic - 5
Shake Milton - 5
Ty Jerome - 5
Bradley Beal - 5
Brandon Ingram - 5
RJ Barrett - 5
Nikola Jokic - 5
Russell Westbrook - 5
Justin Holiday - 5
Joel Embiid - 5
Nicolas Claxton - 4
Julius Randle - 4
Darius Garland - 3
Shai Gilgeous-Alexander - 3
Royce O'Neale - 2
Patty Mills - 2
Joe Harris - 2
DeMar DeRozan - 2
Jordan Clarkson - 2
Tim Hardaway - 1
James Harden - 1
Collin Sexton - 1
Josh Richardson - 1
Jarrett Culver - 1
Danny Green - 1
Used 26/229
Top Players Per Team
CLE(14) - JaVale McGee(10),Darius Garland(3),Collin Sexton(1)
PHI(11) - Shake Milton(5),Joel Embiid(5),Danny Green(1)
WAS(10) - Bradley Beal(5),Russell Westbrook(5)
NY(9) - RJ Barrett(5),Julius Randle(4)
OKC(8) - Ty Jerome(5),Shai Gilgeous-Alexander(3)
DAL(7) - Luka Doncic(5),Tim Hardaway(1),Josh Richardson(1)
BKN(7) - Nicolas Claxton(4),Joe Harris(2),James Harden(1)
NO(5) - Brandon Ingram(5)
DEN(5) - Nikola Jokic(5)
IND(5) - Justin Holiday(5)
UTA(4) - Royce O'Neale(2),Jordan Clarkson(2)
SA(4) - Patty Mills(2),DeMar DeRozan(2)
MIN(1) - Jarrett Culver(1)
And just like that, we can effectively lock a player into our lineups across the board, while still maintaining our optimizer wide restrictions on exposure.