{"id":23982302,"url":"https://github.com/erfan-mtzv/traveling-salesman-problem-evolutionary-algorithm-cyclic-crossover","last_synced_at":"2026-06-10T01:31:35.494Z","repository":{"id":270997322,"uuid":"912109480","full_name":"erfan-mtzv/Traveling-Salesman-Problem-Evolutionary-Algorithm-Cyclic-Crossover","owner":"erfan-mtzv","description":"TSP solver using an evolutionary algorithm with cyclic crossover, tournament selection, and insert mutation. Tested on TSPLIB95 datasets for NP-Hard optimization.","archived":false,"fork":false,"pushed_at":"2025-01-04T16:34:46.000Z","size":2321,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T23:24:33.077Z","etag":null,"topics":["evolutionary-algorithm","genetic-algorithm","optimization","python","tsp-solver"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erfan-mtzv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-04T16:22:31.000Z","updated_at":"2025-01-04T16:40:02.000Z","dependencies_parsed_at":"2025-01-04T17:37:30.420Z","dependency_job_id":null,"html_url":"https://github.com/erfan-mtzv/Traveling-Salesman-Problem-Evolutionary-Algorithm-Cyclic-Crossover","commit_stats":null,"previous_names":["erfan-mtzv/traveling-salesman-problem-evolutionary-algorithm-cyclic-crossover"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/erfan-mtzv/Traveling-Salesman-Problem-Evolutionary-Algorithm-Cyclic-Crossover","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfan-mtzv%2FTraveling-Salesman-Problem-Evolutionary-Algorithm-Cyclic-Crossover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfan-mtzv%2FTraveling-Salesman-Problem-Evolutionary-Algorithm-Cyclic-Crossover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfan-mtzv%2FTraveling-Salesman-Problem-Evolutionary-Algorithm-Cyclic-Crossover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfan-mtzv%2FTraveling-Salesman-Problem-Evolutionary-Algorithm-Cyclic-Crossover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erfan-mtzv","download_url":"https://codeload.github.com/erfan-mtzv/Traveling-Salesman-Problem-Evolutionary-Algorithm-Cyclic-Crossover/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erfan-mtzv%2FTraveling-Salesman-Problem-Evolutionary-Algorithm-Cyclic-Crossover/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284982746,"owners_count":27095048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-17T02:00:06.431Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["evolutionary-algorithm","genetic-algorithm","optimization","python","tsp-solver"],"created_at":"2025-01-07T11:14:10.693Z","updated_at":"2025-11-18T01:02:49.490Z","avatar_url":"https://github.com/erfan-mtzv.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Traveling Salesman Problem (TSP) - Evolutionary Algorithm (EA)\n\n## 📌 Overview\nThis 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.  \n\n### Key Components:\n- **Selection**: Tournament Selection  \n- **Recombination**: Cyclic Crossover (CX)  \n- **Mutation**: Insert Mutation for introducing variability  \n\n### Datasets (from TSPLIB95):\n- **bayg29** – 29 cities  \n- **ali535** – 535 cities  \n\n---\n\n## 📖 Table of Contents\n1. [Algorithm Overview](#algorithm-overview)  \n2. [Setup and Installation](#setup-and-installation)  \n3. [Usage](#usage)  \n4. [Parameters and Configurations](#parameters-and-configurations)  \n5. [Figures](#figures)  \n\n---\n\n## ⚙️ Algorithm Overview\n### Evolutionary Process  \nThe Evolutionary Algorithm (EA) follows these steps:  \n\n1. **Initialization** – Generate an initial random population.  \n2. **Selection** – Apply tournament selection to choose parents for reproduction.  \n3. **Recombination (Cyclic Crossover)** – Perform cyclic crossover to exchange genetic material.  \n4. **Mutation (Insert Mutation)** – Apply insert mutation with a **2% mutation rate**.  \n5. **Survivor Selection** – Replace the old population with newly generated offspring.  \n6. **Termination** – The process stops after a fixed number of generations or upon reaching convergence criteria.  \n\n---\n\n### 🏆 Selection – Tournament Selection  \n- Random subsets of individuals are chosen from the population.  \n- The best individual from each subset is selected to become a parent.  \n\n---\n\n### 🔄 Recombination – Cyclic Crossover (CX)  \n- Cycles of genes between two parents are identified.  \n- Genes within the same cycle are swapped to produce offspring.  \n\n---\n\n### 🔄 Mutation – Insert Mutation  \n- A gene is randomly selected, removed, and reinserted at a different position within the chromosome.  \n\n---\n\n## 🛠️ Setup and Installation  \n### Requirements  \n- **numpy**  \n- **matplotlib**  \n- **pandas**  \n- **random**  \n\n### Installation  \nClone the repository using the following command:  \n```bash\ngit clone https://github.com/yourusername/TSP-EA.git\n```  \n\n---\n\n## 🚀 Usage  \nRun the Jupyter notebook to execute the algorithm on the datasets:  \n```bash\njupyter notebook ali535_bayg29_GA.ipynb\n```  \n- You can modify dataset paths and configurations directly in the notebook.  \n\n---\n\nPlots of **best, worst, and average fitness values** over generations are generated for performance evaluation.  \n\n---\n\n## ⚙️ Base Parameters and Configurations  \n- **Population Size**: 200  \n- **Crossover Rate**: 90%  \n- **Mutation Rate**: 2%  \n- **Epoch**: 1000  \n- **Tournament Selection Size**: 3  \n\n\u003e These values can be adjusted in the configuration section of the notebook.  \n\n---\n\n## 📈 Figures  \n\n### 1. Algorithm Flowchart  \n![Algorithm Flowchart](./Images/EA.jpg)  \n\n### 2. Cyclic Crossover Process  \n![Cyclic Crossover](./Images/Cyclic-Crossover.jpg)  \n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfan-mtzv%2Ftraveling-salesman-problem-evolutionary-algorithm-cyclic-crossover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferfan-mtzv%2Ftraveling-salesman-problem-evolutionary-algorithm-cyclic-crossover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfan-mtzv%2Ftraveling-salesman-problem-evolutionary-algorithm-cyclic-crossover/lists"}