Replies: 3 comments 4 replies
-
The matrices you are using are actually very tiny - it looks like they are only on the order of 20~30 in each dimension, so I wouldn't expect the SVD to really have a significant runtime with them. I think you might start to see the difference between OSQP and the SVD that you are expecting if you increase your matrix size. Also, I would expect the SVD to usually be more accurate than OSQP when solving this problem - this is the nature of OSQP as a first-order solver. |
Beta Was this translation helpful? Give feedback.
-
If you have equality constraints only then OSQP is not needed. You can just solve the KKT problems for your equality constrained problem directly. This is actually what OSQP should end up doing anyway assuming you have the "polishing" option enabled, but it's going to waste a lot of time before getting there. See, for example, §10.1.1 here. I think that is what you are describing -- apologies if I have misunderstood. @imciner2 do you think it would be worth pre-checking whether a problem is entirely equality constrained before solving? In that case one could presumably just proceed directly to something very similar to the polishing step, bypassing the solver entirely. This could also be done in a slightly fancier way by checking that all bound are either 1) equalities, or 2) +/- inf bounds on both sides. More complicated suggestion : in CVXOPT / ECOS / Clarabel, the initial iterate is chosen in a similar way, which means that problems that turn out to be purely equality constrained terminate in one step. A very similar initialization procedure is probably possible in OSQP, which might give better starting points and, hence, lower solve times overall. I think most of the code for doing that already lives in the solver. |
Beta Was this translation helpful? Give feedback.
-
Another possible issue for you here is that your randomly generated Suggestion : compare your SVD run time to the time it takes to solve as an equality constrained QP (i.e. one shot KKT system solve as in the link above), but forcing the matrix to be sparse format. That might account for a lot of the difference. Note also that, even in the best case, OSQP with polishing enabled will factor something twice. The first is the initial KKT factorisation, and the second will be from the polishing step. For an equality constrained QP this will turn out to be the same system, but I don't think the solver explicitly checks for that case. |
Beta Was this translation helpful? Give feedback.
-
Hi All,
I'm having a bit of trouble, getting a good, reliable result from osqp, that is comparable to SVD.
Im using the python bindings to solve certain test cases with only equality constraints with OSQP and on the other hand with SVD from scipy linalg.
I create test cases with this function
then i use this function to solve this random problem with SVD
Ill create a list of all permutations of a config file
In the end, i test all those parameters and solve an extended problem with it
The extended problem is to test the influence of sparsity a
I calculate the error of either SVD or OSQP solutions and the time to solve.
As you can see below, i can (almost only) reach parity with the SVD approach in terms of accuracy, but in terms of solve time, im definitly a magnitude off.
Advantage of SVD vs OSQP
(value is osqp time to solve - svd time to solve) there are values where osqp has an advantage, but only very minimal
(x and y axis are accuracy of the solution)
On the other hand solve time is a magnitude higher when using tighter tolerances, but ...
Accuracy is at most at the same level as the SVD solution.
I tinkered with it a bit, to see what the issue is, but honestly not what i expected.
My expectation would have been that OSQP has some advantages over SVD. In the sense of: high accuracy requirement --> slower solve time and low accuracy requirement --> faster solve time.
But from the comparison right now i would assume, that for this kind of problem, where only equality constraints are concerned, SVD is faster and more accurate than OSQP?
Or maybe i have some misconception and something is wrong in the setup?
Thanks in advance for your insight. If it would help, i can also provide the jupyter notebook for my setup.
Beta Was this translation helpful? Give feedback.
All reactions