Recreating https://arxiv.org/abs/2212.02735 in Pennylane. We attempt to use Grover's Adaptive Search (GAS) to get a quicker solution to the Travelling Salesman Problem (TSP).
- Installation
- Background
- Basic Structure
- Oracle(s) implementation
- Problem Encoding
- Oracle Implementation
- Testing
- Algorithm Analysis
- Current Tasks
- Milestones
Create a virtual environment in Python 3.11 and install the required packages
python -m venv .venv
pip install -r requirements.txt
The travelling salesman problem (TSP) determines a path in a graph that traverses through every node once, and returns to the starting point at the lowest cost/distance. This means that the algorithm is required to detect a Hamiltonian cycle in the graph, and to determine the cycle with the lowest total sum. As a result, TSP is an NP-hard problem, and the decision problem of TSP (for threshold
Grover's Algorithm is an efficient database search algorithm developed in the 1990s, with its claim that the runtime is
As Grover's Algorithm only brings a quadratic speedup in runtime, the algorithm does not run in polynomial time. Nevertheless, any significant speedup is worth investigating.
For an
Note: self edges and non-existing edges are represented by infinite costs. In addition, there needs to be a mapping between the choice index for each city, and the actual other city (ie actual choice) to go to.
The oracle is responsible for picking out a valid hamiltonian cycle that has the shortest total distance. Thus, 2 constraints come into play here - existence of hamiltonian cycle, and the cycle length/distance.
Here, 2 different oracles come into play. The cycle length comparing (CLC) oracle would be used to limit the length of the cycle to
Note: Update threshold from sampled results. Question: how to ensure
- Turn TSP into a decision problem for a specific threshold, and then conduct binary search till a single optimal solution is found.
Set precision of iQFT to 6.
Goal: to calculate the cost of a path (or cycle), and compare it with a threshold
This cost computation module is determin
8000
ed by a
Then, a quantum comparator is implemented to compare the total cost of a path with threshold
Lastly, the intermediate ancillary qubits are freed up for reuse by mirrored gates.
- Set max cycle length to
$2\pi$ (iQFT compatibility) - Normalize adj matrix by sum of all entries (mult by
$2\pi$ )
- Construct controlled U-operators recursively
$$U_j = \text{diag}(\text{exp}(i\theta_{j, 0}), ..., \text{exp}(i\theta_{j, 2^m-1}))$$ $$\theta_{j,k}= a_{j,P_j[k]}$$ - Different path choices introduces different phase shifts (based on the cost)
$$U_j\ket{C_j} = \text{exp}(i\theta_{j, C_j})\ket{C_j}$$ - TODO
The paper states that such a comparator is already implemented in Qiskit. (Goal: find out how the quantum comparator is implemented, and implement in Pennylane)
- Preprocess the input
- Apply iQFT
- TODO
Generate
TODO
Qubit usage increases by
TODO
- Implement iQFT in Pennylane
- Figure out how the quantum comparator is implemented in qiskit, and port to pennylane
- Figure out how the U-operator is implemented
- Learn how the F-index forwarder is implemented
- Implement the OR-gates
- Understand the anchor qubit strategy
- Create graph generator ✔️
- Create the quantum encoding for the nodes and city choices
- Finish the HCD oracle, allowing the algo to check for Hamiltonian cycles
- Understand QFT (and iQFT) to apply to CLC oracle
- Solve the decision problem for TSP
- Apply the decision problem to find a solution for TSP