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)
and
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
Is it because I'm using QAOA incorrectly?