forked from sergiogh/tsp_mayhem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (26 loc) · 937 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import time
import importlib
from tsp_utilities import *
##############################################
## ADD HERE YOUR NEW SOLVERS CLASSES #########
##############################################
active_solvers = ["Bruteforce",
#"Dwave_tsp",
"TSP_genetico"]
##############################################
##############################################
def main():
starting_node = 0
nodes = 5
G = get_graph(nodes)
cost_matrix = get_cost_matrix(G, nodes)
for solver_ in active_solvers:
ClassName = getattr(importlib.import_module("solvers."+solver_.lower()), solver_)
instance = ClassName()
route = instance.calculate(G, cost_matrix, starting_node)
print("Route for %s:" % solver_)
print(route)
print("Cost: %s" % calculate_cost(cost_matrix, route))
draw_tsp_solution(G, route)
if __name__ == '__main__':
main()