This commit is contained in:
UmbertoJr 2019-10-31 16:08:29 +01:00
parent 69e9aa4c81
commit d4a251006d
2 changed files with 4 additions and 2 deletions

5
run.py
View file

@ -3,7 +3,8 @@ import os
def run(show_plots=False):
names = [name_ for name_ in os.listdir("./problems") if "tsp" in name_]
# names = [name_ for name_ in os.listdir("./problems") if "tsp" in name_]
names = ["ch130.tsp"]
for name in names:
print("\n\n#############################")
filename = f"problems/{name}"
@ -22,4 +23,4 @@ def run(show_plots=False):
if __name__ == '__main__':
run()
run(show_plots=True)

View file

@ -53,6 +53,7 @@ class Solver_TSP:
plt.title(self.instance.name)
ordered_points = self.instance.points[self.solution]
plt.plot(ordered_points[:, 1], ordered_points[:, 2], 'b-')
plt.show()
def check_if_solution_is_valid(self, solution):
rights_values = np.sum([self.check_validation(i, solution[:-1]) for i in np.arange(self.instance.nPoints)])