Different behavior in acados_ocp and code generation

Hi :wave:

I am trying to use the Matlab interface of acados to implement a simple mpc controller in a closed-loop simulation. I noticed that if I create the solver as ocp = acados_ocp(ocp_model, ocp_opts); it fails several times during a simulation with status 4 (SQP_RTI: QP solver returned error status 3 QP iteration 44. in the terminal).

On the other hand if I generate the code with ocp.generate_c_code; and create the solver by typing ocp = my_model_mex_solver; It never fails in the same simulation setup.

Why do they behave differently? Shouldn’t they be equivalent?
Maybe the code generation introduces some default solver setup that I am missing in the other case?

I experience the same problem in both MacOs and Ubuntu.
Thanks for any suggestion.

1 Like

Hi Francesco,

these solvers use different interfaces.
I tried to describe this here:
https://docs.acados.org/matlab_octave_interface/index.html#interface-structure

In general equivalence of the two interfaces is not guarenteed.
However, it is ensured for a few for a few test examples.
See here for example.

Maybe you can make a similar minimal example to show the different behavior, both solvers should be initialized in the same way.

Not sure when I will have time to look into it though…

Cheers!

I loaded the simple test code in this repo. As I said what is weird is that the native MEX interface fails several time whereas the code generation never fail, despite the simulation setup is exactly the same. Thus I was wondering if the two interfaces introduce different settings (possibly not voluntarily) and, if this is the case, which are these settings.

Thanks again.

1 Like

Hi Francesco,

I finally found some time to look into your problem.
I found that some settings were not the same in the template based interface:

But the main issue with that problem seems to be that the conditioning of the problem gets too bad for the HPIPM solver used, when condensing the horizon from 100 to 5.
Switching either

  • qp_solver_cond_N to >= 20
    or
  • qp_solver to full_condensing_qpoases
    makes both solvers equivalent.

I made a PR to your repository to compare the results a bit more systematically

I think as soon as the solver fails once / doesn’t fail comparing closed loop simulations does not make much sense anymore, since the errors just accumulate.

Best,
Jonathan

1 Like

Hi Jonathan,
Thank you for your support. This is what I was looking for, now I get the same behavior: indeed if the solver fails using the native interface then it fails also using the template based interface and viceversa.

Thanks also for your suggestion about the choice of the condensing factor.

Regards,
Francesco