Hello, When solving combinatorial optimization problems on a quantum computer, it is very difficult to create quantum entanglement. In this article, I will try to do an optimization calculation using the state vector specification function of blueqat0.4.1, which is a simulator-only function but allows you to specify the state vector.
Quantum adiabatic time evolution
Combinatorial optimization problems can be solved by using a method called QAOA. The application of quantum adiabatic time evolution to combinatorial optimization involves solving an eigenvalue problem, which is achieved by swapping the eigenstates of two Hamiltonians.
H∣ψ⟩=E0∣ψ⟩
The replacement of these Hamiltonians can be done using the time evolution operator. blueqat originally comes with a module to perform QAOA.
Example
Solve for the Hamiltonian as shown below.
H=2q1−4q0q1
To solve this in QAOA is simple.
Copy
!pip install -U blueqat
Requirement already up-to-date: blueqat in /opt/conda/lib/python3.8/site-packages (0.4.1)
Requirement already satisfied, skipping upgrade: numpy~=1.12 in /opt/conda/lib/python3.8/site-packages (from blueqat) (1.19.1)
Requirement already satisfied, skipping upgrade: scipy>=1.1.0 in /opt/conda/lib/python3.8/site-packages (from blueqat) (1.4.1)
Copy
from blueqat import vqe
from blueqat.pauli import qubo_bit as q
h = 2*q(1)-4*q(0)*q(1)
step = 2
result = vqe.Vqe(vqe.QaoaAnsatz(h, step)).run()
print(result.most_common(12))
Let's change the search method to mixer, and prepare a mixer and its corresponding initial state.
Copy
from blueqat import Circuit
from blueqat.pauli import X, Y, Z, I
#mixer and inital state
mixer = 0.5*X[0]*X[1] + 0.5*Y[0]*Y[1]
init = Circuit().h[0].cx[0,1].x[0]
h = 2*q(1)-4*q(0)*q(1)
step=2
result = vqe.Vqe(vqe.QaoaAnsatz(h, step, init, mixer)).run()
print(result.most_common(12))
The initial state shown above was an entangled state of 01 and 10. It becomes more difficult when the number of qubits increases to three. When the number of qubits increases to four, it becomes even more difficult. In order to easily handle this, it is necessary to prepare the initial state in a simple way, but it is quite difficult to write this as a combination of gates. The above entanglement circuit is a
Then, run the ansatz of the QAOA circuit mentioned earlier. If we connect the circuit with the initial state vector as input to the circuit with the initial entanglement circuit removed (there is a short rewrite to Rzz and Rxx in the middle), we get
Copy
c = Circuit(2).rzz(28.48504526568177)[0,1].rz(-28.48504526568177)[0].rxx(-13.395826737916892)[0,1].rx(-1.5707963267948966)[0].rx(-1.5707963267948966)[1].rzz(-13.395826737916892)[0,1].rx(1.5707963267948966)[0].rx(1.5707963267948966)[1].rzz(29.964021341813513)[0,1].rz(-29.964021341813513)[0].rxx(-9.00039424636803)[0,1].rx(-1.5707963267948966)[0].rx(-1.5707963267948966)[1].rzz(-9.00039424636803)[0,1].rx(1.5707963267948966)[0].rx(1.5707963267948966)[1].m[:]
c.run(shots=1000, initial=vec)
Counter({'10': 933, '01': 67})
This is how it turned out. This is because we are solving an optimization problem in time evolution from 01 and 10, which should come out 50-50, so the answer 10 has priority and samples more. In this way, we were able to do QAOA with a state vector start. This will allow us to efficiently test simulations on larger problems. I encourage you to give it a try.