https://github.com/erfan-mtzv/traveling-salesman-problem-evolutionary-algorithm-cyclic-crossover
TSP solver using an evolutionary algorithm with cyclic crossover, tournament selection, and insert mutation. Tested on TSPLIB95 datasets for NP-Hard optimization.
https://github.com/erfan-mtzv/traveling-salesman-problem-evolutionary-algorithm-cyclic-crossover
evolutionary-algorithm genetic-algorithm optimization python tsp-solver
Last synced: 4 months ago
JSON representation
TSP solver using an evolutionary algorithm with cyclic crossover, tournament selection, and insert mutation. Tested on TSPLIB95 datasets for NP-Hard optimization.
- Host: GitHub
- URL: https://github.com/erfan-mtzv/traveling-salesman-problem-evolutionary-algorithm-cyclic-crossover
- Owner: erfan-mtzv
- Created: 2025-01-04T16:22:31.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-01-04T16:34:46.000Z (6 months ago)
- Last Synced: 2025-01-04T17:26:50.453Z (6 months ago)
- Topics: evolutionary-algorithm, genetic-algorithm, optimization, python, tsp-solver
- Language: Jupyter Notebook
- Homepage:
- Size: 2.21 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Traveling Salesman Problem (TSP) - Evolutionary Algorithm (EA)
## 📌 Overview
This project implements an **Evolutionary Algorithm (EA)** to solve the **Traveling Salesman Problem (TSP)**. The objective is to find the shortest possible route that visits each city exactly once and returns to the starting point. As TSP is classified as **NP-Hard**, evolutionary algorithms provide a practical heuristic approach to approximate near-optimal solutions.### Key Components:
- **Selection**: Tournament Selection
- **Recombination**: Cyclic Crossover (CX)
- **Mutation**: Insert Mutation for introducing variability### Datasets (from TSPLIB95):
- **bayg29** – 29 cities
- **ali535** – 535 cities---
## 📖 Table of Contents
1. [Algorithm Overview](#algorithm-overview)
2. [Setup and Installation](#setup-and-installation)
3. [Usage](#usage)
4. [Parameters and Configurations](#parameters-and-configurations)
5. [Figures](#figures)---
## ⚙️ Algorithm Overview
### Evolutionary Process
The Evolutionary Algorithm (EA) follows these steps:1. **Initialization** – Generate an initial random population.
2. **Selection** – Apply tournament selection to choose parents for reproduction.
3. **Recombination (Cyclic Crossover)** – Perform cyclic crossover to exchange genetic material.
4. **Mutation (Insert Mutation)** – Apply insert mutation with a **2% mutation rate**.
5. **Survivor Selection** – Replace the old population with newly generated offspring.
6. **Termination** – The process stops after a fixed number of generations or upon reaching convergence criteria.---
### 🏆 Selection – Tournament Selection
- Random subsets of individuals are chosen from the population.
- The best individual from each subset is selected to become a parent.---
### 🔄 Recombination – Cyclic Crossover (CX)
- Cycles of genes between two parents are identified.
- Genes within the same cycle are swapped to produce offspring.---
### 🔄 Mutation – Insert Mutation
- A gene is randomly selected, removed, and reinserted at a different position within the chromosome.---
## 🛠️ Setup and Installation
### Requirements
- **numpy**
- **matplotlib**
- **pandas**
- **random**### Installation
Clone the repository using the following command:
```bash
git clone https://github.com/yourusername/TSP-EA.git
```---
## 🚀 Usage
Run the Jupyter notebook to execute the algorithm on the datasets:
```bash
jupyter notebook ali535_bayg29_GA.ipynb
```
- You can modify dataset paths and configurations directly in the notebook.---
Plots of **best, worst, and average fitness values** over generations are generated for performance evaluation.
---
## ⚙️ Base Parameters and Configurations
- **Population Size**: 200
- **Crossover Rate**: 90%
- **Mutation Rate**: 2%
- **Epoch**: 1000
- **Tournament Selection Size**: 3> These values can be adjusted in the configuration section of the notebook.
---
## 📈 Figures
### 1. Algorithm Flowchart
### 2. Cyclic Crossover Process
---