Quantum Approximate Optimization Algorithm¶

Copyright (c) 2021 Institute for Quantum Computing, Baidu Inc. All Rights Reserved.

Overview¶

Quantum Approximate Optimization Algorithm (QAOA) is a quantum algorithm that can run on recent Noisy Intermediate-Scale Quantum (NISQ) devices and has a wide range of applications. QAOA was proposed by Edward Farhi et al. in 2014 [1], and its purpose is to solve combinatorial optimization problems approximately.

Combinatorial optimization problem¶

In applied mathematics and theoretical computer science, combinatorial optimization is a type of topic that finds the optimal object in a discrete set of objects. In simple terms, the combinatorial optimization problem means that all solutions of the problem are composed of discrete variables, and the optimal solution is to be found in the discrete solution set. Combinatorial optimization problems involve a wide range of areas and are common in real life, such as the design of aircraft routes and the planning of express delivery routes.

Specifically, a combinatorial optimization problem can be described by nn bits and mm clauses. Each bit is a binary variable whose value is 00 or 11, and we use zjzj to denote the value of the jjth bit. Therefore, the value of these nn bits can be represented by the bit string z=z1z2…znz=z1z2…zn. Each clause is a restriction on some bits. For example, a clause can require the value of the 22nd bit to be 00, or it can require the value of the 33rd bit and the 55th bit to be the same. For the jjth clause, we define a function

Cj(z)={1If the value z of n bits satisfies the condition indicated by clause j0if the value z of n bits does not satisfy the condition indicated by clause j.(1)(1)Cj(z)={1If the value z of n bits satisfies the condition indicated by clause j0if the value z of n bits does not satisfy the condition indicated by clause j.

For example, if the first clause requires the value of the second bit to be 0, then we have C1(z10z3…zn)=1C1(z10z3…zn)=1 and C1(z11z3…zn)=0C1(z11z3…zn)=0.

From the definition of CjCj in equation (1), we can define the objective function of the combinatorial optimization problem

C(z)=m∑j=1wjCj(z),(2)(2)C(z)=∑j=1mwjCj(z),

where wjwj is the weight of the jjth clause. The combinatorial optimization problem is to find a value zz that maximizes the value of the objective function C(z)C(z), namely

argmaxzC(z).(3)(3)argmaxzC(z).

In theoretical computer science, there is a famous problem called the Boolean satisfiability problem (SAT). This problem asks that, given nn bits and mm clauses as inputs, if there exists a value these bits can take so that all the mm clauses are satisfied simultaneously. An optimization problem related to SAT is MAX-SAT, which asks that what value these nn bits should take so that as many as possible clauses are satisfied. It is worth noting that the way we define a combinatorial optimization problem above is to formulate it as MAX-SAT, or more precisely, weighted MAX-SAT.

Quantum approximate optimization algorithm¶

Many combinatorial optimization problems are NP-complete or even NP-hard problems, which means that computers may not be able to solve such problems efficiently. An alternative is to find the approximate optimal solution to such problems, and this task can usually be completed efficiently. QAOA is a quantum algorithm that can find an approximate optimal solution to a combinatorial optimization problem.

Encoding combinatorial optimization problem¶

For the above combinatorial optimization problem, there are nn bits and mm clauses. The QAOA algorithm transforms this problem into an optimization problem on an nn-qubit system. Each computational basis state |z⟩∈{0,1}n|z⟩∈{0,1}n of the quantum system corresponds to a value zz of nn bits in the original problem. At the same time, for the jjth clause in the original problem, we define a diagonal Hamiltonian HCjHCj satisfying

HCj|z⟩=Cj(z)|z⟩.(4)(4)HCj|z⟩=Cj(z)|z⟩.

Specifically, we can construct the Hamiltonian HCjHCj through the following equation:

HCj=∑z∈{0,1}nCj(z)|z⟩⟨z|.(5)(5)HCj=∑z∈{0,1}nCj(z)|z⟩⟨z|.

For example, assuming that z(1)z(1) and z(2)z(2) are the values ​​satisfying the jjth clause, then we can define

HCj=|z(1)⟩⟨z(1)|+|z(2)⟩⟨z(2)|.(6)(6)HCj=|z(1)⟩⟨z(1)|+|z(2)⟩⟨z(2)|.

Therefore, QAOA encodes the objective function CC of the combinatorial optimization problem into the Hamiltonian HCHC on a system with nn qubits, where

HC=m∑j=1wjHCj,(7)(7)HC=∑j=1mwjHCj,

and

HC|z⟩=m∑j=1wjHCj|z⟩=m∑j=1wjCj(z)|z⟩=C(z)|z⟩.(8)(8)HC|z⟩=∑j=1mwjHCj|z⟩=∑j=1mwjCj(z)|z⟩=C(z)|z⟩.

It is worth noting that if an optimal solution to the original problem is zoptzopt, then we have

⟨zopt|HC|zopt⟩=⟨zopt|C(zopt)|zopt⟩=C(zopt)⟨zopt|zopt⟩=C(zopt).(9)(9)⟨zopt|HC|zopt⟩=⟨zopt|C(zopt)|zopt⟩=C(zopt)⟨zopt|zopt⟩=C(zopt).

Therefore, an optimal solution of the original combinatorial optimization problem is an eigenstate with the largest eigenvalue of the Hamiltonian HCHC. In addition, for any quantum state |ψ⟩|ψ⟩,

⟨ψ|HC|ψ⟩≤C(zopt),(10)(10)⟨ψ|HC|ψ⟩≤C(zopt),

and the equation takes the equal sign if and only if |ψ⟩|ψ⟩ is a superposition state of optimal solutions. It can be obtained from equation (9) and equation (10) that

max|ψ⟩⟨ψ|HC|ψ⟩=C(zopt),(11)(11)max|ψ⟩⟨ψ|HC|ψ⟩=C(zopt),

and finding the optimal solution of the original combinatorial optimization problem is equivalent to finding an eigenstate with the largest eigenvalue of the Hamiltonian HCHC, that is, finding a quantum state |ψ⟩|ψ⟩ such that

HC|ψ⟩=C(zopt)|ψ⟩.(12)(12)HC|ψ⟩=C(zopt)|ψ⟩.

When we find such a quantum state |ψ⟩|ψ⟩, it is probably not a computational basis state, but a superposition of several computational basis states, each of which is an optimal solution of the original combinatorial optimization problem. Therefore, we can obtain an optimal solution to the original combinatorial optimization problem by performing computational basis measurements on |ψ⟩|ψ⟩.

Finding an approximate optimal solution¶

Although it is relatively simple to encode the objective function of the combinatorial optimization problem to be solved into the Hamiltonian HCHC of a quantum system, finding the quantum state |ψ⟩|ψ⟩ representing an optimal solution from the huge Hilbert space according to equation (11) is not easy. In order to find such a quantum state, we need another Hamiltonian

HB=n∑j=1Xj,(13)(13)HB=∑j=1nXj,

where XjXj represents the Pauli XX gate acting on the jjth qubit. The two eigenstates of Pauli XX gate are |+⟩|+⟩ and |−⟩|−⟩, and their corresponding eigenvalues ​​are 11 and −1−1, respectively:

X|+⟩=[0110]1√2[11]=1√2[11]=|+⟩,X|−⟩=[0110]1√2[1−1]=1√2[−11]=−|−⟩.(14)(15)(14)X|+⟩=[0110]12[11]=12[11]=|+⟩,(15)X|−⟩=[0110]12[1−1]=12[−11]=−|−⟩.

Therefore, the eigenstate with the largest eigenvalue of HBHB is

|s⟩≡|+⟩⊗⋯⊗|+⟩n terms=|+⟩⊗n.(16)(16)|s⟩≡|+⟩⊗⋯⊗|+⟩⏟n terms=|+⟩⊗n.

We will use this quantum state |s⟩|s⟩ as the initial state for the algorithm. After constructing the Hamiltonian HCHC and HBHB, we can start to find an approximate optimal solution to the original combinatorial optimization problem. According to the Hamiltonian HCHC and HBHB, respectively define the unitary transformation

UC(γ)=e−iγHC(17)(17)UC(γ)=e−iγHC

and unitary transformation

UB(β)=e−iβHB,(18)(18)UB(β)=e−iβHB,

where γγ and ββ are adjustable real parameters. Given any integer p≥1p≥1 and the parameters →γ=(γ1,…,γp)γ→=(γ1,…,γp) and →β=(β1,…,βp)β→=(β1,…,βp), we define

|→γ,→β⟩=UB(βp)UC(γp)⋯UB(β1)UC(γ1)|s⟩.(19)(19)|γ→,β→⟩=UB(βp)UC(γp)⋯UB(β1)UC(γ1)|s⟩.

It can be seen that the integer pp represents the number of layers of UC,UBUC,UB, that is, the UCUC and UBUB are alternately applied to the initial state |s⟩|s⟩ pp times. Let us denote Fp(→γ,→β)Fp(γ→,β→) as the expected value of the Hamiltonian HCHC in the quantum state of equation (19):

Fp(→γ,→β)=⟨→γ,→β|HC|→γ,→β⟩.(20)(20)Fp(γ→,β→)=⟨γ→,β→|HC|γ→,β→⟩.

By adjusting the parameters →γ,→βγ→,β→, we can get

Mp=max→γ,→βFp(→γ,→β)(21)(21)Mp=maxγ→,β→Fp(γ→,β→)

as the approximate optimal solution under a given number of layers pp. So far, we have transformed the problem of searching for the quantum state |ψ⟩|ψ⟩ into a problem of searching for the parameters →γ,→βγ→,β→. It is worth noting that the search space given by pp layers of UC,UBUC,UB is larger than that of p−1p−1 layers, so

Mp≥Mp−1.(22)(22)Mp≥Mp−1.

In fact, when pp is large enough,

limp→∞Mp=maxzC(z).(23)(23)limp→∞Mp=maxzC(z).

Decoding the quantum solution¶

In the previous paragraph, we simplify the search for the quantum state |ψ⟩|ψ⟩ into the search for the parameterized quantum state |→γ,→β⟩|γ→,β→⟩, but at the same time, we have also reduced the search space. That is to say, given the number of layers pp, there may be no parameters →γ,→βγ→,β→ such that Fp(→γ,→β)=C(zopt)Fp(γ→,β→)=C(zopt). Suppose that the parameters →γ∗γ→∗ and →β∗β→∗ make FpFp the largest, that is, Fp(→γ∗,→β∗)=MpFp(γ→∗,β→∗)=Mp. Then under ideal circumstances, the quantum state |→γ∗,→β∗⟩|γ→∗,β→∗⟩ contains the information of an optimal solution. But it should be noted that only pp layers are used here, so it is very likely that Mp<C(zopt)Mp<C(zopt). Therefore, in general |→γ∗,→β∗⟩|γ→∗,β→∗⟩ only contains information about an approximate optimal solution. Furthermore, we assume that the quantum state |→γ∗,→β∗⟩|γ→∗,β→∗⟩ is the superposition state of ll computational basis state, namely

|→γ∗,→β∗⟩=c1|z(1)⟩+⋯+cl|z(l)⟩.(24)(24)|γ→∗,β→∗⟩=c1|z(1)⟩+⋯+cl|z(l)⟩.

Normally, the larger the probability |cj|2|cj|2 that a state |z(j)⟩|z(j)⟩ is measured on the computational basis, the more likely that the corresponding bit string z(j)z(j) is an optimal solution. Thus, we prepare |→γ∗,→β∗⟩|γ→∗,β→∗⟩ and measure it to get a bit string zz and calculate the value of C(z)C(z). Repeat this process many times, and we can get a bit string zz that makes C(z)C(z) close to or even exceed MpMp.

Adiabatic theorem¶

Why do we use the above method to construct the quantum state |→γ,→β⟩|γ→,β→⟩? QAOA tries to find an approximate optimal solution to an optimization problem. A similar algorithm is the quantum adiabatic algorithm [2] (QAA). The difference is that QAA is designed to find an optimal solution to the optimization problem rather than an approximate one. Similar to QAOA, QAA transforms an optimization problem into a problem of finding the ground state of a Hamiltonian, and uses the adiabatic theorem to solve it. Consider the Hamiltonian

H(t)=(1−tT)HB+tTHC,(25)(25)H(t)=(1−tT)HB+tTHC,

of a quantum system. At initial, time t=0t=0, and the Hamiltonian of the system is H(0)=HBH(0)=HB. As time passes, the Hamiltonian of the system gradually changes from HBHB to HCHC. When t=Tt=T, the Hamiltonian of the system becomes H(T)=HCH(T)=HC. The adiabatic theorem in quantum mechanics tells us that if the system is in an eigenstate of HBHB at the beginning, then as long as the evolution time TT is long enough, the system will be in the eigenstate of the corresponding energy level of HCHC when the Hamiltonian of the system completely evolves to HCHC. Therefore, if the system is initially in |s⟩|s⟩, that is, the eigenstate with the largest eigenvalue of HBHB, after a sufficiently long evolution time TT, the quantum state of the system will become the eigenstate with the largest eigenvalue of HCHC. [3]

One way to simulate the evolution of the Hamiltonian H(t)H(t) over time tt is to alternately apply the unitary transformations UC(γ)UC(γ) and UB(β)UB(β) on the quantum system, and the accuracy of simulation depends on the value of γ,βγ,β. In addition, in order for the evolution of the system to follow the adiabatic theorem, a sufficiently long evolution time is required, so the value of pp is required to be large enough. Therefore, combining equation (22) we can deduce the conclusion in equation (23).


References¶

[1] Farhi, E., Goldstone, J. & Gutmann, S. A Quantum Approximate Optimization Algorithm. arXiv:1411.4028 (2014).

[2] Farhi, E., Goldstone, J., Gutmann, S. & Sipser, M. Quantum computation by adiabatic evolution. arXiv:quant-ph/0001106 (2000).

[3] Duan, R. Quantum Adiabatic Theorem Revisited. arXiv:2003.03063 (2020).