Convergence issues with multiple constraints depending on number of steps

Hi, I’m using the python interface for NMPC. My problem has two nonlinear inequality constraints, one of which always active (in this setting) and the other becomes active at some point of the simulation.

Using QPOASES, once the system approaches the activation of the second constraint, the solver seems to be stuck in the local minimum and runs out of iterations (whatever maximum number I set). If I let the simulation go, the second constraint is simply not satisfied.

Using HPIPM (for which I have to use the RTI as for some reason with my problem I have never been able to use the full SQP, which is stuck in the first iteration, even with an optimal initialization) the second constraint is satisfied but I get A LOT of spikes everiwhere, I suspect due to the fact that the interior point method does not work well with an always active constraint and RTI.

Now things get interesting, If I decrease the number of steps in the horizon, QPOASES works almost perfectly. Note that it is related only to the number of steps and not to the time lenght of the horizon, as increasing the time step yields the same results.

This seems to indicate that while a solution exists, QPOASES is not able to find one once the number of steps N is larger than some number (e.g. does not work for 40 but works for 20) even if the effective lenght of the horizon is the same. I understand that the larger the number of steps the larger the number of linearization points, so I’m introducing more possibilities to make errors in the nonlinear optimization, but is there something I can do to improve the behaviour of acados? (Condensing does not seem to make any difference)

Thanks for any input,