I am trying to optimize a Hamiltonian using QAOA in IBM Qiskit.
I used the following 'minimize' function to get my result. (I am not including the whole code because it will get unnecessarily long).
res = minimize(cost_func, x0, args=(ansatz, hamiltonian, estimator), method="COBYLA")
res
When I ran the problem on a 'ibmq qasm simulator' I got the following result:
fun: -23.1424
maxcv: 0.0
message: 'Optimization terminated successfully.'
nfev: 45
status: 1
success: True
x: array([3.39824022, 4.17447906, 2.86297948, 3.1139919 ])
I got multiple attributes in the solution.
But when I ran this on an actual quantum computer (ibm brisbane), I used the same code and same variable 'res'; it went on Queue and I had to wait for around 4-5 hours. But after the job was done, I cannot get the value for res which was defined in the previous line of code.
Traceback (most recent call last):
Cell In[1], line 1
res
NameError: name 'res' is not defined
And I tried using job.result() but that doesn't have the required attributes I got from the results of the simulator stored in variable 'res'.
How can I get the attributes such as res.x from the already completed job?