3737from airsenal .framework .optimization_transfers import make_best_transfers
3838from airsenal .framework .optimization_utils import (
3939 MAX_FREE_TRANSFERS ,
40- calc_points_hit ,
4140 check_tag_valid ,
4241 count_expected_outputs ,
4342 fill_suggestion_table ,
@@ -131,7 +130,15 @@ def optimize(
131130 else :
132131 profiler = None
133132
134- num_transfers , free_transfers , hit_so_far , squad , strat_dict , sid = status
133+ (
134+ num_transfers ,
135+ free_transfers ,
136+ hit_so_far ,
137+ hit_this_gw ,
138+ squad ,
139+ strat_dict ,
140+ sid ,
141+ ) = status
135142 # num_transfers will be 0, 1, 2, OR 'W' or 'F', OR 'T0', T1', 'T2',
136143 # OR 'B0', 'B1', or 'B2' (the latter six represent triple captain or
137144 # bench boost along with 0, 1, or 2 transfers).
@@ -203,18 +210,17 @@ def optimize(
203210 (updater , increment , pid ) if updater is not None else None ,
204211 )
205212
206- points_hit = calc_points_hit (num_transfers , free_transfers )
213+ # points_hit = calc_points_hit(num_transfers, free_transfers)
207214 discount_factor = get_discount_factor (root_gw , gw )
208- points -= points_hit * discount_factor
215+ points -= hit_this_gw * discount_factor
209216 strat_dict ["total_score" ] += points
210217 strat_dict ["points_per_gw" ][gw ] = points
211218 strat_dict ["free_transfers" ][gw ] = free_transfers
212219 strat_dict ["num_transfers" ][gw ] = num_transfers
213- strat_dict ["points_hit" ][gw ] = points_hit
220+ strat_dict ["points_hit" ][gw ] = hit_this_gw
214221 strat_dict ["discount_factor" ][gw ] = discount_factor
215222 strat_dict ["players_in" ][gw ] = transfers ["in" ]
216223 strat_dict ["players_out" ][gw ] = transfers ["out" ]
217-
218224 depth += 1
219225
220226 if depth >= len (gameweek_range ):
@@ -240,16 +246,15 @@ def optimize(
240246 chips = chips_gw_dict [gw + 1 ],
241247 max_free_transfers = max_free_transfers ,
242248 )
243-
244249 for strat in strategies :
245- # strat: (num_transfers, free_transfers, hit_so_far)
246- num_transfers , free_transfers , hit_so_far = strat
250+ num_transfers , free_transfers , hit_so_far , hit_this_gw = strat
247251
248252 queue .put (
249253 (
250254 num_transfers ,
251255 free_transfers ,
252256 hit_so_far ,
257+ hit_this_gw ,
253258 new_squad ,
254259 strat_dict ,
255260 sid ,
@@ -319,7 +324,8 @@ def print_strat(strat: dict) -> None:
319324 print (" ===============================================" )
320325 for gw in gameweeks_as_int :
321326 print (f"\n =========== Gameweek { gw } ================\n " )
322- print (f"Chips played: { strat ['chips_played' ][str (gw )]} \n " )
327+ print (f"Chips played: { strat ['chips_played' ][str (gw )]} " )
328+ print (f"Points Hits: { strat ['points_hit' ][str (gw )]} \n " )
323329 print ("Players in:\t \t \t Players out:" )
324330 print ("-----------\t \t \t ------------" )
325331 for i in range (len (strat ["players_in" ][str (gw )])):
@@ -493,6 +499,7 @@ def run_optimization(
493499 apifetcher = fetcher ,
494500 is_replay = is_replay ,
495501 )
502+ print (f"Starting with { num_free_transfers } free transfers" )
496503
497504 # create the output directory for temporary json files
498505 # giving the points prediction for each strategy
@@ -596,7 +603,7 @@ def update_progress(increment=1, index=None):
596603 processor .start ()
597604 procs .append (processor )
598605 # add starting node to the queue
599- squeue .put ((0 , num_free_transfers , 0 , starting_squad , {}, "starting" ))
606+ squeue .put ((0 , num_free_transfers , 0 , 0 , starting_squad , {}, "starting" ))
600607
601608 for i , p in enumerate (procs ):
602609 progress_bars [i ].close ()
0 commit comments