Improved control over dynamics implemented across stages?

Hi :wave:

We often face situations where would like a bit more control over the dynamics implemented across the stages in Acados:

  • For instance, when using non-uniform shooting nodes we might want so long sample times towards the end of the horizon that most of the dynamics in the original model are too fast to make sense at these stages. In that case we would like to drop such parts of the model (remove states) for the last part of the prediction horizon.

  • I have seen in https://discourse.acados.org/t/control-horizon/377/5 that you recommend increasing the value of sim_method_num_steps if you have longer shooting intervals. However, I cannot set this per stage from the Matlab interface + increasing this also increases the computation time drastically for our problem. So it would be better to simply reduce the model as mentioned above so the high accuracy in the integrator is not needed for the long shooting intervals. Do you think we can have the option to set sim_method_num_steps per stage from Matlab? Also, do you have any rule-of-thumb for how low you can set this number?

  • We also have cases where we would like to penalize the rate-of-change of some function f(x,u) where f can be a table lookup implemented with bspline interpolations. With continuous time models this is not trivial to implement whereas in discrete time I would just penalize (f_k+1 - f_k)/Ts (k being the stage index) for all stages along the horizon. Would it be possible to combine continuous and discrete dynamics in Acados? This would be great as we could leverage on some things being simpler to specify in discrete than in continuous and vice versa.
    Is there another way to implement this that you would recommend?

  • Related to this topic: https://discourse.acados.org/t/how-do-i-set-different-dt-dynamics-per-stage/1005
    Is there a way to limit the online computations of A and B matrices with non-uniform shooting nodes? E.g. does it help if the shooting intervals are the same length for some blocks of the horizon as opposed to every stage having unique shooting intervals?

  • Would it be possible to output the discrete-time systems used in the underlying QPs from Acados (after discretizing the dynamics)?

We are looking very much forward to hear your thoughts on this!
Thanks a lot for all your great work!

Hi Tobias,

For instance, when using non-uniform shooting nodes we might want so long sample times towards the end of the horizon that most of the dynamics in the original model are too fast to make sense at these stages. In that case we would like to drop such parts of the model (remove states) for the last part of the prediction horizon.

You might want to check out the multiphase OCP formulation which has been recently added to acados. It allows you to change the dynamics including the state dimension for each shooting node. Currently it is only available via the python interface.

I have seen in Control horizon - #5 by Antonio that you recommend increasing the value of sim_method_num_steps if you have longer shooting intervals. However, I cannot set this per stage from the Matlab interface + increasing this also increases the computation time drastically for our problem. So it would be better to simply reduce the model as mentioned above so the high accuracy in the integrator is not needed for the long shooting intervals. Do you think we can have the option to set sim_method_num_steps per stage from Matlab? Also, do you have any rule-of-thumb for how low you can set this number?

You can indeed set the number of steps and stages for each shooting node individually, simply provide an array of length N. See the example here. In general the number of required integration steps strongly depends on your model and how low you can set this number is in the end a tuning parameter.

We also have cases where we would like to penalize the rate-of-change of some function f(x,u) where f can be a table lookup implemented with bspline interpolations. With continuous time models this is not trivial to implement whereas in discrete time I would just penalize (f_k+1 - f_k)/Ts (k being the stage index) for all stages along the horizon. Would it be possible to combine continuous and discrete dynamics in Acados? This would be great as we could leverage on some things being simpler to specify in discrete than in continuous and vice versa.
Is there another way to implement this that you would recommend?

At the moment it is not possible to combine continuous and discrete dynamics.

Related to this topic: How do I set different DT dynamics per stage?
Is there a way to limit the online computations of A and B matrices with non-uniform shooting nodes? E.g. does it help if the shooting intervals are the same length for some blocks of the horizon as opposed to every stage having unique shooting intervals?

The computation time does not depend on whether the shooting interval differs from stage to stage or is constant.

Would it be possible to output the discrete-time systems used in the underlying QPs from Acados (after discretizing the dynamics)?

If you increase the print_level the QP matrices will be printed.

Hope this helps with your implementation!

Best, Katrin

Thanks a lot for your replies to my questions!
I would like to follow up on the last point; in addition to the QP matrices, what would it take to get also the A and B matrices of the discretized systems before they are “folded” into the QP matrices? I believe, that it is not simple to retrieve the system matrices from the QP matrices.

Best,
Tobias