Skip to content
Snippets Groups Projects
Commit 0734e1ae authored by Abhishek Racharla's avatar Abhishek Racharla
Browse files

Edit VRE_VQE_QAOA.ipynb

parent ac2c0e89
No related branches found
No related tags found
No related merge requests found
......@@ -162,128 +162,7 @@
"**Now, let's execute the quantum VRP solver below!**\n"
]
},
# **Solving the Vehicle Routing Problem (VRP) Using Quantum Computing (Qiskit AerSimulator) for Passau Location**
### **A Quantum Optimization Approach with QAOA and VQE**
---
## 📌 **Problem Statement**
The **Vehicle Routing Problem (VRP)** extends the **Traveling Salesman Problem (TSP)** by introducing multiple vehicles that must service customers while minimizing travel costs.
The goal is to **determine optimal routes for a fleet of vehicles** to serve all locations efficiently.
### 🔹 **Objective**
This notebook implements a **quantum approach to solving VRP** using:
- **Quantum Approximate Optimization Algorithm (QAOA)**
- **Variational Quantum Eigensolver (VQE)**
Both algorithms leverage **quantum computing** to optimize routing problems.
---
## 📌 **Mathematical Formulation**
### 1️⃣ **VRP as a Quadratic Unconstrained Binary Optimization (QUBO)**
The **binary decision variable** is defined as:
$$
x_{i,j,k} =
\begin{cases}
1, & \text{if vehicle } k \text{ travels from node } i \text{ to node } j \\
0, & \text{otherwise}
\end{cases}
$$
where:
- \( d_{i,j} \) is the **distance** between locations \( i \) and \( j \).
- \( x_{i,j,k} \) is **1 if vehicle \( k \) travels from \( i \) to \( j \), otherwise 0**.
The **objective function** (minimizing travel cost) is given by:
$$
H_{\text{VRP}} = \sum_{k} \sum_{i} \sum_{j} d_{i,j} \cdot x_{i,j,k}
$$
### 📌 **Constraints**
#### 1️⃣ **Each location is visited exactly once (except the depot):**
$$
\sum_{k} \sum_{j} x_{i,j,k} = 1, \quad \forall i \neq 0
$$
#### 2️⃣ **Each vehicle starts and ends at the depot:**
$$
\sum_{j} x_{0,j,k} = 1, \quad \forall k, \quad \sum_{i} x_{i,0,k} = 1, \quad \forall k
$$
#### 3️⃣ **Vehicle route continuity (no teleportation):**
$$
\sum_{j} x_{i,j,k} - \sum_{j} x_{j,i,k} = 0, \quad \forall i, k
$$
#### 4️⃣ **(Optional) Vehicle capacity constraint:**
If each location \( i \) has a demand \( q_i \) and the vehicle has capacity \( C_k \), then:
$$
\sum_{i} q_i \sum_{j} x_{i,j,k} \leq C_k, \quad \forall k
$$
This ensures that no vehicle exceeds its allowed load.
---
## 📌 **Quantum Algorithms**
### 1️⃣ **Quantum Approximate Optimization Algorithm (QAOA)**
QAOA minimizes the **VRP cost Hamiltonian** by iteratively optimizing quantum parameters:
$$
|\psi(\beta, \gamma)\rangle = U(\beta, \gamma) |s\rangle
$$
where:
$$
U(\beta, \gamma) = e^{-i \beta H_M} e^{-i \gamma H_C}
$$
- \( H_C \) is the **VRP cost Hamiltonian**.
- \( H_M \) is the **mixing Hamiltonian** for exploring different routes.
- \( (\beta, \gamma) \) are **classical parameters** optimized iteratively.
### 2️⃣ **Variational Quantum Eigensolver (VQE)**
VQE finds the **optimal VRP route** by solving:
$$
E(\theta) = \langle \psi(\theta) | H | \psi(\theta) \rangle
$$
where:
- \( H \) represents the **VRP Hamiltonian**.
- \( |\psi(\theta)\rangle \) is the **quantum circuit ansatz**.
- \( \theta \) are **circuit parameters optimized using a classical algorithm**.
---
## 📌 **Approach in This Notebook**
### 🔹 **Step 1: Define the VRP**
- **Select 5 locations in Passau, Germany**.
- **Define the distance matrix** and construct a weighted graph.
- **Convert VRP into a QUBO model**.
### 🔹 **Step 2: Solve Using Quantum Algorithms**
- **QAOA** minimizes the VRP Hamiltonian.
- **VQE** optimizes quantum parameters to find the best route.
### 🔹 **Step 3: Compare Results**
- **Run QAOA and VQE** on a quantum simulator.
- **Compare total travel distances & routes**.
- **Visualize optimized vehicle routes**.
---
## 📌 **Expected Outcome**
- **Quantum algorithms provide approximate solutions to VRP.**
- **Compare QAOA vs. VQE performance.**
- **Visualize optimized travel routes using quantum optimization.**
---
### 🚀 **Now, let's execute the quantum VRP solver below!**
{
"cell_type": "code",
"execution_count": 1,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment