Unable to solve the problem using update

271 views
Skip to first unread message

chenyut...@gmail.com

unread,
Jul 30, 2018, 12:50:03 PM7/30/18
to OSQP
Hi there,

First I want to thank all the developers for this excellent solver.

I am using OSQP in MPC application with a time-varying model. Hence, I need to update all the matrices and vectors at each call.

Matlab example:

m.update('Px',P,'Px_idx',[],'Ax',A,'Ax_idx',[],'q',q,'l',l,'u',u);

The Px_idx and Ax_idx are empty hence all the elements are updated.

The problem is that the problem cannot be solved due to primal infeasibility. However, when I just replace the update function by setup function:

m.setup('Px',P,'Ax',A,'q',q,'l',l,'u',u);

I can get the correct solution.

But I don't want to call m.setup at each call (quite stupid in MPC).

What is the possible reason for this difference and how can I resolve it?

Thanks,

Yutao

Goran Banjac

unread,
Jul 30, 2018, 1:20:21 PM7/30/18
to OSQP
Hi Yutao,

Thanks for using OSQP.

Could you please provide a MWE so that it is easier for us to see where the problem is?

Thanks,
Goran

Yutao

unread,
Jul 30, 2018, 1:56:23 PM7/30/18
to os...@googlegroups.com

Thank you for the quick reply.

I have attached the file and data needed.

Cheers,

Yutao

--
You received this message because you are subscribed to a topic in the Google Groups "OSQP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/osqp/VlmMAI2Ti1w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to osqp+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osqp/fab1b2e5-f647-4d25-a9ac-13b106d98fb3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

MWE_OSQP.zip

Goran Banjac

unread,
Jul 30, 2018, 2:57:38 PM7/30/18
to OSQP
Please see attached a modified script which seems to work.

The reason that your example failed was because you did not use the update function properly.

Since you want to update the whole matrix A, Ax should be a vector taking values of nonzero elements of A ordered column-wise. Since P is symmetric, Px should take values of nonzero elements of the upper triangular part of P.

For more details, see the following documentation page:

One more tip: OSQP internally converts matrices A and P to a sparse format and it would be more efficient if you worked with sparse matrices as well. They take much less memory especially when matrices have many zeros.

Hope it helps.

Best,
Goran
MWE_OSQP_GB.m

Chen Yutao

unread,
Jul 30, 2018, 3:16:30 PM7/30/18
to OSQP
It works!  Thank you so much for the prompt and detailed help.

Reply all
Reply to author
Forward
0 new messages