Run time discussion #565
Replies: 10 comments
-
What is the sparsity of your additional constraints? Are What are:
For the second one, I don't recall if we report that value directly anywhere. You could get it by enabling verbose output and counting the number of the times that the What happens if you keep the constraints but relax their bounds such that they are never active? Note that you might get bad solver behaviour if you make the bounds really huge, so maybe try solving once with no constraints and then setting bounds on the RHS of the constraints that are slightly looser than the unconstrained optimal solution. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I tried to reproduce the issue but haven't been able to do so. If I implement what (I think..) you have above, then I always get a solution in about 100 iterations. Some further suggestions:
|
Beta Was this translation helpful? Give feedback.
-
Amazing. Thanks a lot for taking the time to reproduce the issue. Regarding your suggestions:
|
Beta Was this translation helpful? Give feedback.
-
Sorry for taking such a long, I had a deadline for my other project I am working on. Here are two implementations https://github.com/lupusorina/traj_optimization:
Thank you. |
Beta Was this translation helpful? Give feedback.
-
Thank you. I will have a look at see if I can work out what is going wrong with OSQP. In the interim, you might also consider a different solver. Changing from That solver is written in Rust, but we intend to release C and C++/Eigen interfaces to it in a few days.
|
Beta Was this translation helpful? Give feedback.
-
I have tried various things using the scripts you posted but without a lot of success. The issue is perhaps (?) related to the large number of banded equality conditions and the fact that P is low rank, and even the full rank part of P is badly conditioned. I suspect that the difficulty is not really specific to this solver, but rather a general issue with an ADMM based method since SCS also takes a huge number of iterations. You could perhaps try eliminating all of the equality conditions and just optimize over the acceleration terms. Note that since That would make the problem a lot smaller but with much denser KKT matrix. I don't have a good sense of whether the problem in that form would require fewer iterations. It would very likely take longer to factor the KKT system, but maybe that doesn't matter to you if you intend to use this in an embedded system where the KKT matrix can be prefactored one time up front, or if you are using the OSQP embedded codegen from python. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much! I will try your suggestion with using |
Beta Was this translation helpful? Give feedback.
-
Yes, the algorithm in OSQP is ADMM. The other package suggested above is interior point. |
Beta Was this translation helpful? Give feedback.
-
FYI: Clarabel C++ wrappers are now available and support calling it using Eigen. See here: https://github.com/oxfordcontrol/Clarabel.cpp |
Beta Was this translation helpful? Give feedback.
-
Hi,
First of all, thanks a lot for writing such a useful and easy to use library.
I'm trying to solve a relatively straightforward problem (see below), in which p, v, a are the position, velocity and accelerations of a foot for a robot in 3D.
I have observed that the optimization problem solves fast (in the order of microseconds) when no safe constraints are added for both velocity and acceleration. However, when adding the constraints, the time increases considerably. My requirement is to solve this problem in under 5 ms, so I was wondering if you have any advice on how to speed up the computation when using both acc and vel constraints.
Some benchmarking below:
nb variables | nb constraints | run time
270 | 279 | 5e-2 -> only acceleration constraints
270 | 189 | 7e-4 -> no safe set acceleration and velocity constraints
I believe the linear equation from Algorithm 1 (line 3) from the OSQP paper takes long to solve due to a high number of constraints (large A). I saw your library also offers options for multithreading using the MKL Library, however, I haven't really explored that route yet. My code implementation is using the OSQP-Eigen library.
Thank you very much.
Beta Was this translation helpful? Give feedback.
All reactions