Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting min_exposure in Fanduel Single Game #433

Open
EdCarGoes opened this issue Oct 21, 2024 · 1 comment
Open

Setting min_exposure in Fanduel Single Game #433

EdCarGoes opened this issue Oct 21, 2024 · 1 comment

Comments

@EdCarGoes
Copy link

EdCarGoes commented Oct 21, 2024

Hello again. I think I'm really close to adding a workaround to be able to lock players in the single-game formats with MVP and FLEX.

Below is an example where I am testing to try and force Derrick Henry into a certain number of lineups with a specified exposure in the MVP slot and a different specified exposure for one of the FLEX slots. Note: fdpos is a dataframe with just names an positions, used to look up a player's given position in a full slate. In this case it returns RB.

mvp_player = optimizer.player_pool.get_player_by_name('Derrick Henry', 'MVP')
mvp_player.min_exposure = .1
original_position = fdpos.loc[fdpos['Nickname'] == 'Derrick Henry', 'Position'].iloc[0]
flex_player = optimizer.player_pool.get_player_by_name('Derrick Henry', original_position)
flex_player.min_exposure = .3
force_group = PlayersGroup((mvp_player,flex_player), max_from_group=1)
optimizer.add_players_group(force_group)

When I run this I get the error:

Exception has occurred: GenerateLineupException
Can't generate lineups. Following constraints are not valid: total_players,unique_player_Derrick_Henry

So it looks like the force_group is not being applied successfully. Does anyone know why?

Changing mvp_player.min_exposure to 0 works as expected and 30% of the returned lineups feature Derrick Henry in a flex position. And inversely, if I set flex_player.min_exposure to 0 I get 10% of lineups with Derrick Henry as MVP. So again, it seems like the max_from_group is being ignored and it's trying to make at least one lineup with Derrick Henry in both the MVP and FLEX slots. What is the correct solution here?

@EdCarGoes EdCarGoes changed the title Setting min_expossure in Fanduel Single Game Setting min_exposure in Fanduel Single Game Oct 21, 2024
@EdCarGoes
Copy link
Author

EdCarGoes commented Oct 22, 2024

For whatever it's worth, the lines at the bottom of this post do successfully implement total max exposure and specific MVP slot max exposure. I now believe the min exposure issue is that it's trying to insert all specified min exposure players at the end of the run.

For example if I'm asking it for 10 lineups and I want to force Derrick Henry (assuming he is not naturally exposed in any lineups before the min exposure rule) into 30% of lineups as FLEX and 10% of lineups as MVP. It looks like it's building the first 7 lineups naturally and then starting at #8 it forces him in at FLEX for the last three lineups. But then on lineup 10 it tries to squeeze in the one lineup with him at MVP. Then there are two Derrick Henrys and it breaks. Is this a solver priority thing? Is there a way to adjust that?

Here's the successful overall and MVP-specific max exposure lines.

for Nickname in dfinfo['Nickname']:
    mvp_player = optimizer.player_pool.get_player_by_name(Nickname, 'MVP')
    mvp_player.max_exposure = max_exposure*mvp_max_exposure
    original_position = fdpos.loc[fdpos['Nickname'] == Nickname, 'Position'].iloc[0]
    flex_player = optimizer.player_pool.get_player_by_name(Nickname, original_position)
    max_group = PlayersGroup((mvp_player,flex_player),max_from_group=1)
    max_group.max_exposure = max_exposure
    optimizer.add_players_group(max_group)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant