I am solving a QUBO using QAOA. It works flawlessly with default parameters for smaller instances of the problem, but my RAM is saturated when I try to solve a problem of size 15. I suspect this can be resolved by changing the parameter p
. Don't mind if it generates a wrong result as output, at least don't wanna run out of resources and end abruptly. I even checked with different simulators, but it didn't work. Mainly, want to know how to play around with the number of layers p
.
Here's the code for reference:
from qiskit import Aer
from qiskit.aqua import aqua_globals, QuantumInstance
from qiskit.aqua.algorithms import QAOA
from qiskit.optimization import QuadraticProgram
qp=QuadraticProgram()
qp.from_ising(op, offset, linear=True)
aqua_globals.random_seed = 123
quantum_instance = QuantumInstance(Aer.get_backend('aer_simulator'),
seed_simulator=aqua_globals.random_seed,
seed_transpiler=aqua_globals.random_seed)
qaoa_mes = QAOA(quantum_instance=quantum_instance, initial_point=[0., 0.])
qaoa = MinimumEigenOptimizer(qaoa_mes)
result = qaoa.solve(qubo)
Also, how to get the circuit?
p
here the layer of your QAOA's Ansatz (on a 15 qubit problem) ? It seems like you are havingp
= 2 ? $\endgroup$p
is the number of times the interactions(CNOT+R_Z+CNOT) are performed in the circuit. Furthermore, asp
tends to infinity, the probability of QAOA generating the correct solution increases. $\endgroup$