Resetting SQP solver after failure

Dear friendly local staff,

I am using the C interface of acados with SQP. I want to solve problems for which I know that convergence is not always guaranteed, and I handle such cases by modifying the problem and attempting to solve it again.

This works in most cases. However, there are some states in which the solver appears to get “trapped,” and every subsequent recomputation—no matter how simple the modified problem is—fails already in the first SQP iteration.

To address this, I also call acados_reset() from the generated API. However, I noticed that some solver state seems to persist across subsequent solver calls. In particular, I observe a reduced alpha value already in the very first SQP iteration after the reset.

Initially, I thought this behavior only occurred when using MERIT_BACKTRACKING, but I have since observed the same issue with FIXED_STEP. My current workaround is to destroy the solver capsule and create a completely new one whenever this happens.

Am I using the API incorrectly, or is there a better way to recover from this situation?

Thank you a lot! :heart:

Hi :waving_hand:

could you share a minimal working example to reproduce this issue? The reset should indeed be the way to go, solver recreation should not be necessary.

Best, Katrin

Hi Katrin,
thank you for the quick reply. I implemented some kind of minimal example that did not reproduce the problem, but actually shifted my suspicion towards my model and OCP. Since I am parsing a robot URDF model (pinocchio-CasADi pipeline), I was able to replace that with some similar, hand crafted dynamics for my yet simple case.

The interesting thing is that the similar dynamics behaves as expected with and without acados_reset(). Whereas the parsed model even fails repeatedly with recreated capsule for specific states - something I did not observe before my initial post. This “stucked” failure only happens occasionally and (hopefully) shows that my problem is not infeasible in general.

Do you have any suggestion where to dig deeper now?

Thank you very much!

Best, Chris

Hi,

I also encountered a similar problem, however less investigated as compared to yours. Im using the python interface and also converting from pin to casadi. In the first infeasible solve due to hard constraints, the QP throws the minstep error. After moving the obstacle away, which I assume should make it feasible now, I still get an infeasible solve. I also tried using the reset function to no avail. Something I noticed though is that after the first minstep error, the QP doesnt throw any more errors and I get the status 4 error.

Hi,
I encountered in repeated solve fails that it actually always returns with QP solver status 3 ACADOS_MINSTEP and acados_solve() returns status 4. The QP iteration fail can vary, whereas it occurs always in the very first SQP iteration.

In case that it matters, I am using acados v0.5.5 and CasADi v3.7.2.