Experimentally validating QAOA concepts
So far, we have seen how specific gate rotations can be used to increase the probability of the qubit states that produce the lowest cost. We have also seen that we apply the X gate first and then the Hadamard gate to all the qubits to bring them to the |-⟩ state. From there, we apply RZ and ZZ rotations to individual qubits and pairs of qubits, respectively. Finally, we apply the RX gates to bring the information into the measurement basis. Let’s implement this in code:
- First, let’s look at the effect that RZ rotations have on the linear terms. We will begin by defining the
objective
function, as follows:objective=np.array([[-1,-1],[0,2]]) eq=matrix_to_polynomial(objective)
Output:
-1x
₀²+2x
₁²-1x
₀x
₁
- We want to see the effect of the coefficient on x0, which is -1, and on x1, which is 2 on the qubit vectors. In the following code, we will create a combined circuit...