DimaKudosh / pydfs-lineup-optimizer

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

Feature Request: Lineup fill method for Max_Exposure #57

Open kpm1988 opened 5 years ago

kpm1988 commented 5 years ago

Would it be possible to add an option to check max_exposure as each lineup is generated rather than for the full group?

Let's say there are only two players at a position that both have the same salary but different point projections, and max_exposure set to 50% for both. Currently if 10 lineups are generated the first 5 would have the higher ranked player. With this option, you'd have the higher ranked player in every other lineup, since the lower ranked player would get selected as soon as the lineup pool has >50% exposure to the first player, rather than meeting the requirement at the end of generating the lineups.

DimaKudosh commented 5 years ago

It's make sense, but it's problem that optimizer generates each lineup separately, and on each step I setup a new solver with new set of constraints and it returns most optimal lineup, it's how ILP works and I can't change it. It will be possible if we represent generating of many lineups as one task for solver but it much harder and I'm not sure that it will work correctly with existing optimizer rules. I'll discover this issue later.

utahman commented 5 years ago

@kpm1988, The resulting lineups will be a bit worse than those currently generated. Worse in the sum of projections.

bigboyz commented 4 years ago

I believe this is why MIN is not working for me on multiple players. Am I correct to assume that the min constraints are being applied to the first lineups generated so all the requirements are completed first and then the optimizer ignores any constraints.

Example: If my min requirements are 50% QB Tom Brady 30% WR Tyreek Hill 20% WR Odell Beckham 10% WR Corey Davis

And I tell the optimizer to build 10 lineups

LINEUP #1 will always include Tom Brady Tyreek Hill Odell Beckham Corey Davis

LINEUP #2 will always have Tom Brady Tyreek Hill Odell Beckham

LINEUP #3 will always have Tom Brady Tyreek Hill

LINEUP #4/5 will always have Tom Brady

Then Lineups #6-10 may or may not have any of the above players.

The problem that this method creates is it is ignoring potential optimal lineups by fullfilling all the constraints as quick as possible. An example of this might be when it is not optimal to put Tyreek Hill and Odell Beckham in the same lineup. Let's say they are both very highly priced and by taking both it will limit too many other opportutines. I want exposure to both players, but not at the cost of non-optimal lineups. The solver has plenty of lineups to fullfill the 30% and 20% requirements and ideally could detect that none of the top lineups include both players.

Another similar example would be basketball. What if I want 30% exposure to Luka Doncic, Lebron James, and James Harden. If I tell the optimizer to build 10 lineups I am going to get all three players in my first 3 lineups and I guarantee that lineup will suck as their is no money left to spend on the remaining players. It would be such a huge improvement if the optimizer didn't stick all three in the first three lineups in order to satisfy the constraint of 30% and instead spread out those players amongst all the lineups. Possibly a top lineup might include 2 on some slates, but I'd be surprised if you could fit $36,000 in salary cost and still stay under cap and be competitive.

Anyone, have any good ideas on how to solve the MIN problem?