Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarifications on the QUBO tutorial #731

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions tutorials/applications/QAOA and QAA to solve a QUBO problem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
"QUBO has been extensively studied [Glover, et al., 2018](https://arxiv.org/pdf/1811.11538.pdf) and is used to model and solve numerous categories of optimization problems including important instances of network flows, scheduling, max-cut, max-clique, vertex cover and other graph and management science problems, integrating them into a unified modeling framework.\n",
HGSilveri marked this conversation as resolved.
Show resolved Hide resolved
"\n",
"Mathematically, a QUBO instance consists of a symmetric matrix $Q$ of size $(N \\times N)$, and the optimization problem associated with it is to find the bitstring $z=(z_1, \\dots, z_N) \\in \\{0, 1 \\}^N$ that minimizes the quantity\n",
"$$f(z) = z^{T}Qz$$ \n",
"\n",
"\n",
"In this tutorial, we will demonstrate how a QUBO instance can be mapped and solved using neutral atoms."
"$$f(z) = z^{T}Qz$$ "
]
},
{
Expand Down Expand Up @@ -74,7 +71,17 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Because the QUBO is small, we can classically check all solutions and mark the optimal ones. This will help us later in the tutorial to visualize the quality of our quantum approach."
"In this tutorial, we will demonstrate how this QUBO instance can be mapped and solved using neutral atoms. For reasons that will become apparent further along, this QUBO instance is particularly amenable to embedding on a neutral-atom device since:\n",
"\n",
"1. All the off-diagonal terms are positive.\n",
"2. The diagonal terms are all equal."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Furthermore, because the QUBO is small, we can classically check all solutions and mark the optimal ones. This will help us later in the tutorial to visualize the quality of our quantum approach."
]
},
{
Expand Down Expand Up @@ -115,7 +122,16 @@
"source": [
"We now illustrate how to use Pulser to embbed the QUBO matrix $Q$ on a neutral-atom device.\n",
"\n",
"The key idea is to encode the off-diagonal terms of $Q$ by using the Rydberg interaction between atoms. As the interaction $U$ depends on the pairwise distance ($U=C_6/r_{ij}^6$) between atoms $i$ and $j$, we attempt to find the optimal positions of the atoms in the Register that replicate best the off-diagonal terms of $Q$:"
"The key idea is to encode the off-diagonal terms of $Q$ by using the Rydberg interaction between atoms. Recalling that the interaction between two atoms is given by \n",
"$$\n",
"U_{ij}=C_6/r_{ij}^6,\n",
"$$\n",
"we note that \n",
"\n",
"1. The term is strictly positive, which is why it matters that our off-diagonal terms are too.\n",
"2. Its magnitude depends on the pairwise distance between atoms $i$ and $j$, $r_{ij}$. \n",
"\n",
"As such, we attempt a simple minimization procedure to find the optimal positions of the atoms in the Register that replicate best the off-diagonal terms of $Q$:"
]
},
{
Expand All @@ -125,8 +141,7 @@
"outputs": [],
"source": [
"def evaluate_mapping(new_coords, *args):\n",
" \"\"\"Cost function to minimize. Ideally, the pairwise\n",
" distances are conserved\"\"\"\n",
" \"\"\"Cost function to minimize. Ideally, the pairwise distances are conserved.\"\"\"\n",
" Q, shape = args\n",
" new_coords = np.reshape(new_coords, shape)\n",
" new_Q = squareform(\n",
Expand Down Expand Up @@ -178,6 +193,13 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this case, this simple procedure was enough to give a good and valid embedding but it will not always be so. For QUBO instances that are not as easy to embbed as this one, more complex embedding strategies are required."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -193,9 +215,9 @@
"\n",
"$$ H_Q= \\sum_{i=1}^N \\frac{\\hbar\\Omega}{2} \\sigma_i^x - \\sum_{i=1}^N \\frac{\\hbar \\delta}{2} \\sigma_i^z+\\sum_{j \\lt i}\\frac{C_6}{|\\textbf{r}_i-\\textbf{r}_j|^{6}} n_i n_j. $$\n",
"\n",
"In the case where our mapping of the atoms is perfect, the last sum replicates exactly the off-diagonal terms of $Q$. In that case, the next step is to prepare the ground-state of $H_Q$ to output the optimal bitstrings.\n",
"In the case where our mapping of the atoms is perfect, the last sum replicates exactly the off-diagonal terms of $Q$. Additionally, since the diagonal terms are all the same, we can use a Rydberg global beam with an approriate detuning $\\delta$ (otherwise, some kind of local addressability capabilities would be necessary).\n",
"\n",
"To do so we present two different approaches, namely the Quantum Approximation Optimization Algorithm (QAOA) and the Quantum Adiabatic Algorithm (QAA) that have been introduced to prepare ground-states of Hamiltonians."
"As such, the next step is to prepare the ground-state of $H_Q$ to output the optimal bitstrings. To do so we present two different approaches, namely the Quantum Approximation Optimization Algorithm (QAOA) and the Quantum Adiabatic Algorithm (QAA) that have been introduced to prepare ground-states of Hamiltonians."
]
},
{
Expand Down Expand Up @@ -481,13 +503,6 @@
"In our case, we continuously vary the parameters $\\Omega(t), \\delta(t)$ in time, starting with $\\Omega(0)=0, \\delta(0)<0$ and ending with $\\Omega(0)=0, \\delta>0$. The ground-state of $H(0)$ corresponds to the initial state $|00000\\rangle$ and the ground-state of $H(t_f)$ corresponds to the ground-state of $H_Q$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The Rydberg blockade radius is directly linked to the Rabi frequency $\\Omega$ and is obtained using `DigitalAnalogDevice.rydberg_blockade_radius()`. In this notebook, $\\Omega$ is initially fixed to a frequency of 1 rad/µs. We can therefore build the adjacency matrix $A$ of $G$ in the following way:"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down