some small changes to the evaluation scripts

This commit is contained in:
Johannes Erwerle 2022-09-16 17:14:45 +02:00
parent 275c2d933e
commit 5b93233915

View file

@ -6,6 +6,7 @@ from csv import writer
from typing import Tuple, List
import re
import numpy as np
from pprint import pprint
import matplotlib.pyplot as plt
@ -17,7 +18,7 @@ path = argv[1]
files = [f for f in os.listdir(path) if os.path.isfile(f"{ path }/{f}")]
files = [f for f in files if re.match(r"greedy_64_.+", f) is not None ]
# files = [f for f in files if re.match(r"greedy_64_.+", f) is not None ]
def parse_file(file: str) -> Tuple[float, List[int]]:
@ -53,7 +54,7 @@ with open("times.csv", "w+") as times_file:
full_path = f"{ path }/{ file }"
time, pop = parse_file(full_path)
total_pops = sum(pop)
total_pops = sum(pop)/len(pop)
results[name] = (total_pops, time)
@ -61,19 +62,25 @@ with open("times.csv", "w+") as times_file:
pops.writerow([name, *pop])
rel_pops = list()
abs_pops = list()
rel_time = list()
abs_time = list()
labels = list()
# base_pops = results["dijkstra"][0]
# base_time = results["dijkstra"][1]
base_pops = results["greedy_64_1"][0]
base_time = results["greedy_64_1"][1]
pprint(results)
baseline = "dijkstra"
base_pops = results[baseline][0]
base_time = results[baseline][1]
for name, values in results.items():
pops, time = values
labels.append(name)
rel_pops.append(pops/base_pops)
rel_time.append(time/base_time)
abs_pops.append(pops)
abs_time.append(time)
@ -81,8 +88,8 @@ x = np.arange(len(labels)) # the label locations
width = 0.35 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, rel_time , width, label='time')
rects2 = ax.bar(x + width/2, rel_pops, width, label='pops')
rects1 = ax.bar(x - width/2, abs_time , width, label='time')
# rects2 = ax.bar(x + width/2, abs_pops, width, label='pops')
ax.legend()
ax.set_xticks(x, labels)