constructive

This commit is contained in:
UmbertoJr 2019-11-18 08:25:41 +01:00
parent 6be767267d
commit 77ebc9016c

View file

@ -33,15 +33,13 @@ class nearest_neighbor:
@staticmethod @staticmethod
def best_nn(self, instance_): def best_nn(self, instance_):
solutions, lens = [], [] solutions, lens = [], []
for start in range(self.instance.nPoints): for start in range(instance_.nPoints):
new_solution = self.nn(instance_, starting_node=start) new_solution = self.nn(instance_, starting_node=start)
solutions.append(new_solution) solutions.append(new_solution)
assert self.check_if_solution_is_valid(new_solution), "error on best_nn method" lens.append(compute_lenght(new_solution, instance_.dist_matrix))
lens.append(self.evaluate_solution(return_value=True))
self.solution = solutions[np.argmin(lens)] solution = solutions[np.argmin(lens)]
self.solved = True return solution
return self.solution
class multi_fragment: class multi_fragment: