I'm trying to solve the maximum independent set problem using Qiskit and the QAOA.
I've a nice QUBO Matrix for this simple path graph:
as so:
My question is, how do I convert this into a general DOCPLEX method which can be put into the QuadracticProgram
method of Qiskit? How can this be done for a general QUBO matrix?
I realise that for this particular problem I've found the matrix $Q$ as described in this [guide].(https://arxiv.org/ftp/arxiv/papers/1811/1811.11538.pdf)
So by doing the matrix multiplication:
$$y=x^{t} Q x$$
where $$ x = \begin{pmatrix} x_{0} \\ x_{1} \\ x_{2} \end{pmatrix} $$
gives the expression:
$$ y = -x_{0}^{2} -x_{1}^{2} -x_{2}^{2} + 2x_{0}x_{1} + 2x_{1}x_{2} $$
which I want to minimise (EDIT: Changed from maximise - whoops !). As the nodes are either in the maximum set or not, the variables are binary and so $ x_{0}= x_{0}^{2}$ (NB am I correct in thinking for solving the Maximum weighted independent set problem, say where $ x_{0} $ was twice as important, the weight would manifest as a different constant for the quadractic term?)
Is a function that can take a general matrix into DOCPLEX form qiskit can recognise and operate on?
EDIT 2:
I don't think the stable_set.get_operator()
method works at all.
For the simplest example
path = nx.to_numpy_array(nx.path_graph(3))
qubitOp, offset = stable_set.get_operator(path)
print('Offset:', offset)
print('Ising Hamiltonian:')
print(qubitOp.print_details())
gives:
which is not the correct function - the weights of the different nodes are not equal - and so has no hope of finding the right result.
EDIT 3: After a little bug hunt, the problem is nearly solved ! https://github.com/Qiskit/qiskit-aqua/issues/1553