Sensitivity feedback with Gaussian Newton and 'NONLINEAR_LS'

Hi :wave:
I’m implementing a whole body distributed mpc with acados for legged system see the
paper if you are interested.
I want to use the sensitivity to the initial condition as a feedback gain to be used in a faster loop. Still, I saw that the function to get the sensitivity requires linear cost or exact hessian. There is any way to get around these limitations? The evaluation of the exact hessian is too slow for my application.

Thanks!

Hi lamatucci :wave:

great that you are using acados for your research!

Unfortunately, there is no way around using an exact Hessian for computing solution sensitivity. This is not a limitation of acados, but rather due to the underlying math. The solution sensitivities are given by the implicit function theorem which assumes an exact Hessian of the Lagrangian. If you use some Hessian approximation, you might end up with horribly wrong derivatives. Worst case they might even have the wrong sign.

The only thing I can recommend in order to speed up computations is to use two solvers: One solver with an inexact Hessian for solving the NLP and one exact Hessian solver for computing solution sensitivities. After solving the NLP with the first solver, you can initialize the second solver at the solution, perform one more QP solve and afterwards compute solution sensitivities.

This is also the approach implemented in this example.

Hope this is helpful!
Best, Katrin