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

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

Open
rickenrocker24 opened this issue Sep 20, 2022 · 5 comments
Open

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

rickenrocker24 opened this issue Sep 20, 2022 · 5 comments
Assignees

Comments

@rickenrocker24
Copy link

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_

@rickenrocker24 rickenrocker24 changed the title NFL: Try adjusting your query by taking away constraints NFL FD: Try adjusting your query by taking away constraints Sep 20, 2022
@BenBrostoff
Copy link
Owner

BenBrostoff commented Sep 20, 2022 via email

@rickenrocker24
Copy link
Author

rickenrocker24 commented Sep 20, 2022

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

@BenBrostoff
Copy link
Owner

BenBrostoff commented Sep 20, 2022 via email

@BenBrostoff
Copy link
Owner

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.

@BenBrostoff BenBrostoff self-assigned this Sep 21, 2022
@rickenrocker24
Copy link
Author

Thank you so much, this will get me going

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

2 participants