Interface for Limiting The Total Optimization Time

Hi :slight_smile: ,

Is there a way to limit the total optimization time to avoid <model name>_acados_solve(<capsule>) taking more time than the controller loop period?

If there isn’t such an interface, how should my code handle this potential risk?

And in practice, how should I take extra care of the time needed for optimization in a real-time robotic application?

Thanks for your suggestions.

1 Like

Hi,

No it is not possible for acados to know beforehand how long an SQP iteration will take on a specific hardware and for a specific problem.
However, if one uses RTI, i.e. a single linearization and a single QP solve, the CPU time should be pretty deterministic.
You can additionally limit the number of QP solver iterations.
Those are definitely relevant questions for MPC practice that are not trivial to answer in general.

Best,
Jonathan

Hey,

Does the solver_options.qp_solver_iter_max correspond to a limit set on the value returned by solver.get_stats("qp_iter") ? I would have expected it to, however in the tests I’m running, I see solver.get_stats("qp_iter") > solver_options.qp_solver_iter_max

Yes, it is the maximum number of QP solver iterations for each QP, so the array solver.get_stats("qp_iter") should contain values which are all smaller than solver_options.qp_solver_iter_max.

Hi,

a solver timeout for SQP is implemented in this PR. Note that it uses a heuristic to estimate the time required for the next SQP iteration, which means you might still get some violations of the maximum time.

Best, Katrin