BenBrostoff / draftfast

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

NFL FD: Try adjusting your query by taking away constraints #198

Open rickenrocker24 opened 1 year ago

rickenrocker24 commented 1 year ago

Running into No Solution found on the output when I use the below usage - what am I missing?

from os import environ from draftfast import rules from draftfast.optimize import run_multi from draftfast.csv_parse import salary_download, uploaders

players = salary_download.generate_players_from_csvs( salary_file_location='./NFL_SALS.csv', projection_file_location='./NFL_PROJECTIONS.csv', game=rules.FAN_DUEL,)

rosters, _ = run_multi( iterations=3, rule_set=rules.FD_NFL_RULE_SET, player_pool=players, verbose=True )

Output:

_No solution found. Try adjusting your query by taking away constraints.

OPTIMIZER CONSTRAINTS:

Min teams: 2

LINEUP CONSTRAINTS:

None

PLAYER POOL SETTINGS:

None

PLAYER COUNT: 1602_

BenBrostoff commented 1 year ago

Do you mind attaching the CSVs you’re using? I can take a look and work on debugging

On Tue, Sep 20, 2022 at 6:12 PM c0inigr @.***> wrote:

Running into No Solution found on the output when I use the below usage - what am I missing?

from os import environ from draftfast import rules from draftfast.optimize import run_multi from draftfast.csv_parse import salary_download, uploaders

players = salary_download.generate_players_from_csvs( salary_file_location='./NFL_SALS.csv', projection_file_location='./NFL_PROJECTIONS.csv', game=rules.FAN_DUEL,)

rosters, _ = run_multi( iterations=3, rule_set=rules.FD_NFL_RULE_SET, player_pool=players, verbose=True )

Output:

_No solution found. Try adjusting your query by taking away constraints.

OPTIMIZER CONSTRAINTS:

Min teams: 2

LINEUP CONSTRAINTS:

None

PLAYER POOL SETTINGS:

None

PLAYER COUNT: 1602_

— Reply to this email directly, view it on GitHub https://github.com/BenBrostoff/draftfast/issues/198, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVK35DUARMDT4CQY634L5DV7IZFZANCNFSM6AAAAAAQRP5IXU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

rickenrocker24 commented 1 year ago

Here you go, thanks for looking into this. NFL_PROJECTIONS.csv NFL_SALS.csv

BenBrostoff commented 1 year ago

Thank you, will take a look

On Tue, Sep 20, 2022 at 6:47 PM c0inigr @.***> wrote:

NFL_PROJECTIONS.csv https://github.com/BenBrostoff/draftfast/files/9611681/NFL_PROJECTIONS.csv NFL_SALS.csv https://github.com/BenBrostoff/draftfast/files/9611682/NFL_SALS.csv

— Reply to this email directly, view it on GitHub https://github.com/BenBrostoff/draftfast/issues/198#issuecomment-1252992958, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVK35DEFFME2ODYQ2I57ZLV7I5JPANCNFSM6AAAAAAQRP5IXU . You are receiving this because you commented.Message ID: @.***>

BenBrostoff commented 1 year ago

I can repro; it looks like there are a few issues here that require a library update (1 - DEF not in lookup dict for FD, 2 - FLEX not an ordered position), should be able to get to it this week. In the short term, you can modify the positions to get this to work (issue is that DEF is defense in FD):

from os import environ
from draftfast.orm import NFLRoster
from draftfast import rules
from draftfast.optimize import run
from draftfast.csv_parse import salary_download

POSITION_ORDER = {
        'QB': 0,
        'RB': 1,
        'WR': 2,
        'TE': 3,
        'DST': 4,
        'D': 5,
        'FLEX': 6
    }

def sorted_players(self):
    return sorted(
        self.players,
        key=lambda p: POSITION_ORDER[p.pos]
    )

NFLRoster.sorted_players = sorted_players

players = salary_download.generate_players_from_csvs(
    salary_file_location='./NFL_SALS.csv',
    projection_file_location='./NFL_PROJECTIONS.csv',
    game=rules.FAN_DUEL
)
for x in players:
    if x.pos == 'DEF':
        x.pos = 'D'

roster = run(
    rule_set=rules.FD_NFL_RULE_SET,
    player_pool=players,
    verbose=True
)

The above works for me and I think in the short term will allow you to generate lineups.

rickenrocker24 commented 1 year ago

Thank you so much, this will get me going