Does Simulink Coder support code generation of custom solver functions for Nonlinear MPC blocks?
1 view (last 30 days)
Show older comments
Arnold Sterle
on 16 Jan 2023
Commented: Arnold Sterle
on 30 Jan 2023
I have designed a nonlinear model predictive controller using
MpcObj = nlmpc(nx,ny,nu);
Since I want to use my own solver I have set the according property, i.e.,
MpcObj.Optimization.CustomSolverFcn = "CustomSolverInterface"
Using MpcObj, I prepared a Simulink model calling this object via the Nonlinear MPC block. When running in Simulink, the outputs are as expected.
So I built C-code using the Simulink Coder add-on. Doing so yields an executable which generats a logging file where I can inspect the outputs. However, they now have the same trajectory as if I had used fmincon instead of my custom solver.
So I am wondering whether Simulink Coder supports code generation with custom solvers. If yes, what are the limitations for that?
Best,
Arnold
0 Comments
Accepted Answer
Emmanouil Tzorakoleftherakis
on 27 Jan 2023
Hi Arnold,
Unfortunately, right now you can only generate code using 'fmincon'. Custom nlp solvers can currently only be used for simulation. I have let the development team know about this and we will take a look at a future release.
Thanks for bringing this workflow to our attention
More Answers (0)
See Also
Categories
Find more on Code Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!