diff --git a/src/io_tsp.py b/src/io_tsp.py index c1256cc..51b24e0 100644 --- a/src/io_tsp.py +++ b/src/io_tsp.py @@ -50,12 +50,13 @@ class ProblemInstance: print('best_sol: ' + str(self.best_sol)) print('exist optimal: ' + str(self.exist_opt)) - def plot_data(self): + def plot_data(self,show_numbers=False): plt.figure(figsize=(8, 8)) plt.title(self.name) plt.scatter(self.points[:, 1], self.points[:, 2]) - for i, txt in enumerate(np.arange(self.nPoints)): # tour_found[:-1] - plt.annotate(txt, (self.points[i, 1], self.points[i, 2])) + if show_numbers: + for i, txt in enumerate(np.arange(self.nPoints)): # tour_found[:-1] + plt.annotate(txt, (self.points[i, 1], self.points[i, 2])) plt.show() def create_dist_matrix(self): diff --git a/src/utils.py b/src/utils.py index e09ab5b..e6b90f8 100644 --- a/src/utils.py +++ b/src/utils.py @@ -11,7 +11,9 @@ def compute_length(solution, dist_matrix): return total_length -def distance_euc(zi, zj): - xi, xj = zi[0], zj[0] - yi, yj = zi[1], zj[1] - return round(np.sqrt((xi - xj) ** 2 + (yi - yj) ** 2), 0) +def distance_euc(point_i, point_j): + rounding=0 + x_i, y_i = point_i[0], point_i[1] + x_j, y_j = point_j[0], point_j[1] + distance = np.sqrt((x_i - x_j) ** 2 + (y_i - y_j) ** 2) + return round(distance, rounding)