# Repeated application of the oracles <math>U_C</math> and <math>U_M</math>, in the order: <math>U(\boldsymbol\gamma, \boldsymbol\alpha) = \coprod_{i=1}^N (U_C(\gamma_i) U_M(\alpha_i))</math>
# Preparing an initial state, that is a superposition of all possible states and apply <math>U(\boldsymbol\gamma, \boldsymbol\alpha)</math> to the state.
# Using classical methods to optimize the parameters <math>\boldsymbol\gamma, \boldsymbol\alpha</math> and measure the output state of the optimized circuit to obtain the approximate optimal solution to the cost Hamiltonian. TheAn optimal solution will be the one that maximisesmaximizes the expectation value of the cost Hamiltonian <math>H_C</math>.
[[File:QAOAcircuit.png|thumb|457x457px|Sample QAOA ansatz for a three qubit circuit]]
The layout of the algorithm, viz, the use of cost and mixer Hamiltonians are inspired from the [[Quantum Adiabatic Theorem|Quantum Adiabatic theorem]], which states that starting in thea ground state of a time-dependent Hamiltonian, if the Hamiltonian evolves slowly enough, the final state will be thea ground state of the final Hamiltonian. Moreover, the adiabatic theorem can be generalized to any other eigenstate as long as there is no overlap (degeneracy) between different eigenstates across the evolution. Identifying the initial Hamiltonian with <math>H_M</math> and the final Hamiltonian with <math>H_C</math>, whose ground statestates encodesencode the solution to the optimization problem of interest, one can approximate the optimization problem as the adiabatic evolution of the Hamiltonian from an initial to the final one, whose ground (eigen) statestated gives the optimal solutionsolutiond. In general, QAOA relies on the use of [[unitary operators]] dependent on <math> 2p </math> [[angle]]s (parameters), where <math> p>1 </math> is an input integer, which can be identified the number of layers of the oracle <math>U(\boldsymbol\gamma, \boldsymbol\alpha)</math>. These operators are iteratively applied on a state that is an equal-weighted [[quantum superposition]] of all the possible states in the computational basis. In each iteration, the state is measured in the computational basis and the boolean function <math> C(z) </math> is estimated. The angles are then updated classically to increase <math> C(z) </math>. After this procedure is repeated a sufficient number of times, the value of <math> C(z) </math> is almost optimal, and the state being measured is close to being optimal as well. A sample circuit that implements QAOA on a quantum computer is given in figure. This procedure is highlighted using the following example of finding the [[minimum vertex cover]] of a graph.<ref>{{Cite journal |last=Ceroni |first=Jack |date=2020-11-18 |title=Intro to QAOA |url=https://pennylane.aiundefined/ |journal=PennyLane Demos |language=en}}</ref>
=== QAOA for finding the minimum vertex cover of a graph ===
The goal here is to find thea [[Vertex cover|minimum vertex cover]] of a graph: a collection of vertices such that each edge in the graph contains at least one of the vertices in the cover. Hence, these vertices “cover” all the edges. We wish to find thea vertex cover that has the smallest possible number of vertices. Vertex covers can be represented by a bit string where each bit denotes whether the corresponding vertex is present in the cover. For example, the bit string 0101 represents a cover consisting of the second and fourth vertex in a graph with four vertices.
[[File:GraphforQAOA.png|thumb|220x220px|Sample graph to illustrate the minimum vertex cover problem.]]
Consider the graph given in the figure. It has four vertices and there are two minimum vertex cover for this graph: vertices 0 and 2, and the vertices 1 and 2. These can be respectively represented by the bit strings 1010 and 0110. The goal of the algorithm is to sample these bit strings with high probability. In this case, the cost Hamiltonian has two ground states, |1010⟩ and |0110⟩, coinciding with the solutions of the problem. The mixer Hamiltonian is the simple, non-commuting sum of [[Pauli matrices|Pauli-X]] operations on each node of the graph and they are given by:
<math>H_C = -0.25 Z_3 + 0.5 Z_0 + 0.5 Z_1 + 1.25 Z_2 + 0.75 (Z_0 Z_1 + Z_0 Z_2 + Z_2 Z_3 + Z_1 Z_2)</math>
<math>H_M = X_0 + X_1 + X_2 + X_3</math>
[[File:QAOAoutput.png|thumb|<nowiki>Output of QAOA implementation in Qiskit for minimum vertex cover problem. Note that the bit string |1010> is flipedflipped as |0101> as Qiskit uses reverse ordering of bits.</nowiki>]]
[[File:QAOAcircuitforGraph.png|thumb|Qiskit implementation of QAOA for minimum vertex cover problem.]]
Implementing QAOA algorithm for this four qubit circuit with two layers of the ansatz in qiskit (see figure) and optimizing leads to a probability distribution for the states given in the figure. This shows that the states |0110⟩ and |1010⟩ have the highest probabilities of being measured, just as expected.
=== GeneralisationGeneralization of QAOA to constrained combinatorial optimisation ===
In principle the optimal value of <math> C(z) </math> can be reached up to arbitrary precision, this is guaranteed by the adiabatic theorem<ref>{{cite arXiv|last1=Farhi|first1=Edward|last2=Goldstone|first2=Jeffrey|last3=Gutmann|first3=Sam|title=A Quantum Approximate Optimization Algorithm|eprint=1411.4028|class=quant-ph|year=2014}}</ref><ref>{{Cite journal|last1=Binkowski|first1=Lennart |last2=Koßmann|first2=Gereon |last3=Ziegler|first3=Timo |last4=Schwonnek|first4=René |date=2024-07-01|title=Elementary proof of QAOA convergence|journal=New Journal of Physics|volume=26|issue=7|pages=073001|doi=10.1088/1367-2630/ad59bb|arxiv=2302.04968 }}</ref> or alternatively by the universality of the QAOA unitaries.<ref>{{Cite journal|last1=Morales|first1=M. E. |last2=Biamonte|first2=J. D.|last3=Zimborás|first3=Z. |date=2019-09-20|title=On the universality of the quantum approximate optimization algorithm|journal=Quantum Information Processing|volume=19|issue=9 |pages=291|doi=10.1007/s11128-020-02748-9|arxiv=1909.03123 }}</ref> However, it is an open question whether this can be done in a feasible way.
For example, it was shown that QAOA exhibits a strong dependence on the ratio of a problem's [[Constraint (mathematics)|constraint]] to [[Variable (mathematics)|variables]] (problem density) placing a limiting restriction on the algorithm's capacity to minimize a corresponding [[Loss function|objective function]].<ref name=":0">{{Cite journal|last1=Akshay|first1=V.|last2=Philathong|first2=H.|last3=Morales|first3=M. E. S.|last4=Biamonte|first4=J. D.|date=2020-03-05|title=Reachability Deficits in Quantum Approximate Optimization|journal=Physical Review Letters|volume=124|issue=9|pages=090504|doi=10.1103/PhysRevLett.124.090504|pmid=32202873|arxiv=1906.11259|bibcode=2020PhRvL.124i0504A|s2cid=195699685}}</ref>
|