diff --git a/run.py b/run.py index 4d62172..0fe88ac 100644 --- a/run.py +++ b/run.py @@ -51,7 +51,9 @@ def run(show_plots=False, verbose=False): solver.pop() if prob_instance.exist_opt and show_plots: - solver.algorithm_name="optimal" + solver = SolverTSP("optimal", prob_instance) + # solver.name_method = "optimal" # TODO ask umberto details + solver.solution = np.concatenate([prob_instance.optimal_tour, [prob_instance.optimal_tour[0]]]) solver.plot_solution() diff --git a/src/TSP_solver.py b/src/TSP_solver.py index 2562102..70261fa 100644 --- a/src/TSP_solver.py +++ b/src/TSP_solver.py @@ -24,7 +24,7 @@ class SolverTSP: found_length: float def __init__(self, algorithm_name, problem_instance): - assert algorithm_name in available_solvers, f"the {algorithm_name} initializer is not available currently." + # assert algorithm_name in available_solvers, f"the {algorithm_name} initializer is not available currently." self.duration = np.inf self.algorithm_name = algorithm_name self.algorithms = [algorithm_name] diff --git a/src/io_tsp.py b/src/io_tsp.py index 551380f..c2676a1 100644 --- a/src/io_tsp.py +++ b/src/io_tsp.py @@ -16,7 +16,7 @@ class ProblemInstance: def __init__(self, name_tsp): self.read_instance(name_tsp) - self.exist_opt = None # TODO determine default value + self.exist_opt = False # TODO determine default value self.optimal_tour = None def read_instance(self, name_tsp): @@ -40,8 +40,7 @@ class ProblemInstance: self.points[i, 2] = line_i[2] self.create_dist_matrix() - self.exist_opt = False - if [name for name in ["eil76", "kroA100"] if name in name_tsp]: + if name_tsp in ["./problems/eil76.tsp", "./problems/kroA100.tsp"]: self.exist_opt = True file_object = open(name_tsp.replace(".tsp", ".opt.tour")) data = file_object.read()