Full horizon and cost function value from S-function

Hi,

I am glad you like the S-function.

Did you actually edit the template?
https://github.com/acados/acados/blob/master/interfaces/acados_template/acados_template/c_templates_tera/acados_solver_sfun.in.c#L1
Or the generated Code?

I think it is a trade-off what is added as input/output to the S-function.
If all possible inputs & outputs were added, I think that the block would get hard to use and probably it would slow down Simulink.

However, please feel encouraged to extent the S-function for your needs.
For example, you can enlarge the port with x_1 to contain the full state trajectory.
For that you would have to change the size of the port here (to size N*nx).:

and add a loop that extracts x for stage 1 up to N here:

Best,
Jonathan

1 Like