BenBrostoff / draftfast

A tool to automate and optimize DraftKings and FanDuel lineup construction.
277 stars 113 forks source link

Exposure Settings help #186

Closed bluh32 closed 2 years ago

bluh32 commented 2 years ago

I am having trouble getting the Expsoure Random to work. .

rosters, _ = run_multi( iterations=10, rule_set=rules.DK_NBA_RULE_SET, player_pool=player_pool, exposure_bounds=exposures, exposure_random_seed=1, verbose=True, )

When I remove the exposure_random_seed argument it runs fine and optimizes with total exposure mins/maxes. I am trying to test out the difference of using the random exposure piece of the code. Any help would be greatly appreciated, sorry if I am just completely missing the point here.

I get 'No Solution Found Error' when I try to plug in the random_seed.

Thanks

BenBrostoff commented 2 years ago

@bluh32 Can you try some other numbers in the seed and let me know if you get the same result? We do test this scenario specifically here https://github.com/BenBrostoff/draftfast/blob/master/draftfast/test/test_exposure.py#L50 . One thing to know about run_multi is that you can make optimization impossible depending on what is passed into exposure_bounds. I would also suggest messing around with this to see if a specific bound is causing problems.

Additionally, on any interrupted optimization run, you can see what parameters caused No Solution Found. If your player pool doesn't have enough of one position as an example (ex. you need at least one QB and all QBs are removed from the pool), you'll get No Solution Found.

For advanced use cases where you want to reliably produce lineups and keep going if No Solution happens (for example, add players back into the pool given a No Solution), I'd recommend not using run_multi and instead iterate, append to existing_lineups and change OptimizerSettings or exposure_dict.

Let me know if this makes sense.

bluh32 commented 2 years ago

hey @BenBrostoff, appreciate the response. When I remove the bounds from the argument list, it runs with random_seed -- I guess I just don't understand what is happening in that scenario. Is it just completely random exposure caps each interation?

I uploaded the bounds as all Min 0, Max 1 just to test if there was some sort of error. I will take a look at some of the example files describing some of the other advanced use cases.

One more question if you don't mind answering, thanks again for the help. If I upload a randomization factor is it applied on like each iteration or does it just change everyones projections one time?

BenBrostoff commented 2 years ago

So exposure_random_seed won't actually modify projections - it just makes random who is locked on each iteration, as locking is necessary to increase players who need more exposure allocated to:

def get_exposure_args_random(exposures, exposure_bounds, n,
                             random_seed) -> dict:
    locked = []

    for bound in exposure_bounds:
        name = bound['name']

        # TODO: maybe exclude players who have met max exposure?
        # randomly lock in players based on the desired exposure
        # TODO - downsize locked so solution is not impossible
        r = random.random()
        if r <= bound['max']:
            locked.append(name)

    return {
        'banned': [],
        'locked': locked,
    }

If you want to randomize projections, check out randomize in PlayerPoolSettings. This factor (which you pass as a decimal from 0 to 1) will randomize each player in the pool's projections by the factor (so if 35%, 35% above or below the projection).