Skip to content

Latest commit

 

History

History
64 lines (52 loc) · 1.43 KB

README.md

File metadata and controls

64 lines (52 loc) · 1.43 KB

Travelling Salesman Problem using Genetic Algorithm

Installation

You can download it as zip or clone it using cmd

 git clone https://github.com/Inf1n8/TSP_GA.git
 cd TSA_GPA/

Make sure you have the package virtualenv if not then execute pip install virtualenv

Create a virtual environment

  1. Windows
virtualenv venv
venv\Scripts\activate
  1. Linux
virtualenv venv
source venv/bin/activate

Install necessary packages from requirements.txt

pip install -r requirements.txt

How to run

Parameters can be changed in config.json

{
	"num_location" : 20,
	"elite_size" : 20,
	"num_generations" : 500,
	"population_size" : 100,
	"mutation_rate" : 0.01
}

If you want to run the jupyter notebook then type the following command in your terminal:

$> jupyter notebook

Click TSA_GA and run all the cells

Else you can run the python file directly using the command:

python main.py

Results

When you run the python file we get the following outputs:

  1. Initial distance to complete travelling all the locations
  2. Final Distance to complete travelling all the locations after n generations
  3. The best route which can be taken with minimum distance
  4. Graph visualization between Distance and Generations
  5. Plot the path that can be taken to cover all the locations

Generation vs Total Distance

Shortest Path