DimaKudosh / pydfs-lineup-optimizer

Daily Fantasy Sports lineup optimzer for all popular daily fantasy sports sites
MIT License
424 stars 157 forks source link

Multi-positional eligibility #6

Closed sansbacon closed 7 years ago

sansbacon commented 7 years ago

From reviewing the code, I can't tell if the optimizer handles multi-position eligibility

rneu31 commented 7 years ago

I do not believe so. I looked at this in the past and ended up writing my own from scratch.

On Mon, Mar 13, 2017, 6:31 PM Eric Truett notifications@github.com wrote:

From reviewing the code, I can't tell if the optimizer handles multi-position eligibility

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DimaKudosh/pydfs-lineup-optimizer/issues/6, or mute the thread https://github.com/notifications/unsubscribe-auth/AFpAH359ZN7PEZ7w5JKf0g-4qpWN5Y9pks5rldHDgaJpZM4Mb8kf .

sansbacon commented 7 years ago

What constraints did you add? No more than 1 of a player ID?

sansbacon commented 7 years ago

If you add a player multiple times to the pool for different positions, you could create a constraint like this. for pid in set([p.id for p in players]): prob += sum([x[player] for player in players if player.id == pid]) <= 1

DimaKudosh commented 7 years ago

I'll look into it on weekends.

brendanahart commented 7 years ago

Kudos to the optimizer that was created, it really is a great solution, efficien, is very customizable, and fits my exact needs. I just wanted to second that I am still encountering this issue where a player with multiple positions will be added to the lineup as a member of both those positions.

A work around I found was adding the player twice to the pool, assigning them a unique id, then creating a constraint in the optimizer listed above (this was inserted into the optimizer function):

for pid in set([p.id for p in players]):
                prob += lpSum([x[player] for player in players if player.id == pid]) <= 1
DimaKudosh commented 7 years ago

What version of library you use? It should be fixed in latest version.

brendanahart commented 7 years ago

I'm running version 1.1.2 of the library and python 2.7

DimaKudosh commented 7 years ago

Can you provide info about site and sport and players list sample?