You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, 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
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)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I am writing a Linear Programming problem to help generate daily fantasy lineups.
The goal is:
The constraints are:
I have my problem set up like this:
Here are some of the example variables being referenced above
player_vars
player_vars = plp.LpVariable.dicts("Players", players, lowBound=0, cat='Binary')
projections
players
players = list(projections['Name'])
fpts, salaries, positions
Here is my
prob.writeLP()
output:When trying to
.solve()
this problem`:it outputs:
I know the issue lies within the positionality constraints, because commenting them out or altering them produces an optimal result.
Beta Was this translation helpful? Give feedback.
All reactions