Creating a constraint that changes the optimization based off what the model is solving. #342
-
It is currently my first time using the PuLP library in python. The purpose of diving into this library was to make a fantasy football solver in python. I have successfully made the solver but cant figure out how to add a few constraints I need. I have an excel sheet of 400 players and how I project them to play, and I want to find the optimal combination of 9 players given specific constraints. The excel sheet holds, player name, player projection, team player is on, opponent player is facing, and position. Below is what the head of the panda data frame looks like.
The constraints i have done successfully: limit a max of 9 players are selected, only 1 person of position QB, 3-4 of position WR, 1-2 of position TE, 1 position DST, and 2-3 position RB.
The constraints I am trying to add and cant figure out how: have 2 players of the 9 selected be on the same team as the QB, the opponent of the DST cant be anyone of the 9's team, have 1 players opponent be the QB's team. Any idea how I would do this? This data is in my excel file but I'm not sure how to add these constraints to the model? Ive been looking through the cases in the documentation and i cant find any examples where the optimal output is changed based off what the model picks. Example: if picks a quarterback, it affects the rest of the 8 players being selected. Appreciate any help anyone can provide me. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hello! You seemed to have cross posted in stack overflow ? https://stackoverflow.com/questions/64094589/python-pulp-optimization-problem-for-fantasy-football-how-to-add-certain-condit In that case you can paste the solution if it indeed helped you. Next time, please add the link to the question in both sides, so not to repeat efforts. To my surprise, there are a lot of questions and answers about fantasy football, pandas and pulp in stack overflow, most similar one to the other... (maybe a course, a test or an interview screening?) so you can also look at other questions... |
Beta Was this translation helpful? Give feedback.
-
you are currently getting help on stack overflow with you issue and Jacob seems to be very knowledgeable so I'd keep asking there. |
Beta Was this translation helpful? Give feedback.
-
Feel free to cross - post, it's okay. Just remember to add the link to the
other site.
Good luck!
…On Tue, Sep 29, 2020, 21:39 Stuart Mitchell ***@***.***> wrote:
you are currently getting help on stack overflow with you issue and Jacob
seems to be very knowledgeable so I'd keep asking there.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#342 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJUZ43YN6CLBKBS4VH6LT3SIIZW7ANCNFSM4R35CZRQ>
.
|
Beta Was this translation helpful? Give feedback.
you are currently getting help on stack overflow with you issue and Jacob seems to be very knowledgeable so I'd keep asking there.