|
13 | 13 | "id": "1", |
14 | 14 | "metadata": {}, |
15 | 15 | "source": [ |
16 | | - ">The **Quantum Approximate Optimization Algorithm (QAOA)**, introduced by Edward Farhi, Jeffrey Goldstone, and Sam Gutmannan [[1](#QAOA)], is a hybrid quantum–classical method for tackling combinatorial optimization problems like Max-Cut, scheduling, and constraint satisfaction. It prepares a parameterized quantum state by alternating two simple operations: one that encodes the problem’s cost function and another that “mixes” amplitudes across candidate solutions. After measuring the circuit, a classical optimizer updates the parameters to increase the expected cost, repeating this loop until good solutions are found. QAOA is especially appealing for near-term quantum devices because it uses shallow circuits, yet its quality can systematically improve as you increase the number of alternating layers. We demonstrate the algorithm by analyzing the Max-Cut and Knapsack problems. The former is an unconstrained optimization problem, while the latter is a constrained task. \n", |
| 16 | + ">The **Quantum Approximate Optimization Algorithm (QAOA)**, introduced by Edward Farhi, Jeffrey Goldstone, and Sam Gutmann [[1](#QAOA)], is a hybrid quantum–classical method for tackling combinatorial optimization problems like Max-Cut, scheduling, and constraint satisfaction. It prepares a parameterized quantum state by alternating two simple operations: one that encodes the problem’s cost function and another that “mixes” amplitudes across candidate solutions. After measuring the circuit, a classical optimizer updates the parameters to increase the expected cost, repeating this loop until good solutions are found. QAOA is especially appealing for near-term quantum devices because it uses shallow circuits, yet its quality can systematically improve as you increase the number of alternating layers. We demonstrate the algorithm by analyzing the Max-Cut and Knapsack problems. The former is an unconstrained optimization problem, while the latter is a constrained task. \n", |
17 | 17 | ">\n", |
18 | | - "> - **Input:** Classical objective function $C(x)=\\sum_{\\alpha=1}^{m} C_{\\alpha}(x)$ returning the number of satisied clauses by the $n$ bit string $x$, where $C_{\\alpha}(x)$ evaluates to $1$ if $z$ satisfies clause $\\alpha$ and $0$ otherwise. \n", |
19 | | - "> - **Output:** Binary string $x^*$, constituting the best solution from the pool of solution candidates, maximizing the objective function.\n", |
| 18 | + "> - **Input:** Classical objective function $C(x)$ on $n$-bit variable $x$. $C(x)$ is commonly constructed to output the number of satisfied clauses by the $x$. \n", |
| 19 | + "> - **Output:** A bit array $x^*$, constituting the best solution from the pool of candidates, maximizing the objective function.\n", |
20 | 20 | ">\n", |
21 | 21 | "> **Complexity:** The algorithm involves iteration over two types of operations. The \"cost\" operations involve $O(m)$ two-qubit gates, scaling linearly with the number of clauses m. While the mixing operation involves $n$ single-qubit gates. Hence, a single shot of a $p$-depth QAOA circuit includes $O(p(n+m))$ single and double qubit gates. \n", |
22 | 22 | ">\n", |
|
43 | 43 | "1. **Cost layer:** \n", |
44 | 44 | " A phase rotation in the $Z$-direction is applied based on the cost function:\n", |
45 | 45 | " $$\n", |
46 | | - " |x\\rangle \\xrightarrow{U_{\\text{C}}(\\gamma)} e^{i\\gamma H_C(x)} |x\\rangle ,\n", |
| 46 | + " |x\\rangle \\xrightarrow{U_{\\text{C}}(\\gamma)} e^{i\\gamma H_C(x)} |x\\rangle ~~,\n", |
47 | 47 | " $$\n", |
48 | 48 | " where $H_C(x)$ is diagonal in the computational basis, encoding the classical cost function $C(x)$. \n", |
49 | 49 | "\n", |
50 | 50 | "3. **Mixer layer:** \n", |
51 | 51 | " An $X$-rotation is applied to all qubits:\n", |
52 | 52 | " $$\n", |
53 | | - " U_B(\\beta) = e^{-i\\beta H_M}, \\quad \\text{with } H_M = \\sum_i X_i.\n", |
| 53 | + " U_B(\\beta) = e^{-i\\beta H_M}, \\quad \\text{with } H_M = \\sum_i X_i~~.\n", |
54 | 54 | " $$\n", |
55 | 55 | " This operation induces transitions between computational basis states based on the phases that were assigned by the previous layer\n", |
56 | 56 | "\n", |
57 | | - "By alternating these operations, the QAOA ansatz explores the combinatorial optimization space. After $p$ iterations, the state is measured in the computational basis. Repeated repetitions of the basic experiment lead to a sample of bit strings $\\{x\\}$ and associated costs $\\{C(x)\\}$. The average cost is given by the expectation value $\\langle \\boldsymbol{\\gamma}\\boldsymbol{\\beta}| H_C(x)|{\\boldsymbol{\\gamma}\\boldsymbol{\\beta}}\\rangle$. Following, the variational parameters are adjusted according to a chosen classical optimization algorithm, and the procedure is repeated until convergence of $C(x)$ to a maximum value.\n", |
| 57 | + "By alternating these operations, the QAOA ansatz explores the combinatorial optimization space. After $p$ iterations, the state is measured in the computational basis. Repeated repetitions of the basic experiment lead to a sample of binary arrays (i.e, bit strings) $\\{x\\}$ and associated costs $\\{C(x)\\}$. The average cost is given by the expectation value $\\langle \\boldsymbol{\\gamma}\\boldsymbol{\\beta}| H_C(x)|{\\boldsymbol{\\gamma}\\boldsymbol{\\beta}}\\rangle$. Following, the variational parameters are adjusted according to a chosen classical optimization algorithm, and the procedure is repeated until convergence of $C(x)$ to a maximum value.\n", |
58 | 58 | "\n", |
59 | 59 | "**Note:** In the limit of $p\\rightarrow \\infty$, the QAOA ansatz state can approximate adiabatic evolution and converges to the optimum solution (see Technical Notes).\n" |
60 | 60 | ] |
|
73 | 73 | "metadata": {}, |
74 | 74 | "source": [ |
75 | 75 | "The implementation follows a modular design, associating a regular and `@qfunc` functions to the algorithmic components:\n", |
76 | | - "- A **cost function** evaluating the classical cost function associated with a particular bit string.\n", |
| 76 | + "- A **cost function** evaluating the classical cost function associated with a particular binary array instance.\n", |
77 | 77 | " \n", |
78 | 78 | "- **cost layer** function which employs the cost function to evaluate phase rotations of quantum states in the computational basis, with a parameter $\\gamma$ controlling the extent of phase rotation.\n", |
79 | 79 | "\n", |
80 | 80 | "- A **mixer layer**, that applies a uniform $RX$ rotations (with parameter $\\beta$) to all qubits.\n", |
81 | 81 | "\n", |
82 | | - "- **QAOA ansatz**, the overall circuit is constructed by first preparing a uniform superposition (via a Hadamard transform), consisting the ground state of the mixer Hamiltonian $H_B$, and then alternating the cost and mixer layers for a specified number of layers." |
| 82 | + "- **QAOA ansatz**, the overall circuit is constructed by first preparing a uniform superposition (via a Hadamard transform), which constitutes the ground state of the mixer Hamiltonian $H_B$, and then alternating the cost and mixer layers for a specified number of layers." |
83 | 83 | ] |
84 | 84 | }, |
85 | 85 | { |
|
103 | 103 | "$$\n", |
104 | 104 | "C_{\\text{MC}}(x)=\\sum_{(i,j) \\in E} \\frac{1-x_i x_j}{2}\n", |
105 | 105 | "$$\n", |
106 | | - "where $x = x_1x_2\\dots x_{|V|}$ is a bit string encoding the graphs vertices, and $x_i = 1$, $i\\in [1,n]$ if the $i$'th vertex is in subset $S$ or $x_i = -1$ if the $i$'th vertex is in $\\bar{S}$.\n", |
| 106 | + "where $x = x_1x_2\\dots x_{|V|}$ is a bit array encoding the graphs vertices, and $x_i = 1$, $i\\in [1,n]$ if the $i$'th vertex is in subset $S$ or $x_i = -1$ if the $i$'th vertex is in $\\bar{S}$.\n", |
107 | 107 | "\n", |
108 | 108 | "The Max-Cut problem is known to be $\\mathsf{NP}$-complete.\n", |
109 | 109 | "\n", |
|
0 commit comments