Skip to content

grwkremilek/TSP-GA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

TSP-GeneticAlgorithm

  • genetic algorithm for Travelling Salesman Problem implemented in python 3.6
  • explores different selection, crossover and mutation methods

Getting Started

Prerequisites

Basic Structure

Data

Population

  • to make the algorithm the least black box possible, the Population class object is a list of class Tour objects, which again is a list of class City objects (the Matryoshka doll style), thus it is possible to access different levels of data with indices
  • the Population class object is a tuple consisiting of: fitness float value, distance, the Tour class object

    print(p[0][2])
    
    print(p[0][2][3])
    
    print(p[0][2][3].longitude)

(0.00047625626940124924, 2099.709892023475, [Olomouc, Opava, Trnava, Bratislava, Brno, Znojmo, Most, Opole, Jihlava, Prague, Liberec, Berlin, Pardubice])

[Olomouc, Opava, Trnava, Bratislava, Brno, Znojmo, Most, Opole, Jihlava, Prague, Liberec, Berlin, Pardubice]

Bratislava

17.1093063

Parent selection

  • roulette wheel selection

    • fitness proportionate selection
    • fitness of each individual route is used to assign a probability of selection
  • tournament selection

    • number of individuals are randomly selected from the population
    • individual with the highest fitness in the group is chosen as the first parent
    • repeated to chose the second parent.
  • elitist selection

    • the best performing individuals from the population carry over to the next generation

Crossover

Mutation

  • a way to introduce variation in the population
  • possible to choose from:
    • swap mutation
    • inversion mutation
    • insertion mutation
    • scramble mutation

Convergence

  • Conditions under which GA will come to a stop
    • number of generations
    • time limit
    • distance improvement over a number of generations
    • value threshold

Sources

  • Genetic Algorithms Tutorial
  • Larrañaga, P., Kuijpers, C., Murga, R. H., Inza, I., & Dizdarevic, S. (1999). Genetic algorithms for the travelling salesman problem: A review of representations and operators. Artificial intelligence review: An international survey and tutorial journal, 13(2), 129-170. https://doi.org/10.1023/A:1006529012972

About

Travelling salesman problem solver with genetic algorithm applied to real-world data

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages