From 69aadb3d297c86ab58370f6f236047cf23b8b810 Mon Sep 17 00:00:00 2001 From: UmbertoJr Date: Wed, 23 Oct 2019 21:19:38 +0200 Subject: [PATCH] update --- run.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/run.py b/run.py index 11401dc..73c7f16 100644 --- a/run.py +++ b/run.py @@ -2,21 +2,23 @@ from code import * import os -def run(): +def run(show_plots=False): names = [name_ for name_ in os.listdir("./problems") if "tsp" in name_] for name in names: + print("\n\n#############################") filename = f"problems/{name}" instance = Instance(filename) instance.print_info() - print(" --- ") - instance.plot_data() solver = Solver_TSP('random') - naive_solution = solver(instance) - solver.plot_solution() + solver(instance, return_value=False) + print(f"the total length for the solution found is {solver.evaluate_solution()}", f"while the optimal length is {instance.best_sol}", f"the gap is {solver.gap} %", sep="\n") + if show_plots: + instance.plot_data() + solver.plot_solution() if __name__ == '__main__':