Skip to content

A Genetic Algorithm in Python for the Travelling Salesman Problem

License

Notifications You must be signed in to change notification settings

lccasagrande/TSP-GA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This repository contains a generic Python implementation of a Genetic Algorithm to solve the Travelling Salesman Problem (TSP). Geographic coordinates of cities are provided as input to generate a edge-weighted complete graph where the weights are the distance between the cities in kilometers.

Output Example

output-ga

Requirements

You'll need Python 3.x x64 to be able to run theses projects.

If you do not have Python installed yet, it is recommended that you install the Anaconda distribution of Python, which has almost all packages required in these project.

You can also install Python 3.x x64 from here

Instructions

  1. Clone the repository and navigate to the downloaded folder.

    git clone https://github.com/lccasagrande/TSP-GA.git
    cd TSP-GA
  2. Install required packages:

    pip install -e .

    Or:

    pip install -e . --user
  3. Navigate to the src folder and execute:

    cd src
    python main.py -v 1 --pop_size 500 --tourn_size 50 --mut_rate 0.02 --n_gen 20 --cities_fn '../data/cities.csv'

About

A Genetic Algorithm in Python for the Travelling Salesman Problem

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages