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

Sporadic "squad is incomplete" errors in optimisation #469

Closed
jack89roberts opened this issue Jan 18, 2022 · 2 comments · Fixed by #468
Closed

Sporadic "squad is incomplete" errors in optimisation #469

jack89roberts opened this issue Jan 18, 2022 · 2 comments · Fixed by #468
Labels
bug Something isn't working

Comments

@jack89roberts
Copy link
Contributor

jack89roberts commented Jan 18, 2022

Happened near the end of the optimisation in the last gameweek (and then causes optimisation to hang as at least one of the strategies didn't create an output file). Not sure of the cause but has come up before. Perhaps either:

  • Transfer functions failing to find a way to improve the initial squad (but I think this would usually lead to a different error, e.g. best_squad undefined).
  • Something weird about the behaviour of adding and removing players in the Squad class - I think I remember seeing this error before and just the process of investigating it (without making changes apart from print statements etc.) seemed to fix it...
Traceback (most recent call last):█████████████████▍        | 76.19047619047603/100 [21:34<01:15,  3.19s/it]
  File "/Users/jroberts/opt/anaconda3/envs/airsenalenv/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap-1-2-1:  93%|███████████████████████████████▋  | 93.33333333333334/100 [21:43<00:11,  1.67s/it]
    self.run()2-0-2:  37%|████████████▎                    | 37.142857142857125/100 [21:21<00:04, 13.07it/s]
  File "/Users/jroberts/opt/anaconda3/envs/airsenalenv/lib/python3.8/multiprocessing/process.py", line 108, in rungy: 1-2-0-2-2:  29%|█████████▍                       | 28.571428571428573/100 [21:37<02:00,  1.69s/it]
    self._target(*self._args, **self._kwargs)              | 24.761904761904763/100 [21:38<02:59,  2.38s/it]
  File "/Users/jroberts/GitHub/AIrsenal/airsenal/scripts/fill_transfersuggestion_table.py", line 185, in optimizeegy: 2-1-0-1-2:  93%|███████████████████████████████▋  | 93.33333333333312/100 [21:42<00:16,  2.41s/it]
    new_squad, transfers, points = make_best_transfers(     | 69.52380952380939/100 [21:31<00:00, 43.74it/s]
  File "/Users/jroberts/GitHub/AIrsenal/airsenal/framework/optimization_transfers.py", line 339, in make_best_transfers
    new_squad, players_out, players_in = make_optimum_single_transfer(
  File "/Users/jroberts/GitHub/AIrsenal/airsenal/framework/optimization_transfers.py", line 84, in make_optimum_single_transfer
    total_points += new_squad.get_expected_points(
  File "/Users/jroberts/GitHub/AIrsenal/airsenal/framework/squad.py", line 366, in get_expected_points
    self.optimize_lineup(gameweek, tag)
  File "/Users/jroberts/GitHub/AIrsenal/airsenal/framework/squad.py", line 353, in optimize_lineup
    raise RuntimeError("Squad is incomplete")
@jack89roberts jack89roberts added the bug Something isn't working label Jan 18, 2022
@jack89roberts
Copy link
Contributor Author

jack89roberts commented Feb 11, 2022

In the loop below, if we fail to find a valid replacement player then new_squad will be incomplete after the loop:

new_squad.remove_player(p_out.player_id, gameweek=transfer_gw)
for p_in in ordered_player_lists[position]:
if p_in[0].player_id == p_out.player_id:
continue # no point in adding the same player back in
added_ok = new_squad.add_player(p_in[0], gameweek=transfer_gw)
if added_ok:
if verbose:
print("Added player {}".format(p_in[0].name))
break
else:
if verbose:
print("Failed to add {}".format(p_in[0].name))

Though it seems unlikely that we wouldn't find a single valid player to replace someone with (perhaps if the original player is the cheapest available in that position).

@jack89roberts
Copy link
Contributor Author

Failing to replace the cheapest available player does seem to be the problem in this case - the original squad contains Tsimikas, currently the cheapest player in the game at £3.7m and so can't be replaced unless the squad has money in the bank.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant