solver
This commit is contained in:
parent
de3e3f0793
commit
904ce65413
2 changed files with 2 additions and 1 deletions
1
run.py
1
run.py
|
@ -34,6 +34,7 @@ def run(show_plots=False):
|
||||||
|
|
||||||
if instance.optimal_tour:
|
if instance.optimal_tour:
|
||||||
solver.solution = np.concatenate([instance.optimal_tour, [instance.optimal_tour[0]]])
|
solver.solution = np.concatenate([instance.optimal_tour, [instance.optimal_tour[0]]])
|
||||||
|
solver.method = "optimal"
|
||||||
solver.plot_solution()
|
solver.plot_solution()
|
||||||
|
|
||||||
index = pd.MultiIndex.from_tuples(index, names=['problem', 'method'])
|
index = pd.MultiIndex.from_tuples(index, names=['problem', 'method'])
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Solver_TSP:
|
||||||
assert self.solved, "You can't plot the solution, you need to solve it first!"
|
assert self.solved, "You can't plot the solution, you need to solve it first!"
|
||||||
plt.figure(figsize=(8, 8))
|
plt.figure(figsize=(8, 8))
|
||||||
self._gap()
|
self._gap()
|
||||||
plt.title(f"{self.instance.name} solved with {self.method}, gap {self.gap}")
|
plt.title(f"{self.instance.name} solved with {self.method} solver, gap {self.gap}")
|
||||||
ordered_points = self.instance.points[self.solution]
|
ordered_points = self.instance.points[self.solution]
|
||||||
plt.plot(ordered_points[:, 1], ordered_points[:, 2], 'b-')
|
plt.plot(ordered_points[:, 1], ordered_points[:, 2], 'b-')
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
Reference in a new issue