-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathrun_example.py
39 lines (37 loc) · 1.56 KB
/
run_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pulp
from nhl.fanduel import Fanduel as NHLFanduel
from nhl.draftkings import Draftkings as NHLDraftkings
"""EXAMPLE SHOWING HOW TO RUN THE NHL OPTIMIZER"""
while True:
site = input("Select 1 for Draftkings or 2 for Fanduel: ")
if site not in ('1', '2'):
print('Try Again...')
continue
print()
# set the optimizer based on the user input for the site
if site == '1':
#enter the parameters
optimizer = NHLDraftkings(num_lineups=150,
overlap=4,
solver=pulp.CPLEX_PY(msg=0),
players_filepath = 'nhl/example_inputs/players_inputs/player_17791.csv',
goalies_filepath = 'nhl/example_inputs/goalies_inputs/goalie_17791.csv',
output_filepath = 'nhl/example_output_draftkings.csv')
else:
#enter the parameters
optimizer = NHLFanduel(num_lineups=150,
overlap=4,
solver=pulp.CPLEX_PY(msg=0),
players_filepath = 'nhl/example_inputs/players_inputs/player_17791.csv',
goalies_filepath = 'nhl/example_inputs/goalies_inputs/goalie_17791.csv',
output_filepath = 'nhl/example_output_fanduel.csv')
#create the indicators used to set the constraints to be used by the formula
optimizer.create_indicators()
#generate the lineups with the formula and the indicators
lineups = optimizer.generate_lineups(formula=optimizer.type_1)
#fill the lineups with player names - send in the positions indicator
filled_lineups = optimizer.fill_lineups(lineups)
#save the lineups
optimizer.save_file(optimizer.header, filled_lineups)
optimizer.save_file(optimizer.header, filled_lineups, show_proj=True)
break