Skip to content
Snippets Groups Projects
Commit ea283caa authored by gospodnetic's avatar gospodnetic
Browse files

Output best results to the table

parent 4f76cd4b
No related branches found
No related tags found
No related merge requests found
......@@ -57,16 +57,16 @@ class Benchmark:
tex_file.write("\n& \makecell{{{}}}".format(method))
for model in models:
# self.log_container_per_model[model].get_best_log()
logs = self.log_container_per_model[model].get_logs_by_method(method)
if len(logs) == 0:
try:
best_log = self.log_container_per_model[model].get_best_log(method)
except:
tex_file.write(" & - & - & - & -")
continue
VPC_count = logs[0].VPC["count"] + logs[0].VPC["discarded_count"]
VPC_used = logs[0].VPC["count"]
OVP = len(logs[0].optimization["OVP"])
coverage = util.set_precision(logs[0].coverage["percent_fraction"] * 100, 2)
VPC_count = best_log.VPC["count"] + best_log.VPC["discarded_count"]
VPC_used = best_log.VPC["count"]
OVP = len(best_log.optimization["OVP"])
coverage = util.set_precision(best_log.coverage["percent_fraction"] * 100, 2)
tex_file.write(" & {} & {} & {} & {}".format(VPC_count, VPC_used, OVP, coverage))
tex_file.write("\\\\")
......
import Log
import pprint
from enum import Enum
class LogContainer:
def __init__(self, methods_per_approach):
......@@ -13,12 +14,6 @@ class LogContainer:
self.__parse_methods_per_approach()
def __parse_methods_per_approach(self):
self.approaches_per_method = {}
for approach in self.methods_per_approach:
for method in self.methods_per_approach[approach]:
self.approaches_per_method[method] = approach
def add_log(self, log):
method = log.VPC["method"]
if method in self.approaches_per_method:
......@@ -51,3 +46,63 @@ class LogContainer:
method_logs.append(log)
return method_logs
# Log which obtains coverage over 99% with minimal number of viewpoint candidates
# If no log obrains coverage over 99%, the log with the greatest coverage is considered.
def get_best_log(self, method):
method_logs = self.get_logs_by_method(method)
if len(method_logs) == 0:
raise Exception("Error: No logs available for given method ({})".format(method))
# Find logs with coverage >99%.
high_coverage_logs = self.__filter_coverage_threshold(method_logs, 0.99, ComparisonType.GEQ)
if len(high_coverage_logs) > 0:
return self.max_coverage_log(high_coverage_logs)
else:
return self.max_coverage_log(method_logs)
def max_coverage_log(self, input_logs=None):
if not input_logs:
input_logs = self.logs
if len(input_logs) == 0:
raise Exception("Error: no logs available.")
max_coverage = input_logs[0].coverage["percent_fraction"]
max_log = input_logs[0]
for log in input_logs:
if log.coverage["percent_fraction"] > max_coverage:
max_log = log
return max_log
def __parse_methods_per_approach(self):
self.approaches_per_method = {}
for approach in self.methods_per_approach:
for method in self.methods_per_approach[approach]:
self.approaches_per_method[method] = approach
# Find logs which have coverage greater or equal to the given threshold.
# threshold is given as a fraction (e.g. 0.99)
def __filter_coverage_threshold(self, input_logs, threshold, comparison_type):
filtered_logs = []
for log in input_logs:
if comparison_type == ComparisonType.G:
if log.coverage["percent_fraction"] > threshold:
filtered_logs.append(log)
elif comparison_type == ComparisonType.GEQ:
if log.coverage["percent_fraction"] >= threshold:
filtered_logs.append(log)
elif comparison_type == ComparisonType.LEQ:
if log.coverage["percent_fraction"] <= threshold:
filtered_logs.append(log)
elif comparison_type == ComparisonType.L:
if log.coverage["percent_fraction"] < threshold:
filtered_logs.append(log)
return filtered_logs
class ComparisonType(Enum):
G = 0 # >
GEQ = 1 # >=
LEQ = 2 # <=
L = 3 # <
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment