Fixed averaged battle points calculation #45
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the points for the averaged battles are calculated incorrectly.
The current formula for the valuations where a higher valuations means you get a higher share of the point is
valuation = (len(ratios) / sum(ratios)) / len(ratios)
which simplifies tovaluation = 1 / sum(ratios)
. So to get more points you want a smaller sum of approximation ratios.This schema breaks when some, but not all, of the iterations were not solved by the solving team. Then the list of approximation ratios will have 0 entries since that is the default value assigned to unsolved instances. There is error handling for completely unsolved instances, but not for ones that are sometimes solved and sometimes not.
With this calculation it is better to e.g. not solve the problem 9 out of 10 times, but solve it very badly with an approx. ratio of 9 once (valuation 1/9), than to solve it perfectly every time (valuation 1/10).
As this is clearly not intended behaviour I made this PR to fix that bug and also incorporate a small amount of cleanup changes.
The new formula works by calculating the average reciprocal of the approx. ratios and setting unsolved instances to 0. This means that an unsolved instance will always be worse than a badly solved one. I have decided on this schema instead of eg giving the unsolved instances a very high approx. ratio because in the case of a team solving 9/10 instances very well but not solving 1 they should not be punished too harshly.
The rest of this PR is not essential to this fix, but should improve overall code readability in the future. The variable
points_per_iteration
does not actually track the iterations, but rather the number of rounds. These two terms are not used interchangably throughout the rest of the codebase so they should be differentiated here too.The other change is that previously each combination of teams had their points calculation done twice as it was done per permutation instead. This does not change the output as it previously was done twice and the value halved.