Specifically, I can't get the correct result using QAOA,A total of 6 qubits were used in this work,this is part of my code using VQE and QAOA localsim = BasicAer.get_backend('qasm_simulator')

optimizer = SPSA(max_trials=500)
ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')
vqe = VQE(op, ansatz, optimizer = optimizer)
results1 = vqe.run(localsim)


from qiskit import QuantumCircuit
optimizer = COBYLA(maxiter = 100)
depth = 10
initial = QuantumCircuit(nbr_qubits)
qaoa = QAOA(operator=op, optimizer=optimizer, p = depth,initial_state = initial, quantum_instance=localsim)
results2 = qaoa.run() 

I tried changing depth and optimizer type but it didn't work,The following two pictures are the results of VQE and QAOA respectively enter image description here

enter image description here

Is it because I'm using QAOA incorrectly?

  • $\begingroup$ What was your operator? $\endgroup$
    – KAJ226
    Commented May 29, 2022 at 18:56
  • $\begingroup$ op is an ising hamiltonian $\endgroup$
    – Zachary
    Commented May 30, 2022 at 4:39

1 Answer 1


I recommend use the new released version, but you can still plot out iteration with graph and compare them, see what happen. choose of optimizer, depth, max iteration will effect the result. reference: https://learn.qiskit.org/course/ch-applications/simulating-molecules-using-vqe


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.