Sparse parameter updates from Matlab/Simulink

Hi :wave:

We have a very large number of parameters in some of our applications. Most of them do not change during runtime and need only to be loaded into the solver once at the initialization or first call. This is related to this discussion: https://discourse.acados.org/t/solver-getting-slow-with-a-large-number-of-parameters/290/2
I can see in the generated acados_solver_…c file that there is a function called …_acados_update_params_sparse( … ). As I understand it this function only updates a subset of the parameters. Would it be possible to change the Matlab and Simulink interfaces to use this function? For Simulink we would need to specify e.g. an index matrix with ones for the parameters that we want to update, I guess.

Also, when some functions, derivatives, etc. depend on the parameters; is it possible to avoid that these will be re-calculated at every solve if the parameters have not been updated?

What do you think about this?
Thanks for your great work!

Hi Tobias,

the sparse parameter update is available via the c interface only, you are of course very welcome to contribute with an extension to the MATLAB and/or python interface :rocket:

All problem functions are re-evaluated in every SQP iteration independent of whether parameters are updated or not. These function can in general be nonlinear and thus need to be linearized again in every iteration.

Best, Katrin

Small correction: Sparse parameter update is implemented in Python and the templates, just not in Matlab/Simulink.

1 Like

Also updated in Matlab and Simulink, see Simulink sparse parameter update and testing by FreyJo · Pull Request #1177 · acados/acados · GitHub