Background
I am attempting to understand the post-aqua way that external qiskit libraries are supposed to be used for solving QUBOs. To do so I am trying to work with the toy problem of minimizing $f(x_1, x_2, x_3) = 2x_1x_2 + 3x_2x_3 - 4x_1x_3$, where $x_1,x_2,x_3 ∈\{0,1\}$. Looking at the migration guide I found code very much like the following:
from qiskit.algorithms import QAOA
from qiskit.algorithms.optimizers import COBYLA
from qiskit.opflow import Z, I
from qiskit import Aer, transpile
from qiskit.utils import QuantumInstance
# Define the problem Hamiltonian
observable = Z ^ I # Example Hamiltonian (modify as per your problem)
# Define the QAOA instance with an optimizer and quantum instance
optimizer = COBYLA() # You can choose a different optimizer
quantum_instance = QuantumInstance(Aer.get_backend('statevector_simulator'))
qaoa = QAOA(optimizer=optimizer, quantum_instance=quantum_instance)
# Compute the minimum eigenvalue using QAOA
result = qaoa.compute_minimum_eigenvalue(observable)
print(result.eigenvalue)
I imagine that, to an expert's eyes, it is trivial to replace the line observable = Z ^ I
with code that corresponds to $2x_1x_2 + 3x_2x_3 - 4x_1x_3$.
The Question
I get a wide range of errors as I try different ways of doing this and a lot of tutorials online use deprecated code. A template solution would be greatly appreciated. Can someone show me how to solve this toy problem?