PuLP linear programming problem is infeasible

Question:

I am writing a Linear Programming problem to help generate daily fantasy lineups.

The goal is:

  • Maximize Fpts projection

The constraints are:

  • Salary (Maximum 50,000)
  • Positionality (Have to have 1 PG, 1 SG, 1 SF, 1 PF, 1 C, 1 G, 1 F and 1 UTIL player) where "G" players are either PG or SG, "F" are either SF or PF players, and "UTIL" are any position players

I have my problem set up like this:

# Create problem
prob = plp.LpProblem("NBA_DK", plp.LpMaximize)

# Objective function
prob += plp.lpSum([fpts[i] * player_vars[i] for i in players]), 'Objective - Maximize Fpts'

# Salary constraint
prob += plp.lpSum([salaries[i] * player_vars[i] for i in players]) <= 50000, 'Salary Constraints'

 # Position constraints                 
for curr_pos in ['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'UTIL']:
    prob += plp.lpSum([player_vars[player] for player in players if curr_pos in positions[player]]) == 1, f'{curr_pos} Positional Constraint'

Here are some of the example variables being referenced above

player_vars

player_vars = plp.LpVariable.dicts("Players", players, lowBound=0, cat='Binary')

projections

projections = pd.read_csv('../dk_data/projections.csv', thousands=',')
...
                        Name   Fpts        Position Team Opponent  Minutes  Salary  Pts/$  Value
0               Nikola Jokic  61.52          C/UTIL  DEN      LAL     33.9   11700   5.26   3.02
1      Giannis Antetokounmpo  58.09     PF/C/F/UTIL  MIL      NYK     36.1   12000   4.84  -1.91
2               LeBron James  53.05    SF/PF/F/UTIL  LAL      DEN     35.4   10900   4.87  -1.45
3               Jayson Tatum  52.94    SF/PF/F/UTIL  BOS      CHI     37.1   10700   4.95  -0.56
4           Domantas Sabonis  52.62          C/UTIL  SAC      ORL     36.7   10500   5.01   0.12
5                  Ja Morant  51.01       PG/G/UTIL  MEM      SAS     32.6   10300   4.95  -0.49
6              Julius Randle  49.74       PF/F/UTIL  NYK      MIL     38.0   10400   4.78  -2.26
7         Kristaps Porzingis  44.76     PF/C/F/UTIL  WAS      NOP     35.0    9400   4.76  -2.24
8               De'Aaron Fox  43.40       PG/G/UTIL  SAC      ORL     35.3    8700   4.99  -0.10
9              DeMar DeRozan  43.21    SF/PF/F/UTIL  CHI      BOS     36.8    9000   4.80  -1.79
10              Jaylen Brown  42.45  SG/SF/G/F/UTIL  BOS      CHI     33.7    9500   4.47  -5.05
11               CJ McCollum  42.05       PG/G/UTIL  NOP      WAS     35.0    8500   4.95  -0.45
12             Jalen Brunson  41.20       PG/G/UTIL  NYK      MIL     36.2    8100   5.09   0.70
13            Paolo Banchero  40.34    SF/PF/F/UTIL  ORL      SAC     34.3    8200   4.92  -0.66
14                Kyle Kuzma  39.88    SF/PF/F/UTIL  WAS      NOP     34.8    8400   4.75  -2.12
15            Nikola Vucevic  37.51          C/UTIL  CHI      BOS     32.0    8000   4.69  -2.49
16               Zach LaVine  37.45  SG/SF/G/F/UTIL  CHI      BOS     34.9    7500   4.99  -0.05
17         Russell Westbrook  37.11       PG/G/UTIL  LAL      DEN     28.9    7700   4.82  -1.39
18         Jaren Jackson Jr.  36.08     PF/C/F/UTIL  MEM      SAS     28.3    6800   5.31   2.08
19            Keldon Johnson  35.44       SF/F/UTIL  SAS      MEM     31.7    7000   5.06   0.44
20              Jrue Holiday  35.32       PG/G/UTIL  MIL      NYK     32.4    7400   4.77  -1.68
21              Desmond Bane  35.18       SG/G/UTIL  MEM      SAS     29.2    6600   5.33   2.18
22         Jonas Valanciunas  34.71          C/UTIL  NOP      WAS     26.4    6600   5.26   1.71
23              Jamal Murray  34.59       PG/G/UTIL  DEN      LAL     31.9    6800   5.09   0.59
24                 Tre Jones  32.40       PG/G/UTIL  SAS      MEM     30.2    6000   5.40   2.40
25              Aaron Gordon  32.37       PF/F/UTIL  DEN      LAL     30.1    6600   4.90  -0.63
26              Franz Wagner  32.13  SG/SF/G/F/UTIL  ORL      SAC     35.1    7100   4.53  -3.37
27              Jakob Poeltl  31.88          C/UTIL  SAS      MEM     25.8    5900   5.40   2.38
28             Thomas Bryant  31.78          C/UTIL  LAL      DEN     29.9    6300   5.05   0.28
29         Immanuel Quickley  31.78    PG/SG/G/UTIL  NYK      MIL     35.9    6200   5.13   0.78
30        Wendell Carter Jr.  31.64          C/UTIL  ORL      SAC     29.8    6400   4.94  -0.36
31              Steven Adams  29.50          C/UTIL  MEM      SAS     27.6    6000   4.92  -0.50
32             Naji Marshall  29.14    SF/PF/F/UTIL  NOP      WAS     34.1    5500   5.30   1.64
33        Michael Porter Jr.  29.10       SF/F/UTIL  DEN      LAL     29.7    5900   4.93  -0.40
34            Markelle Fultz  29.02       PG/G/UTIL  ORL      SAC     28.8    6100   4.76  -1.48
35              Bobby Portis  28.49     PF/C/F/UTIL  MIL      NYK     27.1    6700   4.25  -5.01
36             Kevin Huerter  28.25  SG/SF/G/F/UTIL  SAC      ORL     32.9    5700   4.96  -0.25
37         Mitchell Robinson  27.48          C/UTIL  NYK      MIL     29.9    5200   5.28   1.48
38           Malcolm Brogdon  27.16    PG/SG/G/UTIL  BOS      CHI     24.5    5300   5.12   0.66
39           Dennis Schroder  27.07       PG/G/UTIL  LAL      DEN     34.6    5700   4.75  -1.43
40           Harrison Barnes  26.88    SF/PF/F/UTIL  SAC      ORL     32.9    5600   4.80  -1.12
41             Dillon Brooks  26.32  SG/SF/G/F/UTIL  MEM      SAS     29.1    5800   4.54  -2.68
42            Daniel Gafford  26.22          C/UTIL  WAS      NOP     24.7    4700   5.58   2.72
43               Brook Lopez  25.35          C/UTIL  MIL      NYK     28.6    5700   4.45  -3.15
44              Monte Morris  25.13       PG/G/UTIL  WAS      NOP     27.9    4800   5.23   1.13
45             Jeremy Sochan  25.10       PF/F/UTIL  SAS      MEM     28.6    5000   5.02   0.10
46              Cole Anthony  25.07    PG/SG/G/UTIL  ORL      SAC     26.7    5200   4.82  -0.93
47             Derrick White  24.74    PG/SG/G/UTIL  BOS      CHI     28.7    5100   4.85  -0.76
48              Bones Hyland  24.70    PG/SG/G/UTIL  DEN      LAL     21.8    4900   5.04   0.20
49                Malik Monk  23.98       SG/G/UTIL  SAC      ORL     22.1    4500   5.33   1.48
50           Robert Williams  23.88          C/UTIL  BOS      CHI     21.8    4400   5.43   1.88
51                Al Horford  23.51     PF/C/F/UTIL  BOS      CHI     29.0    4800   4.90  -0.49
52            Quentin Grimes  23.48  SG/SF/G/F/UTIL  NYK      MIL     34.4    5400   4.35  -3.52
53             Rui Hachimura  23.25       PF/F/UTIL  WAS      NOP     24.5    4700   4.95  -0.25
54             Herbert Jones  23.16       SF/F/UTIL  NOP      WAS     27.5    4900   4.73  -1.34
55               Deni Avdija  22.61       SF/F/UTIL  WAS      NOP     25.7    4200   5.38   1.61
56           Trey Murphy III  22.56  SG/SF/G/F/UTIL  NOP      WAS     28.2    5100   4.42  -2.94
57          Patrick Williams  21.92    SF/PF/F/UTIL  CHI      BOS     30.6    4400   4.98  -0.08
58  Kentavious Caldwell-Pope  21.74       SG/G/UTIL  DEN      LAL     31.3    4400   4.94  -0.26
59           Josh Richardson  21.62    PG/SG/G/UTIL  SAS      MEM     21.7    4000   5.40   1.62
60             Keegan Murray  21.61       PF/F/UTIL  SAC      ORL     27.8    4300   5.03   0.11
61               Bruce Brown  21.01  SG/SF/G/F/UTIL  DEN      LAL     24.2    5000   4.20  -3.99
62             Moritz Wagner  20.30     PF/C/F/UTIL  ORL      SAC     19.5    5300   3.83  -6.20
63              Zach Collins  20.08          C/UTIL  SAS      MEM     17.9    4700   4.27  -3.42

players

players = list(projections['Name'])

fpts, salaries, positions

salaries = dict(zip(players, projections['Salary']))
fpts = dict(zip(players, projections['Fpts']))
positions = dict(zip(players, projections['Position']))

Here is my prob.writeLP() output:

* NBA_DK *
Maximize
OBJ: 32.37 Players_Aaron_Gordon + 23.51 Players_Al_Horford
 + 28.49 Players_Bobby_Portis + 24.7 Players_Bones_Hyland
 + 25.35 Players_Brook_Lopez + 21.01 Players_Bruce_Brown
 + 42.05 Players_CJ_McCollum + 25.07 Players_Cole_Anthony
 + 26.22 Players_Daniel_Gafford + 43.4 Players_De'Aaron_Fox
 + 43.21 Players_DeMar_DeRozan + 22.61 Players_Deni_Avdija
 + 27.07 Players_Dennis_Schroder + 24.74 Players_Derrick_White
 + 35.18 Players_Desmond_Bane + 26.32 Players_Dillon_Brooks
 + 52.62 Players_Domantas_Sabonis + 32.13 Players_Franz_Wagner
 + 58.09 Players_Giannis_Antetokounmpo + 26.88 Players_Harrison_Barnes
 + 23.16 Players_Herbert_Jones + 31.78 Players_Immanuel_Quickley
 + 51.01 Players_Ja_Morant + 31.88 Players_Jakob_Poeltl
 + 41.2 Players_Jalen_Brunson + 34.59 Players_Jamal_Murray
 + 36.08 Players_Jaren_Jackson_Jr. + 42.45 Players_Jaylen_Brown
 + 52.94 Players_Jayson_Tatum + 25.1 Players_Jeremy_Sochan
 + 34.71 Players_Jonas_Valanciunas + 21.62 Players_Josh_Richardson
 + 35.32 Players_Jrue_Holiday + 49.74 Players_Julius_Randle
 + 21.61 Players_Keegan_Murray + 35.44 Players_Keldon_Johnson
 + 21.74 Players_Kentavious_Caldwell_Pope + 28.25 Players_Kevin_Huerter
 + 44.76 Players_Kristaps_Porzingis + 39.88 Players_Kyle_Kuzma
 + 53.05 Players_LeBron_James + 27.16 Players_Malcolm_Brogdon
 + 23.98 Players_Malik_Monk + 29.02 Players_Markelle_Fultz
 + 29.1 Players_Michael_Porter_Jr. + 27.48 Players_Mitchell_Robinson
 + 25.13 Players_Monte_Morris + 20.3 Players_Moritz_Wagner
 + 29.14 Players_Naji_Marshall + 61.52 Players_Nikola_Jokic
 + 37.51 Players_Nikola_Vucevic + 40.34 Players_Paolo_Banchero
 + 21.92 Players_Patrick_Williams + 23.48 Players_Quentin_Grimes
 + 23.88 Players_Robert_Williams + 23.25 Players_Rui_Hachimura
 + 37.11 Players_Russell_Westbrook + 29.5 Players_Steven_Adams
 + 31.78 Players_Thomas_Bryant + 32.4 Players_Tre_Jones
 + 22.56 Players_Trey_Murphy_III + 31.64 Players_Wendell_Carter_Jr.
 + 20.08 Players_Zach_Collins + 37.45 Players_Zach_LaVine
Subject To
C_Positional_Constraint: Players_Al_Horford + Players_Bobby_Portis
 + Players_Brook_Lopez + Players_Daniel_Gafford + Players_Domantas_Sabonis
 + Players_Giannis_Antetokounmpo + Players_Jakob_Poeltl
 + Players_Jaren_Jackson_Jr. + Players_Jonas_Valanciunas
 + Players_Kristaps_Porzingis + Players_Mitchell_Robinson
 + Players_Moritz_Wagner + Players_Nikola_Jokic + Players_Nikola_Vucevic
 + Players_Robert_Williams + Players_Steven_Adams + Players_Thomas_Bryant
 + Players_Wendell_Carter_Jr. + Players_Zach_Collins = 1
F_Positional_Constraint: Players_Aaron_Gordon + Players_Al_Horford
 + Players_Bobby_Portis + Players_Bruce_Brown + Players_DeMar_DeRozan
 + Players_Deni_Avdija + Players_Dillon_Brooks + Players_Franz_Wagner
 + Players_Giannis_Antetokounmpo + Players_Harrison_Barnes
 + Players_Herbert_Jones + Players_Jaren_Jackson_Jr. + Players_Jaylen_Brown
 + Players_Jayson_Tatum + Players_Jeremy_Sochan + Players_Julius_Randle
 + Players_Keegan_Murray + Players_Keldon_Johnson + Players_Kevin_Huerter
 + Players_Kristaps_Porzingis + Players_Kyle_Kuzma + Players_LeBron_James
 + Players_Michael_Porter_Jr. + Players_Moritz_Wagner + Players_Naji_Marshall
 + Players_Paolo_Banchero + Players_Patrick_Williams + Players_Quentin_Grimes
 + Players_Rui_Hachimura + Players_Trey_Murphy_III + Players_Zach_LaVine = 1
G_Positional_Constraint: Players_Bones_Hyland + Players_Bruce_Brown
 + Players_CJ_McCollum + Players_Cole_Anthony + Players_De'Aaron_Fox
 + Players_Dennis_Schroder + Players_Derrick_White + Players_Desmond_Bane
 + Players_Dillon_Brooks + Players_Franz_Wagner + Players_Immanuel_Quickley
 + Players_Ja_Morant + Players_Jalen_Brunson + Players_Jamal_Murray
 + Players_Jaylen_Brown + Players_Josh_Richardson + Players_Jrue_Holiday
 + Players_Kentavious_Caldwell_Pope + Players_Kevin_Huerter
 + Players_Malcolm_Brogdon + Players_Malik_Monk + Players_Markelle_Fultz
 + Players_Monte_Morris + Players_Quentin_Grimes + Players_Russell_Westbrook
 + Players_Tre_Jones + Players_Trey_Murphy_III + Players_Zach_LaVine = 1
PF_Positional_Constraint: Players_Aaron_Gordon + Players_Al_Horford
 + Players_Bobby_Portis + Players_DeMar_DeRozan
 + Players_Giannis_Antetokounmpo + Players_Harrison_Barnes
 + Players_Jaren_Jackson_Jr. + Players_Jayson_Tatum + Players_Jeremy_Sochan
 + Players_Julius_Randle + Players_Keegan_Murray + Players_Kristaps_Porzingis
 + Players_Kyle_Kuzma + Players_LeBron_James + Players_Moritz_Wagner
 + Players_Naji_Marshall + Players_Paolo_Banchero + Players_Patrick_Williams
 + Players_Rui_Hachimura = 1
PG_Positional_Constraint: Players_Bones_Hyland + Players_CJ_McCollum
 + Players_Cole_Anthony + Players_De'Aaron_Fox + Players_Dennis_Schroder
 + Players_Derrick_White + Players_Immanuel_Quickley + Players_Ja_Morant
 + Players_Jalen_Brunson + Players_Jamal_Murray + Players_Josh_Richardson
 + Players_Jrue_Holiday + Players_Malcolm_Brogdon + Players_Markelle_Fultz
 + Players_Monte_Morris + Players_Russell_Westbrook + Players_Tre_Jones = 1
SF_Positional_Constraint: Players_Bruce_Brown + Players_DeMar_DeRozan
 + Players_Deni_Avdija + Players_Dillon_Brooks + Players_Franz_Wagner
 + Players_Harrison_Barnes + Players_Herbert_Jones + Players_Jaylen_Brown
 + Players_Jayson_Tatum + Players_Keldon_Johnson + Players_Kevin_Huerter
 + Players_Kyle_Kuzma + Players_LeBron_James + Players_Michael_Porter_Jr.
 + Players_Naji_Marshall + Players_Paolo_Banchero + Players_Patrick_Williams
 + Players_Quentin_Grimes + Players_Trey_Murphy_III + Players_Zach_LaVine = 1
SG_Positional_Constraint: Players_Bones_Hyland + Players_Bruce_Brown
 + Players_Cole_Anthony + Players_Derrick_White + Players_Desmond_Bane
 + Players_Dillon_Brooks + Players_Franz_Wagner + Players_Immanuel_Quickley
 + Players_Jaylen_Brown + Players_Josh_Richardson
 + Players_Kentavious_Caldwell_Pope + Players_Kevin_Huerter
 + Players_Malcolm_Brogdon + Players_Malik_Monk + Players_Quentin_Grimes
 + Players_Trey_Murphy_III + Players_Zach_LaVine = 1
Salary_Constraints: 6600 Players_Aaron_Gordon + 4800 Players_Al_Horford
 + 6700 Players_Bobby_Portis + 4900 Players_Bones_Hyland
 + 5700 Players_Brook_Lopez + 5000 Players_Bruce_Brown
 + 8500 Players_CJ_McCollum + 5200 Players_Cole_Anthony
 + 4700 Players_Daniel_Gafford + 8700 Players_De'Aaron_Fox
 + 9000 Players_DeMar_DeRozan + 4200 Players_Deni_Avdija
 + 5700 Players_Dennis_Schroder + 5100 Players_Derrick_White
 + 6600 Players_Desmond_Bane + 5800 Players_Dillon_Brooks
 + 10500 Players_Domantas_Sabonis + 7100 Players_Franz_Wagner
 + 12000 Players_Giannis_Antetokounmpo + 5600 Players_Harrison_Barnes
 + 4900 Players_Herbert_Jones + 6200 Players_Immanuel_Quickley
 + 10300 Players_Ja_Morant + 5900 Players_Jakob_Poeltl
 + 8100 Players_Jalen_Brunson + 6800 Players_Jamal_Murray
 + 6800 Players_Jaren_Jackson_Jr. + 9500 Players_Jaylen_Brown
 + 10700 Players_Jayson_Tatum + 5000 Players_Jeremy_Sochan
 + 6600 Players_Jonas_Valanciunas + 4000 Players_Josh_Richardson
 + 7400 Players_Jrue_Holiday + 10400 Players_Julius_Randle
 + 4300 Players_Keegan_Murray + 7000 Players_Keldon_Johnson
 + 4400 Players_Kentavious_Caldwell_Pope + 5700 Players_Kevin_Huerter
 + 9400 Players_Kristaps_Porzingis + 8400 Players_Kyle_Kuzma
 + 10900 Players_LeBron_James + 5300 Players_Malcolm_Brogdon
 + 4500 Players_Malik_Monk + 6100 Players_Markelle_Fultz
 + 5900 Players_Michael_Porter_Jr. + 5200 Players_Mitchell_Robinson
 + 4800 Players_Monte_Morris + 5300 Players_Moritz_Wagner
 + 5500 Players_Naji_Marshall + 11700 Players_Nikola_Jokic
 + 8000 Players_Nikola_Vucevic + 8200 Players_Paolo_Banchero
 + 4400 Players_Patrick_Williams + 5400 Players_Quentin_Grimes
 + 4400 Players_Robert_Williams + 4700 Players_Rui_Hachimura
 + 7700 Players_Russell_Westbrook + 6000 Players_Steven_Adams
 + 6300 Players_Thomas_Bryant + 6000 Players_Tre_Jones
 + 5100 Players_Trey_Murphy_III + 6400 Players_Wendell_Carter_Jr.
 + 4700 Players_Zach_Collins + 7500 Players_Zach_LaVine <= 50000
UTIL_Positional_Constraint: Players_Aaron_Gordon + Players_Al_Horford
 + Players_Bobby_Portis + Players_Bones_Hyland + Players_Brook_Lopez
 + Players_Bruce_Brown + Players_CJ_McCollum + Players_Cole_Anthony
 + Players_Daniel_Gafford + Players_De'Aaron_Fox + Players_DeMar_DeRozan
 + Players_Deni_Avdija + Players_Dennis_Schroder + Players_Derrick_White
 + Players_Desmond_Bane + Players_Dillon_Brooks + Players_Domantas_Sabonis
 + Players_Franz_Wagner + Players_Giannis_Antetokounmpo
 + Players_Harrison_Barnes + Players_Herbert_Jones + Players_Immanuel_Quickley
 + Players_Ja_Morant + Players_Jakob_Poeltl + Players_Jalen_Brunson
 + Players_Jamal_Murray + Players_Jaren_Jackson_Jr. + Players_Jaylen_Brown
 + Players_Jayson_Tatum + Players_Jeremy_Sochan + Players_Jonas_Valanciunas
 + Players_Josh_Richardson + Players_Jrue_Holiday + Players_Julius_Randle
 + Players_Keegan_Murray + Players_Keldon_Johnson
 + Players_Kentavious_Caldwell_Pope + Players_Kevin_Huerter
 + Players_Kristaps_Porzingis + Players_Kyle_Kuzma + Players_LeBron_James
 + Players_Malcolm_Brogdon + Players_Malik_Monk + Players_Markelle_Fultz
 + Players_Michael_Porter_Jr. + Players_Mitchell_Robinson
 + Players_Monte_Morris + Players_Moritz_Wagner + Players_Naji_Marshall
 + Players_Nikola_Jokic + Players_Nikola_Vucevic + Players_Paolo_Banchero
 + Players_Patrick_Williams + Players_Quentin_Grimes + Players_Robert_Williams
 + Players_Rui_Hachimura + Players_Russell_Westbrook + Players_Steven_Adams
 + Players_Thomas_Bryant + Players_Tre_Jones + Players_Trey_Murphy_III
 + Players_Wendell_Carter_Jr. + Players_Zach_Collins + Players_Zach_LaVine = 1
Binaries
Players_Aaron_Gordon
Players_Al_Horford
Players_Bobby_Portis
Players_Bones_Hyland
Players_Brook_Lopez
Players_Bruce_Brown
Players_CJ_McCollum
Players_Cole_Anthony
Players_Daniel_Gafford
Players_De'Aaron_Fox
Players_DeMar_DeRozan
Players_Deni_Avdija
Players_Dennis_Schroder
Players_Derrick_White
Players_Desmond_Bane
Players_Dillon_Brooks
Players_Domantas_Sabonis
Players_Franz_Wagner
Players_Giannis_Antetokounmpo
Players_Harrison_Barnes
Players_Herbert_Jones
Players_Immanuel_Quickley
Players_Ja_Morant
Players_Jakob_Poeltl
Players_Jalen_Brunson
Players_Jamal_Murray
Players_Jaren_Jackson_Jr.
Players_Jaylen_Brown
Players_Jayson_Tatum
Players_Jeremy_Sochan
Players_Jonas_Valanciunas
Players_Josh_Richardson
Players_Jrue_Holiday
Players_Julius_Randle
Players_Keegan_Murray
Players_Keldon_Johnson
Players_Kentavious_Caldwell_Pope
Players_Kevin_Huerter
Players_Kristaps_Porzingis
Players_Kyle_Kuzma
Players_LeBron_James
Players_Malcolm_Brogdon
Players_Malik_Monk
Players_Markelle_Fultz
Players_Michael_Porter_Jr.
Players_Mitchell_Robinson
Players_Monte_Morris
Players_Moritz_Wagner
Players_Naji_Marshall
Players_Nikola_Jokic
Players_Nikola_Vucevic
Players_Paolo_Banchero
Players_Patrick_Williams
Players_Quentin_Grimes
Players_Robert_Williams
Players_Rui_Hachimura
Players_Russell_Westbrook
Players_Steven_Adams
Players_Thomas_Bryant
Players_Tre_Jones
Players_Trey_Murphy_III
Players_Wendell_Carter_Jr.
Players_Zach_Collins
Players_Zach_LaVine
End

When trying to .solve() this problem`:

prob.solve(plp.PULP_CBC_CMD(msg=0))
print(f'Status: {plp.LpStatus[prob.status]}')

score = str(prob.objective)
for v in prob.variables():
    score = score.replace(v.name, str(v.varValue))

score = eval(score)
lineup = [v.name for v in prob.variables() if v.varValue != 0]

print(score, lineup)

it outputs:

Status: Infeasible
23.570000000000004 ['Players_Giannis_Antetokounmpo', 'Players_Immanuel_Quickley', 'Players_Ja_Morant', 'Players_Jaylen_Brown', 'Players_Malcolm_Brogdon']

I know the issue lies within the positionality constraints, because commenting them out or altering them produces an optimal result.

Asked By: Sean Sailer

||

Answers:

You’ll need to re-index your problem with a second index such that the assignment binary variable is as:

assign[player, position]

currently you are double/triple counting people which is leading to the infeasibility. Specifically, if player X can play 3 positions, you are (inadvertently) assigning them to play all 3 positions at once, so when you total up by position the result is > 1, which busts your position constraint.

After you change your variable, then it will be easy to also sum across all positions for each player and ensure they are only assigned once, which will address the second issue of avoiding multiple assignments where feasible.

This is pretty similar, with an added twist, but is shows most of the general construct:

Python PULP optimization – Limiting total number of one variable chosen

And this:

Python PULP – Positional Constraints for a Lineup Generator

(I guess I’ve looked at a couple of these fantasy teams!)

Answered By: AirSquid