-
Notifications
You must be signed in to change notification settings - Fork 166
Description
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?