update
This commit is contained in:
parent
9acede718b
commit
69aadb3d29
1 changed files with 7 additions and 5 deletions
12
run.py
12
run.py
|
@ -2,21 +2,23 @@ from code import *
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def run():
|
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_]
|
||||||
for name in names:
|
for name in names:
|
||||||
|
print("\n\n#############################")
|
||||||
filename = f"problems/{name}"
|
filename = f"problems/{name}"
|
||||||
instance = Instance(filename)
|
instance = Instance(filename)
|
||||||
instance.print_info()
|
instance.print_info()
|
||||||
print(" --- ")
|
|
||||||
instance.plot_data()
|
|
||||||
|
|
||||||
solver = Solver_TSP('random')
|
solver = Solver_TSP('random')
|
||||||
naive_solution = solver(instance)
|
solver(instance, return_value=False)
|
||||||
solver.plot_solution()
|
|
||||||
print(f"the total length for the solution found is {solver.evaluate_solution()}",
|
print(f"the total length for the solution found is {solver.evaluate_solution()}",
|
||||||
f"while the optimal length is {instance.best_sol}",
|
f"while the optimal length is {instance.best_sol}",
|
||||||
f"the gap is {solver.gap} %", sep="\n")
|
f"the gap is {solver.gap} %", sep="\n")
|
||||||
|
if show_plots:
|
||||||
|
instance.plot_data()
|
||||||
|
solver.plot_solution()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Reference in a new issue