Initializing with sparsity only?

48 views
Skip to first unread message

joris.g...@gmail.com

unread,
Mar 12, 2019, 8:21:33 PM3/12/19
to OSQP
Dear OSQP developers,

I'm busy adding an interface to OSQP to CasADi, but got stuck.

Using some numerical experiments, I was under the impression that one could set up an osqp instance with sparse matrices and dummy data, and later update that data to meaningful values.

However, I stumbled on a case were this approach does not give identical results compared to just setting up osqp with the proper values right away.
(e.g. https://gist.github.com/jgillis/65e0db7c10a33b275ab7cd7b530ea205)

Did I hit a bug, or was I just lucky with the experiments were it did work out alright?
Fwiw, I also have a case were this 'delayed' approach leads to an unexpected "nonconvex" message..

Many thanks in advance,
Joris Gillis


Paul Goulart

unread,
Mar 13, 2019, 8:48:19 AM3/13/19
to OSQP
The problem you are having in your example is that the 'update' method only wants you to specify values in the upper triangle of P.    This means that when you do the update, you should do something like this:

>> prob.update(l=l,u=u,q=q,Px=np.array([1,-1,2,0,0,0]),Ax=np.array(Ax))

The above fixes the problem for me in the example you provide.   I assume it will also fix the non-convexity warning you received, because the likely cause of that error is that you are providing values for the symmetric version of P and some or all values are getting mapped into the upper-triangle of P.

We can add some error checking to help prevent this case - I will raise an issue on github.

Thanks for your interest in our solver.

joris.g...@gmail.com

unread,
Mar 13, 2019, 11:14:56 AM3/13/19
to OSQP
Dear Paul,

Thanks a lot. Confusion about the triangular nature of the argument did indeed cause my problems.

For any other interested readers, scipy.sparse.triu(P).data would work as argument..

Best regards,
Joris
Reply all
Reply to author
Forward
0 new messages