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

Update max free transfers to 5 #680

Merged
merged 10 commits into from
Sep 18, 2024
Merged

Update max free transfers to 5 #680

merged 10 commits into from
Sep 18, 2024

Conversation

jack89roberts
Copy link
Contributor

@jack89roberts jack89roberts commented Jul 24, 2024

Updates the optimisation code so that:

  • Up to 5 free transfers can be saved in the logic around computing points hits and dropping strategies that leave transfers unused.

    • I think the current main branch would actually raise an error if a user has saved more than 2 transfers, as we sanity-checked for free transfers being 0, 1, or 2 before. At minimum it would incorrectly compute points hits in cases where a user had saved more than 2 transfers.
  • Adds max_opt_transfers and max_free_transfers to various optimisation functions:

    • max_free_transfers is the maximum allowable free transfers in the game rules (now 5).
    • max_opt_transfers is the maximum number of transfers to allow the optimisation to make each week. This still defaults to 2. At the command line the value of --max_transfers is passed to max_opt_transfers.
  • If optimising more than 2 transfers, calls make_random_transfers, which uses the value of num_iterations to decide the number of attempts. For the current AIrsenal squad I didn't manage to get anything that beats the brute force 2 transfer optimisation.

  • Fixes a bug in computing free transfers & hit so far for the next strategies in the optimisation tree: See commit be3d6d9. I've not fully got my head around this but I believe this is a long-standing bug in AIrsenal that has slipped by unnoticed as it was less likely to cause issues when limited to making 2 transfers. However, I think it could have made AIrsenal under-estimate points hits and therefore more likely to suggest making 2 transfers.

    • In very loose pseudocode, the issue came from this logic lurking in optimize for updating the tree/next strategies:
    free_transfers = calc_free_transfers(free_transfers, ...)
    strategies = next_week_transfers(free_transfers, ...)

    but next_week_transfers itself already calls calc_free_transfers, so you could incorrectly end up with an extra free transfer available in the strategy.

@jack89roberts jack89roberts marked this pull request as ready for review July 25, 2024 13:07
@jack89roberts
Copy link
Contributor Author

Currently seems to hang at the end of optimisation - probably count_expected_outputs is wrong somehow.

relies on baseline strategy being first if present
@jack89roberts
Copy link
Contributor Author

I think I've fixed one bug with counting the baseline strategy, but it still hangs. The optimisation seems to be running strategies that should be excluded because they take too many hits (0-3-3, 3-0-3) for a test run allowing 3 transfers/8pts hits. If I set max hit to a large value so it doesn't impact things it terminates successfully.

Already handled by `next_week_transfers` when computing new strategies to add to the queue.

Doing this twice before is probably a long standing bug. Could have meant we were over-estimating free transfers available, and therefore under-counting hits.
Copy link
Member

@nbarlowATI nbarlowATI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work Jack!!
Code changes look sensible, the tests all run for me, and a quick test going 2 weeks ahead for optimization with max_transfers=5 runs OK, so I think we should merge, and in the not-too-distant future I will try and have a think/play with some other method for knowing when to stop, rather than the current method of counting the expected outputs.....

@nbarlowATI nbarlowATI merged commit 35c136a into develop Sep 18, 2024
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants