• Members 8 posts
    Oct. 13, 2021, 12:56 p.m.

    From my understanding, the parameters used in QAOA circuit (eg, beta for mix H and alpha for cost H) are non-deterministic. We can use different techniques to initialize these parameters and they will be updated according to the optimizer. The parameters are used in Rz gate. Please correct me if I didn't understand it correctly!

    Let's say we have a weighted graph and we want to use QAOA to solve maxcut problem, the cost Hamiltonian H_c = 0.5 * IZZI + 0.5 * ZIIZ +...
    My question is, how to demonstrate the weights (i.e, 0.5 in this case) in our circuit? Is there a different approach to construct a QAOA circuit for a weighted graph compared to an unweighted graph?

  • Members 11 posts
    Oct. 14, 2021, 9:56 p.m.

    The weights determine relative strength of evolution of the corresponding term. Your cost Hamiltonian is a bit trivial as both terms have coefficient 0.5. This corresponds to a graph where both edges have weights 0.5, which is the same as weight 1. If $H_c=0.5IZZI+ZIIZ$ (i.e. different weights), then the corresponding evolution term is $e^{i\gamma H_c}$, which you can break down to two gates $e^{i\gamma IZZI/2}$ and $e^{i\gamma ZIIZ}$.

  • Members 8 posts
    Oct. 15, 2021, 4:33 a.m.

    Thanks for your reply! Yes, my cost Hamiltonian is trivial... Let's take your's as an example, and the weights are 0.5 and 1, respectively. When I construct the circuit, will the two weights somehow influence the circuit? The parameters in Rz gate are not equal to the weights, are they? So the circuits for $H_c = \alpha IZZI + \beta ZIIZ$ for arbitrary $\alpha$ and $\beta$ are the same if use the same parameters for initialization? Thanks!

  • Members 11 posts
    Oct. 15, 2021, 8:20 a.m.

    Yes the weights influence the circuit. For angle $\gamma$, the evolution will be $e^{i\gamma H_c}$, which is equivalent to $e^{i\alpha\gamma IZZI}\otimes e^{i\beta\gamma ZIIZ}$. Note that the two terms have different coefficient, $\alpha\gamma$ and $\beta\gamma$ respectively. $\gamma$ is a global parameter for every term in the Hamiltonian, and $\alpha$,$\beta$ are the weights of the graph. Hope this is clear!

  • Members 8 posts
    Oct. 18, 2021, 9:55 a.m.

    Thanks for your answer! A follow-up question :) No matter the graph is weighted or unweighted, the QAOA circuit always has the same structure as shown in the photo. The weights will influence the classical optimization part, which can further influence the angles $\beta$ and $\gamma$ in the circuit. Is that correct?
    image.png

    image.png

    PNG, 24.8 KB, uploaded by Peachnuts on Oct. 18, 2021.

  • Members 22 posts
    Oct. 18, 2021, 5:57 p.m.

    I think the QAOA circuit for a weighted graph with different weight $a$ and $b$, and $\gamma$ to be the first layer variable should be

    from qiskit import QuantumCircuit
    from qiskit.circuit import Parameter
    
    gamma = Parameter('γ')
    beta = Parameter('β')
    a = Parameter('a')
    b = Parameter('b')
    qc = QuantumCircuit(4)
    qc.h(range(4))
    # first term in H
    qc.cx(1,2)
    qc.rz(gamma*a,2)
    qc.cx(1,2)
    qc.barrier()
    # second term in H
    qc.cx(0,3)
    qc.rz(gamma*b,3)
    qc.cx(0,3)
    qc.barrier()
    
    qc.rx(2*beta,range(4))
    qc.draw('mpl')
    

    image.png
    and $a, b$ are fixed, we send this circuit to optimizer and optimize $\gamma,\beta$

    image.png

    PNG, 58.0 KB, uploaded by Meng on Oct. 18, 2021.