clean up display of old scoring method

This commit is contained in:
Connor Olding 2023-05-09 23:51:02 -07:00
parent cb01f794cd
commit 3365a182b5

View file

@ -189,6 +189,12 @@ def main(argv, display=True):
else " "
)
def print_place(ind, names, which="best"):
color = "\033[32m" if which == "best" else "\033[31m"
reset, placed, tied = "\033[m", place_names[ind], " \033[90m(tied)\033[m"
for i, name in enumerate(sorted(set(names))):
print(tied if i else f" {color}{placed}:{reset}", name)
def fancy_output(opt_name, score, price):
name = opt_name.removesuffix("_cube")
if type(score) is float:
@ -243,9 +249,10 @@ def main(argv, display=True):
reset = "\033[m"
quieter = True
please_stop_the_spam = True
no_summary = True
quieter = False
summarize_each_objective = True
old_summary = True
note = (lambda s: None) if quieter else m36
if 1:
multiple = 2
@ -264,9 +271,9 @@ def main(argv, display=True):
budget = int(argv[3]) if len(argv) > 3 else fib(abs(size) + 4) * 10
place_names = ("1st", "2nd", "3rd", "4th")
place_scores = (5, 3, 2, 1)
assert size < 0, "unsupported in this version"
size = abs(size)
place_scores = (5, 3, 2, 1)
objectives = GO_BENCHMARKS[size] # * multiple
optimizers = list(which) # copy
ms = f" ({multiple}+{run_anyway-multiple} times)" if multiple != 1 else ""
@ -303,8 +310,6 @@ def main(argv, display=True):
fopt, xopt, history = cache
results.setdefault(obj_name, []).append((fopt, opt_name, history))
note = (lambda s: None) if quieter else m36
once = False
while (
run <= multiple
@ -329,12 +334,12 @@ def main(argv, display=True):
run += 1
all_results = results
results = prune_results(results, multiple, _check=not no_summary)
results = prune_results(results, multiple, _check=old_summary)
scores, prices = {}, {}
all_opt_names = set()
for obj_name, obj_res in results.items():
if display and not please_stop_the_spam:
if display and summarize_each_objective:
print()
m1(f"{obj_name}:")
all_res = {}
@ -358,21 +363,21 @@ def main(argv, display=True):
# break
mi = len(all_res) - i - 1
if i < len(place_scores):
for opt_name in all_res[fopt]:
scores[opt_name] = (
scores[opt_name] + place_scores[i] / score_insignificance
)
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_name in all_res[fopt]:
prices[opt_name] = (
prices[opt_name] + place_scores[mi] / price_insignificance
)
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)
for blah, points in zip(("best", "worst"), (scores, prices)):
if display and not no_summary:
if display and old_summary:
print(
f"\n\033[1m{blah} scoring optimizers:\033[m"
f" (awards={place_scores})"
@ -382,7 +387,7 @@ def main(argv, display=True):
for opt_name, opt_point in sorted(points.items(), key=lambda t: -t[1]):
# place = place_names[i] if i < len(place_names) else " "
# delta = scores.get(opt_name, 0) - prices.get(opt_name, 0)
if display and not no_summary:
if display and old_summary:
print(
fancy_output(
opt_name, scores.get(opt_name, 0), prices.get(opt_name, 0)
@ -400,7 +405,7 @@ def main(argv, display=True):
if opt_name not in negative:
negative.append(opt_name)
if display and no_summary:
if display and not old_summary:
print(
f"\n\033[1malternatively scored optimizers:\033[m"
f" (awards={place_scores})"