From e6b125bed1be8c885e565d9ece6acd3c7104bb6b Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 9 May 2023 23:58:04 -0700 Subject: [PATCH] mostly superficial cleanup --- thursday/go_benchmark_it.py | 50 +++++++++++++++---------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/thursday/go_benchmark_it.py b/thursday/go_benchmark_it.py index 5b4ae7f..c1bedec 100644 --- a/thursday/go_benchmark_it.py +++ b/thursday/go_benchmark_it.py @@ -254,16 +254,10 @@ def main(argv, display=True): old_summary = True note = (lambda s: None) if quieter else m36 - if 1: - multiple = 2 - run_anyway = 3 # run_anyway = 7 - always_run_anyway = True - else: - multiple = 1 - run_anyway = 3 - always_run_anyway = False + multiple = 2 + run_anyway = 3 + always_run_anyway = True - # percents = dict(frugal_percent=0.1, greedy_percent=1.5) percents = dict(frugal_percent=1.0, greedy_percent=2.0) which = parties[argv[1]] if len(argv) > 1 else parties["standard"] @@ -272,6 +266,7 @@ def main(argv, display=True): place_names = ("1st", "2nd", "3rd", "4th") place_scores = (5, 3, 2, 1) + assert size < 0, "unsupported in this version" size = abs(size) objectives = GO_BENCHMARKS[size] # * multiple @@ -349,29 +344,24 @@ def main(argv, display=True): scores.setdefault(opt_name, 0.0) prices.setdefault(opt_name, 0.0) sorted_res = sorted(all_res) - score_insignificance = sum( - len(all_res[fopt]) for _, fopt in zip(range(len(place_scores)), sorted_res) - ) - price_insignificance = sum( - len(all_res[fopt]) - for _, fopt in zip(range(len(place_scores)), reversed(sorted_res)) - ) + places = min(len(place_names), len(place_scores)) + score_insignificance = sum(len(all_res[fopt]) for fopt in sorted_res[:places]) + price_insignificance = sum(len(all_res[fopt]) for fopt in sorted_res[-places:]) # print("score 1/x:", obj_name, score_insignificance) # print("price 1/x:", obj_name, price_insignificance) - for i, fopt in enumerate(sorted_res): - # if i >= len(place_scores): # TODO: just make this part of the loop. - # break - mi = len(all_res) - i - 1 - if i < len(place_scores): - for opt_i, opt_name in enumerate(all_res[fopt]): - scores[opt_name] += place_scores[i] / score_insignificance - if display and summarize_each_objective: - print_place(i, all_res[fopt], "best") - if mi < len(place_scores): - for opt_i, opt_name in enumerate(all_res[fopt]): - prices[opt_name] += place_scores[mi] / price_insignificance - if display and summarize_each_objective: - print_place(mi, all_res[fopt], "worst") + + for i, fopt in enumerate(sorted_res[:places]): + for opt_i, opt_name in enumerate(all_res[fopt]): + scores[opt_name] += place_scores[i] / score_insignificance + if display and summarize_each_objective: + print_place(i, all_res[fopt], "best") + + for i, fopt in enumerate(sorted_res[-places:]): + mi = places - i - 1 + for opt_i, opt_name in enumerate(all_res[fopt]): + prices[opt_name] += place_scores[mi] / price_insignificance + if display and summarize_each_objective: + print_place(mi, all_res[fopt], "worst") if display: more_scores = perform_another_experimental_scoring_method(results)