This commit is contained in:
UmbertoJr 2019-10-31 16:54:17 +01:00
parent 69c29e47b2
commit 4269a1b45a
2 changed files with 3 additions and 3 deletions

View file

@ -39,7 +39,7 @@ class Solver_TSP:
def nn(self, instance_, starting_node=0): def nn(self, instance_, starting_node=0):
dist_matrix = np.copy(instance_.dist_matrix) dist_matrix = np.copy(instance_.dist_matrix)
n = int(instance_.nPoints) n = int(instance_.nPoints)
node = np.argmin([starting_node]) node = starting_node
tour = [node] tour = [node]
for _ in range(n - 1): for _ in range(n - 1):
for new_node in np.argsort(dist_matrix[node]): for new_node in np.argsort(dist_matrix[node]):
@ -100,4 +100,4 @@ class Solver_TSP:
def _gap(self): def _gap(self):
self.evaluate_solution(return_value=False) self.evaluate_solution(return_value=False)
self.gap = np.round((self.found_length - self.instance.best_sol) / self.instance.best_sol * 100, 2) self.gap = np.round(((self.found_length - self.instance.best_sol) / self.instance.best_sol) * 100, 2)

View file

@ -25,7 +25,7 @@ class Instance:
# store data set information # store data set information
self.name = self.lines[0].split(' ')[2] self.name = self.lines[0].split(' ')[2]
self.nPoints = np.int(self.lines[3].split(' ')[2]) self.nPoints = np.int(self.lines[3].split(' ')[2])
self.best_sol = np.int(self.lines[5].split(' ')[2]) self.best_sol = np.float(self.lines[5].split(' ')[2])
# read all data points and store them # read all data points and store them
self.points = np.zeros((self.nPoints, 3)) self.points = np.zeros((self.nPoints, 3))