Skip to content

OptiNobles/tsp-simulated-annealing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

tsp-simulated-annealing

Simulated annealing optimizer designed to solve Travelling Salesman Problem (TSP). Working of this optimizer consists of three stages:

  • Stage 1: Greedy algorithm provides an initial solution,
  • Stage 2: Simulated Annealing searches solutions space,
  • Stage 3: 2-Opt algorithm improves the solution obtained in stage 2. (optional)

DEMO

  • Input should be in the form of a list [ [x_1, y_1], [x_2, y_2], ... , [x_n, y_n] ]
from random import randint

towns = []

for town in range(60):
    towns.append([randint(0, 100), randint(0, 100)])
  • How to initialize
from SimulatedAnnealing import SimulatedAnnealing

SA_optimizer = SimulatedAnnealing()
SA_optimizer.fit(towns, iterations=60000, cooling='polynomial', improve=True)
  • Plotting results
SA_optimizer.plot()

plot_output_SAO

  • Visualization
SA_optimizer.show_graph(fitted=True)

graph_output_SAO

Releases

No releases published

Packages

No packages published

Languages