some smaller edits
This commit is contained in:
parent
f2eaab99dc
commit
a0971e647f
2 changed files with 10 additions and 7 deletions
|
@ -50,10 +50,11 @@ class ProblemInstance:
|
||||||
print('best_sol: ' + str(self.best_sol))
|
print('best_sol: ' + str(self.best_sol))
|
||||||
print('exist optimal: ' + str(self.exist_opt))
|
print('exist optimal: ' + str(self.exist_opt))
|
||||||
|
|
||||||
def plot_data(self):
|
def plot_data(self,show_numbers=False):
|
||||||
plt.figure(figsize=(8, 8))
|
plt.figure(figsize=(8, 8))
|
||||||
plt.title(self.name)
|
plt.title(self.name)
|
||||||
plt.scatter(self.points[:, 1], self.points[:, 2])
|
plt.scatter(self.points[:, 1], self.points[:, 2])
|
||||||
|
if show_numbers:
|
||||||
for i, txt in enumerate(np.arange(self.nPoints)): # tour_found[:-1]
|
for i, txt in enumerate(np.arange(self.nPoints)): # tour_found[:-1]
|
||||||
plt.annotate(txt, (self.points[i, 1], self.points[i, 2]))
|
plt.annotate(txt, (self.points[i, 1], self.points[i, 2]))
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
10
src/utils.py
10
src/utils.py
|
@ -11,7 +11,9 @@ def compute_length(solution, dist_matrix):
|
||||||
return total_length
|
return total_length
|
||||||
|
|
||||||
|
|
||||||
def distance_euc(zi, zj):
|
def distance_euc(point_i, point_j):
|
||||||
xi, xj = zi[0], zj[0]
|
rounding=0
|
||||||
yi, yj = zi[1], zj[1]
|
x_i, y_i = point_i[0], point_i[1]
|
||||||
return round(np.sqrt((xi - xj) ** 2 + (yi - yj) ** 2), 0)
|
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)
|
||||||
|
|
Reference in a new issue