some smaller edits

This commit is contained in:
Dario Mantegazza 2020-10-12 11:43:27 +02:00
parent f2eaab99dc
commit a0971e647f
2 changed files with 10 additions and 7 deletions

View file

@ -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):

View file

@ -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)