in scheme_adapters/pso_adapter/pso_adapter.py [0:0]
def run_best_workload(self, scheme):
new_scheme = ""
ind = 0
for key in self.params:
if scheme[ind] < 0:
new_scheme += str(self.convert(self.ranges[key])) + "\t"
elif "age" in key:
new_scheme += str(round(scheme[ind])) + "us" + "\t"
elif "size" in key:
new_scheme += str(round(scheme[ind])) + "B" + "\t"
else:
new_scheme += str(round(scheme[ind])) + "\t"
ind += 1
new_scheme += self.ranges["action"]
file_name = self.damoos_path + "/scheme_adapters/pso_adapter/scheme"
scheme_file = open(file_name, "w")
scheme_file.write(new_scheme)
scheme_file.close()
best_score = 0
for i in range(3):
pid = self.run_workload()
subprocess.Popen(["sudo", "python3", self.damos_path, "schemes", "--schemes", file_name, str(pid)])
collected = self.get_metric(pid, self.metrics)
command = ["bash", self.damoos_path + "/scheme_adapters/pso_adapter/" + self.score_func_path]
for metric in self.metrics:
name = metric.split(";")[0]
command.append(str(self.workload_info[0][name]))
command.append(str(collected[name]))
res = subprocess.check_output(command)
score = str(res).split("'")[1][0:-2]
best_score += float(score)
print("Best Score:",best_score/3 )