Convert Hamiltonian QUBO matrix of quantum annealing to Hamiltonian of quantum gate
Hi let's convert a Hamiltonian QUBO matrix from quantum annealing to quantum gate Hamiltonian. When you enter quantum gate model business from quantum annealing, you want to convert your previous software assets. blueqat has that conversion tool since 2018, which allows you to leverage your quantum annealing assets in quantum gates. Let's take a look at exactly how.
Call pauli in the old wildqat module and convert QUBO to Pauli operations.
Basically, we revert to the Ising formulation, convert it to a form that can be read by quantum gate operators. First, let's load the tool.
Copy
import blueqat.wq as wq
And then make QUBO matrix
Copy
QUBO = [[1,1],[0,1]]
And put it into wq.pauli. It's quite easy.
Copy
hamiltonian = wq.pauli(QUBO)
Let's see how it converted.
Copy
print(hamiltonian)
1.25*I - 0.75*Z[0] - 0.75*Z[1] + 0.25*Z[0]*Z[1]
It is done let's do calculation on gate model.
Put the transformed Pauli matrix into QAOA.
Quantum gates have a small number of qubits, so we can't solve large problems yet. Since the above matrix is small, let's run it by determining the number of steps, a parameter to divide analog into digital. In this case, let's set step p=2.
Copy
step = 2
blueqat has a function to automatically calculate QAOA from time evolution and variational formulation. Let's just put step and hamiltonian into the function
Copy
from blueqat import vqe
result = vqe.Vqe(vqe.QaoaAnsatz(hamiltonian, step)).run()
print(result.most_common(12))