{"id":22117328,"url":"https://github.com/arnobt78/Vehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp","last_synced_at":"2025-10-12T06:31:55.451Z","repository":{"id":222031483,"uuid":"756059379","full_name":"arnobt78/Vehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp","owner":"arnobt78","description":"My Master's Thesis Project - Solving Vehicle Routing Problem with Time Windows using multiple Classic Heuristic, Metaheuristic algorithms (Hybrid Genetic Search (HGS), Guided Local Search (GLS), Ant Colony Optimisation (ACO), Simulated Annealing (SA)), compare result's with each one's results and present it in the graph.","archived":false,"fork":false,"pushed_at":"2025-06-29T11:37:17.000Z","size":7260,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T12:32:32.637Z","etag":null,"topics":["ant-colony-optimization","grasp","guided-local-search","high-integrity-systems","hybrid-genetic-search","informatik","jupiter-notebook","local-search","master-thesis","python","simulated-annealing","vehicle-routing-problems-with-time-window","vrp","vrptw"],"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/arnobt78.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,"zenodo":null}},"created_at":"2024-02-11T21:16:35.000Z","updated_at":"2025-06-29T11:37:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"b571f260-0350-4693-97ed-3ef70a0e3017","html_url":"https://github.com/arnobt78/Vehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp","commit_stats":null,"previous_names":["arnobt78/vrptw-solver-comparison","arnobt78/vehicle-routing-problem-time-windows-solver-comparison--pyapp","arnobt78/vrptw-solver-comparison-pyapp"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/arnobt78/Vehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FVehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FVehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FVehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FVehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnobt78","download_url":"https://codeload.github.com/arnobt78/Vehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FVehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010507,"owners_count":26084757,"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-10-12T02:00:06.719Z","response_time":53,"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":["ant-colony-optimization","grasp","guided-local-search","high-integrity-systems","hybrid-genetic-search","informatik","jupiter-notebook","local-search","master-thesis","python","simulated-annealing","vehicle-routing-problems-with-time-window","vrp","vrptw"],"created_at":"2024-12-01T13:31:52.543Z","updated_at":"2025-10-12T06:31:55.446Z","avatar_url":"https://github.com/arnobt78.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vehicle Routing Problem with Time Windows (VRPTW) Solver Comparison\n\n---\n\n## The Comparison results of different NP metahuristic algorithms for VRPTW\n\nRunning Algorithms on dataset: rc108.txt\n\n---\n\nBest-Known Solution (BKS) Route Cost: 1114.2\n\nBKS solution:\n\nRoute #1: 2 6 7 8 46 4 45 5 3 1 100\n\nRoute #2: 12 14 47 17 16 15 13 9 11 10\n\nRoute #3: 33 32 30 28 26 27 29 31 34 93\n\nRoute #4: 41 42 44 43 40 38 37 35 36 39\n\nRoute #5: 61 81 94 71 72 54 96\n\nRoute #6: 64 51 76 89 18 48 19 20 66\n\nRoute #7: 65 83 57 24 22 49 21 23 25 77\n\nRoute #8: 69 98 88 53 78 73 79 60 55 70 68\n\nRoute #9: 82 99 52 86 87 59 97 75 58 74\n\nRoute #10: 90\n\nRoute #11: 92 95 67 62 50 63 85 84 56 91 80\n\n---\n\nHybrid Genetic Search (HGS) Route Cost: 1114.2\n\nHGS solution:\n\nRoute #1: 12 14 47 17 16 15 13 9 11 10 \n\nRoute #2: 82 99 52 86 87 59 97 75 58 74 \n\nRoute #3: 65 83 57 24 22 49 21 23 25 77 \n\nRoute #4: 64 51 76 89 18 48 19 20 66 \n\nRoute #5: 92 95 67 62 50 63 85 84 56 91 80 \n\nRoute #6: 33 32 30 28 26 27 29 31 34 93 \n\nRoute #7: 61 81 94 71 72 54 96 \n\nRoute #8: 41 42 44 43 40 38 37 35 36 39 \n\nRoute #9: 2 6 7 8 46 4 45 5 3 1 100 \n\nRoute #10: 90 \n\nRoute #11: 69 98 88 53 78 73 79 60 55 70 68 \n\n---\n\nGuided Local Search (GLS) Route Cost: 1266.9\n\nGLS solution:\n\nRoute #1: 71 72 44 43 40 38 37 35 36 39\n\nRoute #2: 98 82 90 53 78 73 79 2 60\n\nRoute #3: 92 67 32 30 28 26 27 29 31 34 93\n\nRoute #4: 65 99 24 22 20 49 21 23 25 77\n\nRoute #5: 95 51 76 89 33 50 62 91 80\n\nRoute #6: 12 14 47 17 16 15 13 9 11 10\n\nRoute #7: 88 6 7 8 46 4 45 5 3 1 100 55\n\nRoute #8: 69 70 61 81 94 96 54 41 42 68\n\nRoute #9: 83 52 57 86 87 59 97 75 58 74\n\nRoute #10: 64 19 48 18 63 85 84 56 66\n\n---\n\nAnt Colony Optimization (ACO) Route Cost: 1321.8459204561746\n\nACO solution:\n\nRoute #1: 69 98 88 82 99 52 86 74 57 83 66 91\n\nRoute #2: 65 64 51 76 89 85 63 62 56 80\n\nRoute #3: 90 53 73 79 78 60 55 68\n\nRoute #4: 33 28 30 32 34 31 29 27 26\n\nRoute #5: 72 71 93 94 81 61 54 96 100 70\n\nRoute #6: 2 45 5 8 7 6 46 4 3 1\n\nRoute #7: 41 42 44 38 39 40 36 35 37 43\n\nRoute #8: 19 21 23 18 48 49 22 20 24 25\n\nRoute #9: 12 14 47 17 16 15 11 10 9 13\n\nRoute #10: 59 58 87 97 75 77\n\nRoute #11: 92 95 84 50 67\n\n---\n\nSimulated Annealing (SA) Route Cost: 1237.620141359753\n\nSA solution:\n\nRoute #1: 7 8 46 4 45 5 3 1 100 55\n\nRoute #2: 64 51 76 89 63 85 84 56 91\n\nRoute #3: 69 98 53 12 15 16 17 47 14\n\nRoute #4: 90 82 9 13 11 10\n\nRoute #5: 61 42 44 40 39 38 37 35 36 43\n\nRoute #6: 65 52 86 77 25 23 57\n\nRoute #7: 88 60 78 73 79 6 2 70 68\n\nRoute #8: 92 67 62 34 50 94 96\n\nRoute #9: 99 87 59 97 75 58 74\n\nRoute #10: 83 24 22 19 18 48 21 49 20 66\n\nRoute #11: 81 93 71 72 41 54\n\nRoute #12: 95 33 32 30 28 26 27 29 31 80\n\n---\n\nAlgorithms - - No. of Routes - - Costs - - Gap(%) - - Runtime(seconds)\n\n  BKS - - - - - - 11 - - - - - - - - - - 1114.2 - - -\t-\n\n  HGS - - - - - - 11 - - - - - - - - - - 1114.2 - - 0.0 - - - - 300.137736082077\n\n  GLS - - - - - - 10 - - - - - - - - - - 1266.9 - - 13.7 - -- - 300.0492959022522\n\n  ACO - - - - - - 11 - - - - - - - - - - 1321.8 - - 18.63 - - - 877.1980187892914\n\n  SA - - -- - - - 12 - - - - - - - - - - 1237.6 - - 11.08 - - - 416.80780506134033\n\n---\n\n![3 HGS rc108](https://github.com/user-attachments/assets/afac9be9-37a1-4b4d-a7f8-5d346d653e2f) ![3 GLS rc108](https://github.com/user-attachments/assets/b8140b7f-30c2-4f65-9d55-24207754dd0f) ![3 ACO rc108](https://github.com/user-attachments/assets/3643d0e9-c3d4-418c-8ed7-efea8d94ede9) ![3 SA rc108](https://github.com/user-attachments/assets/3632158b-6131-4157-97bd-9cd4116bcecf)\n---\n\n## Project Summary\n\nThis repository provides a comprehensive comparison and implementation of several heuristic and metaheuristic algorithms for solving the **Vehicle Routing Problem with Time Windows (VRPTW)**. Developed as part of an advanced study project, it showcases reproducible computational experiments, detailed analysis, and visualizations of solution quality for different algorithms. The target audience includes researchers, students, and practitioners interested in operations research, optimization, and applied machine learning.\n\n---\n\n## Table of Contents\n\n- [Project Summary](#project-summary)\n- [Project Details](#project-details)\n- [Features](#features)\n- [Technologies Used](#technologies-used)\n- [Project Structure](#project-structure)\n- [Algorithms Implemented](#algorithms-implemented)\n- [How to Run](#how-to-run)\n- [Visualizations](#visualizations)\n- [Results \u0026 Comparison](#results--comparison)\n- [Screenshots](#screenshots)\n- [Keywords](#keywords)\n- [Contact](#contact)\n\n---\n\n## Project Details\n\nThe Vehicle Routing Problem with Time Windows (VRPTW) is a classic combinatorial optimization problem that extends the basic Vehicle Routing Problem (VRP) by adding constraints on service time windows for each customer. The challenge is to determine optimal routes for a fleet of vehicles to service a set of customers within their specified time windows, minimizing total travel cost. This project benchmarks and compares several well-known metaheuristic algorithms on standard datasets (e.g., Solomon's instances) and visualizes their performance.\n\n**Algorithms Compared:**\n- Hybrid Genetic Search (HGS)\n- Guided Local Search (GLS)\n- Ant Colony Optimization (ACO)\n- Simulated Annealing (SA)\n\n---\n\n## Features\n\n- Modular implementation for each algorithm\n- Benchmarking against Best-Known Solutions (BKS)\n- Visual comparison of routes and costs\n- Reproducible experiments via fixed seeds (with options to randomize)\n- Interactive Jupyter notebook for experiment walkthroughs\n- Easily extensible for new algorithms or datasets\n\n---\n\n## Technologies Used\n\n- **Python 3.x**: Core programming language\n- **NumPy, pandas**: Data manipulation and analysis\n- **matplotlib**: Visualization of routes and performance\n- **OR-Tools**: Used in GLS for routing optimization\n- **pyVRP**: Framework for HGS implementation\n- **Jupyter Notebook**: Interactive analysis and visualization\n\n---\n\n## Project Structure\n\n```\n.\n├── main.py                   # Main script to run all algorithms and generate results\n├── solver.ipynb              # Jupyter Notebook for interactive exploration\n├── aco/                      # Implementation of Ant Colony Optimization\n│   ├── vrptw_base.py         # Node and graph structures for ACO\n│   ├── basic_aco.py          # Core ACO logic and route extraction\n│   ├── ant.py                # Ant agent behaviors and movement\n├── gls/                      # Implementation of Guided Local Search\n│   ├── base_solver.py        # GLS algorithm and solver logic\n│   ├── instance_loader.py    # Data loader for GLS\n├── sa/                       # Simulated Annealing code\n├── hgs/                      # Hybrid Genetic Search code\n├── bks.py                    # Processes Best-Known Solutions (BKS)\n├── plot.py                   # Visualization utilities\n├── data/                     # Benchmark datasets (Solomon .txt and .sol)\n├── requirements.txt          # Python dependencies\n├── README.md                 # Project documentation\n```\n\n---\n\n## Algorithms Implemented\n\n### 1. Hybrid Genetic Search (HGS)\nA metaheuristic that evolves a population of solutions using selection, crossover, and mutation. Implementation is based on the pyVRP library and supports customizable stopping criteria.\n\n**Example Usage:**\n```python\nfrom pyvrp import Model, read\nfrom pyvrp.stop import MaxRuntime\n\ndef solve_with_hgs(input_path, runtime):\n    INSTANCE = read(input_path, instance_format=\"solomon\", round_func=\"trunc1\")\n    model = Model.from_data(INSTANCE)\n    result = model.solve(stop=MaxRuntime(runtime), seed=0)  # Can randomize 'seed'\n    return result\n```\n\n---\n\n### 2. Guided Local Search (GLS)\nEnhances local search by penalizing overused solution components, implemented using OR-Tools, and allows for time-limited optimization.\n\n**Example Usage:**\n```python\nfrom gls.base_solver import Solver\nfrom gls.instance_loader import load_instance\n\ndef solve_with_gls(input_path, runtime):\n    data = load_instance(input_path)\n    solver = Solver(data)\n    solver.create_model()\n    solver.solve_model({\"time_limit\": runtime})\n    return solver.get_solution()\n```\n\n---\n\n### 3. Ant Colony Optimization (ACO)\nA population-based metaheuristic that simulates ant foraging behavior using pheromone trails to discover optimal routes.\n\n**Key Classes:**\n- `Node` (in `aco/vrptw_base.py`): Represents each location (customer or depot), including time windows and demand.\n- `Ant` (in `aco/ant.py`): Each ant constructs a route, considering vehicle load, time windows, and updates its path.\n- `BasicACO` (in `aco/basic_aco.py`): Core logic for iteratively building solutions and updating pheromones.\n\n**Example Code Excerpt:**\n```python\n# Example: Extracting routes from the best path (aco/basic_aco.py)\ndef get_best_route(self):\n    routes = []\n    route = []\n    for node in self.best_path:\n        if node != 0:\n            route.append(node)\n        else:\n            if route:\n                routes.append(route)\n                route = []\n    return routes\n```\n\n---\n\n### 4. Simulated Annealing (SA)\nA probabilistic algorithm that explores the solution space by occasionally accepting worse solutions, allowing escape from local minima.\n\n---\n\n## How to Run\n\n### 1. Environment Setup\n\n```sh\npython -m venv .venv\n# Activate the virtual environment:\n# Linux/Mac:\nsource .venv/bin/activate\n# Windows:\n.venv\\Scripts\\activate\n\npip install -r requirements.txt\n```\n\n---\n\n### 2. Running the Algorithms\n\nTo run all algorithms and generate comparative results:\n\n```sh\npython main.py\n```\n\n---\n\n### 3. Interactive Exploration\n\nFor a step-by-step interactive analysis:\n\n```sh\njupyter notebook solver.ipynb\n```\n\n---\n\n## Visualizations\n\n- Visualizations of the generated routes and algorithm performance are created using `matplotlib`. You can customize these plots in `plot.py`.\n- Results are saved and/or displayed as images for direct comparison.\n\n---\n\n## Results \u0026 Comparison\n\nThe following table summarizes the results of each algorithm on the `rc108.txt` dataset:\n\n| Algorithm | Route Cost | No. of Routes | Gap (%) | Runtime (s) |\n|-----------|------------|---------------|---------|-------------|\n| BKS       | 1114.2     | 11            | 0       | -           |\n| HGS       | 1114.2     | 11            | 0.0     | 300.14      |\n| GLS       | 1266.9     | 10            | 13.7    | 300.05      |\n| ACO       | 1321.8     | 11            | 18.63   | 877.20      |\n| SA        | 1237.6     | 12            | 11.08   | 416.81      |\n\n\u003e See the detailed solution routes and costs for each algorithm in the section below.\n\n---\n\n## Screenshots\n\n*All images are retained from the original README and illustrate the route solutions for each algorithm.*\n\n*(See README for full image list)*\n\n---\n\n## Keywords\n\n- Vehicle Routing Problem (VRP)\n- Time Windows\n- Metaheuristics\n- Genetic Algorithm\n- Ant Colony Optimization\n- Simulated Annealing\n- Guided Local Search\n- Solomon Dataset\n- Routing Optimization\n- Visualization\n- Benchmarking\n\n---\n\n## Conclusion\n\nThis project serves as a hands-on, extensible, and educational platform for benchmarking and understanding metaheuristic algorithms applied to the VRPTW. You are encouraged to explore, modify, and extend the codebase for learning, research, or practical use cases.\n\n---\n\n## Contact\n\nFor questions, feedback, or collaboration:\n\n**Arnob Mahmud**  \nEmail: arnob_t78@yahoo.com\n\n---\n\n*Thank you for exploring this project!*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobt78%2FVehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnobt78%2FVehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobt78%2FVehicle-Routing-Problem-Time-Windows-Solver-Comparison--pyApp/lists"}