https://github.com/kazemihabib/vehicle-routing-problem-vrp
This project, also known as the Vehicle Routing Problem (VRP), addresses the Multiple Couriers Planning (MCP) problem using Constraint Programming (CP), Satisfiability Modulo Theories (SMT), and Mixed-Integer Linear Programming (MIP) to optimize courier routes efficiently.
https://github.com/kazemihabib/vehicle-routing-problem-vrp
cp mcp minizinc mip pulp smt vrp z3
Last synced: 6 months ago
JSON representation
This project, also known as the Vehicle Routing Problem (VRP), addresses the Multiple Couriers Planning (MCP) problem using Constraint Programming (CP), Satisfiability Modulo Theories (SMT), and Mixed-Integer Linear Programming (MIP) to optimize courier routes efficiently.
- Host: GitHub
- URL: https://github.com/kazemihabib/vehicle-routing-problem-vrp
- Owner: kazemihabib
- Created: 2024-11-04T16:20:16.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2024-12-18T16:17:13.000Z (10 months ago)
- Last Synced: 2025-04-01T04:57:24.209Z (6 months ago)
- Topics: cp, mcp, minizinc, mip, pulp, smt, vrp, z3
- Language: Python
- Homepage:
- Size: 1.48 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: licenses/.keep
Awesome Lists containing this project
README
# Combinatorial Decision Making and Optimization (CDMO) Project
This project tackles the **Multiple Couriers Planning (MCP) problem**, a complex combinatorial optimization challenge where a set of couriers must deliver items to various locations while minimizing the maximum distance any courier travels. The MCP problem, increasingly relevant in the era of online shopping and rapid delivery expectations, requires that each courier’s load capacity is respected, and routes are planned efficiently from an origin point back to the same point.
The goal of this project is to model and solve the MCP problem using three approaches:
1. **Constraint Programming (CP)**
2. **Satisfiability Modulo Theories (SMT)**
3. **Mixed-Integer Linear Programming (MIP)**Each model applies different optimization techniques to allocate items fairly and efficiently to couriers. The project includes experiments to evaluate solver performance across multiple instances.
You can access the complete project description [here](https://github.com/kazemihabib/DUMMY-PROJECT/blob/master/CDMO_Project-2023-2024.pdf).
## Table of Contents
- [Prerequisites](#prerequisites)
- [Quick Start Guide (TL;DR)](#quick-start-guide-tldr)
- [Detailed Setup and Usage](#detailed-setup-and-usage)
- [Building Docker Image](#building-docker-image)
- [Running Docker Image](#running-docker-image)
- [Running Solvers](#running-solvers)
- [Running All Solvers](#running-all-solvers)
- [Running the SMT Solver](#running-the-smt-solver)
- [Running the CP Solver](#running-the-cp-solver)
- [Running the MIP Solver](#running-the-mip-solver)## Prerequisites
Before you begin, ensure that you have the following installed:
- **Docker**: Install Docker on your host machine. You can download it from [Docker's official website](https://www.docker.com/get-started).
- **Internet Connection**: `Gurobi` solver's license requires an internet connection during the usage.---
## Quick Start Guide (TL;DR)
1. **Open your terminal and navigate to the root of this project**.
2. **Build Docker Image**:
```bash
docker build -t cdmo .
```3. **Run Docker**:
```bash
docker run -it --rm cdmo
```This command will launch the Docker container and open a shell session inside it, allowing you to run commands directly within the container environment.
4. **Run All Solvers**:
```bash
python multi_solver.py res/
```
5. **Check correctness of found soloutions**
```bash
python check_solution.py instances/instances_dat res/
```
6. **Access soloutions**
```bash
cd /app/res
```For more specific instructions on setting up and running individual solvers or using additional options, see [Detailed Setup and Usage](#detailed-setup-and-usage)
## Detailed Setup and Usage
### Building Docker Image
To build the Docker image:
1. Open your preferred terminal.
2. Navigate to the root of this project.
3. Run the following command:```bash
docker build -t cdmo .
```This will create an image named `cdmo`.
### Running Docker Image
To run the Docker image, execute the following command:
```bash
docker run -it --rm cdmo
```This command will run the `cdmo` image and provide a bash shell for running the solvers.
**Optional1**: If you want to access the solution files generated by the solvers from your host machine, mount a directory from your host into the Docker container by adding `-v :` option to the previous command
**Examples**
```bash
docker run -it --rm -v $(pwd)/docker_generated_files/res:/app/res cdmodocker run -it --rm -v ~/docker_generated_files/res:/app/res cdmo
```**Optional2**: If you have new instance files in your host that you want to solve, Again mount the new instances directory from your host into the Docker by adding `-v :`
**Examples**
```bash
docker run -it --rm -v $(pwd)/new_instances:/app/new_instances cdmodocker run -it --rm -v ~/new_instances:/app/new_instances cdmo
```You can use both *Optional1* and *Optional2* together
**Example**
```bash
docker run -it --rm -v $(pwd)/docker_generated_files/res:/app/res -v $(pwd)/new_instances:/app/new_instances cdmo
```Now, you have a prompt ready to run the solvers.
### Running Solvers
#### Running All Solvers
To run all solvers:
```bash
python multi_solver.py
```- ``: Directory where the solutions will be saved as JSON files.
This will solve all instances given in the assignment using *CP*, *SMT* and *MIP* and save the results in the output directory.
**Example**:
```bash
python multi_solver.py res/
```
#### Running the SMT SolverTo run the SMT solver:
```bash
python SMT/SMT_Z3.py
```Arguments:
- ``: Directory containing the instance files. The files must be `.dat`.
- ``: Directory to save the solutions as JSON files.
- ``: Symmetry breaking options:
- `both`: Run both with and without symmetry breaking.
- `sb`: Enable symmetry breaking.
- `nosb`: Disable symmetry breaking.**Examples**
To run the SMT Solver with symmetry breaking enabled:
```bash
python SMT/SMT_Z3.py instances/instances_dat res/SMT sb
```To run the SMT Solver without symmetry breaking:
```bash
python SMT/SMT_Z3.py instances/instances_dat res/SMT nosb
```To run the SMT Solver with and without symmetry breaking:
```bash
python SMT/SMT_Z3.py instances/instances_dat res/SMT both
```
#### Running the CP SolverTo run the CP solver:
```bash
python CP/run_cp.py
```Arguments:
- ``: Directory containing the instance files, the files must be `.dzn`.
- ``: Directory to save the solutions as JSON files.The script will run three different minizinc solvers using each "chuffed" or "gecode". The solvers include:
- `CP_SYM_LB_RML_HRSTIC`: Uses Symmetry-breaking, Lower-bound constraint, Route Matrix Limiting and non-trivial Heuristics.
- `CP_SYM_LB`: Uses only Symmetry-breaking and Lower-bound constraint.
- `CP`: The simplest solver without Symmetry-breaking or LB constraint.**Example**
```bash
python CP/run_cp.py instances/instances_dzn res/CP
```#### Running the MIP solver
To run the MIP solver:
```bash
python run.py
```Arguments:
- ``: Directory containing the instance files. The files should follow `inst{num_instances:02}.dat` naming. convention
- ``: Directory to save the solutions as JSON files.Solvers:
The script supports multiple solvers, including:- `CBC` : Default solver provided by PuLP.
- `HiGHS` : High-performance solver for linear programming.
- `Gurobi` : A powerful commercial solver for linear and mixed-integer programming.**Example**
```bash
python MIP/run.py instances/instances_dat res/MIP
```