some small changes to the evaluation scripts
This commit is contained in:
parent
275c2d933e
commit
5b93233915
1 changed files with 15 additions and 8 deletions
|
|
@ -6,6 +6,7 @@ from csv import writer
|
||||||
from typing import Tuple, List
|
from typing import Tuple, List
|
||||||
import re
|
import re
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
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 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]]:
|
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 }"
|
full_path = f"{ path }/{ file }"
|
||||||
time, pop = parse_file(full_path)
|
time, pop = parse_file(full_path)
|
||||||
|
|
||||||
total_pops = sum(pop)
|
total_pops = sum(pop)/len(pop)
|
||||||
|
|
||||||
results[name] = (total_pops, time)
|
results[name] = (total_pops, time)
|
||||||
|
|
||||||
|
|
@ -61,19 +62,25 @@ with open("times.csv", "w+") as times_file:
|
||||||
|
|
||||||
pops.writerow([name, *pop])
|
pops.writerow([name, *pop])
|
||||||
rel_pops = list()
|
rel_pops = list()
|
||||||
|
abs_pops = list()
|
||||||
rel_time = list()
|
rel_time = list()
|
||||||
|
abs_time = list()
|
||||||
labels = list()
|
labels = list()
|
||||||
|
|
||||||
# base_pops = results["dijkstra"][0]
|
|
||||||
# base_time = results["dijkstra"][1]
|
|
||||||
base_pops = results["greedy_64_1"][0]
|
pprint(results)
|
||||||
base_time = results["greedy_64_1"][1]
|
baseline = "dijkstra"
|
||||||
|
base_pops = results[baseline][0]
|
||||||
|
base_time = results[baseline][1]
|
||||||
|
|
||||||
for name, values in results.items():
|
for name, values in results.items():
|
||||||
pops, time = values
|
pops, time = values
|
||||||
labels.append(name)
|
labels.append(name)
|
||||||
rel_pops.append(pops/base_pops)
|
rel_pops.append(pops/base_pops)
|
||||||
rel_time.append(time/base_time)
|
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
|
width = 0.35 # the width of the bars
|
||||||
|
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
rects1 = ax.bar(x - width/2, rel_time , width, label='time')
|
rects1 = ax.bar(x - width/2, abs_time , width, label='time')
|
||||||
rects2 = ax.bar(x + width/2, rel_pops, width, label='pops')
|
# rects2 = ax.bar(x + width/2, abs_pops, width, label='pops')
|
||||||
|
|
||||||
ax.legend()
|
ax.legend()
|
||||||
ax.set_xticks(x, labels)
|
ax.set_xticks(x, labels)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue