From 77ebc9016ca8e6a192dfe839e879a115d78badb9 Mon Sep 17 00:00:00 2001 From: UmbertoJr Date: Mon, 18 Nov 2019 08:25:41 +0100 Subject: [PATCH] constructive --- src/constructive_algorithms.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/constructive_algorithms.py b/src/constructive_algorithms.py index ddf1d19..4f5a556 100644 --- a/src/constructive_algorithms.py +++ b/src/constructive_algorithms.py @@ -33,15 +33,13 @@ class nearest_neighbor: @staticmethod def best_nn(self, instance_): solutions, lens = [], [] - for start in range(self.instance.nPoints): + for start in range(instance_.nPoints): new_solution = self.nn(instance_, starting_node=start) solutions.append(new_solution) - assert self.check_if_solution_is_valid(new_solution), "error on best_nn method" - lens.append(self.evaluate_solution(return_value=True)) + lens.append(compute_lenght(new_solution, instance_.dist_matrix)) - self.solution = solutions[np.argmin(lens)] - self.solved = True - return self.solution + solution = solutions[np.argmin(lens)] + return solution class multi_fragment: