Git Product home page Git Product logo

tsp_ga's Introduction

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

tsp_ga's People

Contributors

inf1n8 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.