Skip to content

🏃🏻‍♂️Travelling Salesman Problem solved with a Genetic Algorithm in Python

Notifications You must be signed in to change notification settings

pparuzel/Genetic-Algorithm-TSP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travelling Salesman Problem

Tested on Python version: 3.7

Important: If you want to use your own coordinates for GraphicsBased TSP please note that function map_cities_onto_screen needs to be changed as it is hardcoded towards showing Poland.

Average generations to solution:

  • With graphics about 20k (population_size=20)
  • With text about 600 (population_size=100)

Text-based TSP

The program shows the cities of Poland based on a real latitude and longitude.
Possibility of adding more cities.
There are two modes available - time-bounded or repetition-bounded:

GeneticAlgorithm.run(seconds=NUMBER_OF_SECONDS)
GeneticAlgorithm.run(reps=NUMBER_OF_REPETITIONS)

Graphics-based TSP

Similar to the text-based program.
Press SPACE to toggle program PAUSE (notice that on the animation below).
TSP-gif

About

🏃🏻‍♂️Travelling Salesman Problem solved with a Genetic Algorithm in Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages