-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
24 lines (20 loc) · 744 Bytes
/
Copy pathrun.py
File metadata and controls
24 lines (20 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from tsp import Cities
from tsp import SimulatedAnnealing
from tsp import GeneticAlgorithm
if __name__ == '__main__':
print 'Travleing Salesman Problem'
print 'Please select an algorithm:'
print '1 - Simulated Annealing'
print '2 - Genetic Algorithm'
selection = raw_input('Selection: ')
cities = Cities()
if selection == '1':
sa = SimulatedAnnealing(cities.generate_random_state(), cities.generate_distance_matrix())
state, distance = sa.anneal()
print state
print distance
elif selection == '2':
ga = GeneticAlgorithm(cities.generate_random_state(), cities.generate_distance_matrix())
tour, distance = ga.simulate()
print tour
print distance