This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
AICup/run.py

23 lines
651 B
Python
Raw Normal View History

2019-10-23 19:07:20 +00:00
from code import *
def run():
names = [name_ for name_ in os.listdir("./problems") if "tsp" in name_]
for name in names:
filename = f"problems/{name}"
instance = Instance(filename)
instance.print_info()
print(" --- ")
instance.plot_data()
2019-10-23 19:12:59 +00:00
solver = Solver_TSP('random')
naive_solution = solver(instance)
solver.plot_solution()
print(f"the total length for the solution found is {solver.evaluate_solution()}",
f"while the optimal length is {instance.best_sol}",
f"the gap is {solver.gap} %", sep="\n")
2019-10-23 19:11:32 +00:00
2019-10-23 19:07:20 +00:00
if __name__ == '__main__':
run()