justintemps / tsp-genetic-algorithm

Implements a Genetic Algorithm to solve the Travelling Salesman Problem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TSP Genetic Algorithm

Description

This application implements a Genetic Algorithm to solve the Travelling Salesman Problem. It implements a solution for crossover proposed by Professor Eric Braude, Boston University.

Installation

  1. Clone this repository

  2. Start a Python environment

python3 -m venv .env
  1. Activate the environment
source .env/bin/activate
  1. Install requirements
pip3 install -r requirements.txt

What's inside

App

  • Runs the algorithm with randomly generated cities
  • Creates a line chart showing the algorithm's progress after successive generations
  • Parameters for altering the data and hyperparameters for modyfing the algorithm are available as constants listed at the top of the file
  • City distances are calculated automatically from lat/long coordinates

From the project root:

python3 app.py

Boston

  • Runs the algorithm four predefined cities
  • Creates a line chart showing the algorithm's progress after successive generations
  • Parameters for altering the data and hyperparameters for modyfing the algorithm are available as constants listed at the top of the file
  • City distances are calculated automatically from lat/long coordinates

From the project root:

python3 boston.py

Resources

About

Implements a Genetic Algorithm to solve the Travelling Salesman Problem


Languages

Language:Python 100.0%