11"""Wrapper that iterates the instance size up to a point where the solving team is no longer able to solve an instance."""
22
3+ import itertools
34import logging
45
56from algobattle .battle_wrapper import BattleWrapper
@@ -43,9 +44,9 @@ def wrapper(self, match, options: dict = {}) -> None:
4344 def calculate_points (self , match_data : dict , achievable_points : int ) -> dict :
4445 """Calculate the number of achieved points, given results.
4546
46- The valuation of an averaged battle is the number of successfully
47- executed battles divided by the average competitive ratio of successful
48- battles, to account for failures on execution .
47+ The valuation of an averaged battle is calculating by summing up
48+ the reciprocals of each solved fight. This sum is then divided by
49+ the total number of ratios to account for unsuccessful battles .
4950
5051 Parameters
5152 ----------
@@ -68,14 +69,15 @@ def calculate_points(self, match_data: dict, achievable_points: int) -> dict:
6869 team_names = set ()
6970 for pair in team_pairs :
7071 team_names = team_names .union (set ((pair [0 ], pair [1 ])))
72+ team_combinations = itertools .combinations (team_names , 2 )
7173
7274 if len (team_names ) == 1 :
7375 return {team_names .pop (): achievable_points }
7476
7577 if match_data ['rounds' ] <= 0 :
7678 return {}
77- points_per_iteration = round (achievable_points / match_data ['rounds' ], 1 )
78- for pair in team_pairs :
79+ points_per_round = round (achievable_points / match_data ['rounds' ], 1 )
80+ for pair in team_combinations :
7981 for i in range (match_data ['rounds' ]):
8082 points [pair [0 ]] = points .get (pair [0 ], 0 )
8183 points [pair [1 ]] = points .get (pair [1 ], 0 )
@@ -86,9 +88,9 @@ def calculate_points(self, match_data: dict, achievable_points: int) -> dict:
8688 valuation0 = 0
8789 valuation1 = 0
8890 if ratios0 and sum (ratios0 ) != 0 :
89- valuation0 = ( len ( ratios0 ) / sum ( ratios0 ) ) / len (ratios0 )
91+ valuation0 = sum ( 1 / x if x != 0 else 0 for x in ratios0 ) / len (ratios0 )
9092 if ratios1 and sum (ratios1 ) != 0 :
91- valuation1 = ( len ( ratios1 ) / sum ( ratios1 ) ) / len (ratios1 )
93+ valuation1 = sum ( 1 / x if x != 0 else 0 for x in ratios1 ) / len (ratios1 )
9294
9395 # Default values for proportions, assuming no team manages to solve anything
9496 points_proportion0 = 0.5
@@ -99,8 +101,8 @@ def calculate_points(self, match_data: dict, achievable_points: int) -> dict:
99101 points_proportion0 = (valuation0 / (valuation0 + valuation1 ))
100102 points_proportion1 = (valuation1 / (valuation0 + valuation1 ))
101103
102- points [pair [0 ]] += round (points_per_iteration * points_proportion0 , 1 ) / 2
103- points [pair [1 ]] += round (points_per_iteration * points_proportion1 , 1 ) / 2
104+ points [pair [0 ]] += round (points_per_round * points_proportion0 , 1 )
105+ points [pair [1 ]] += round (points_per_round * points_proportion1 , 1 )
104106
105107 return points
106108
0 commit comments