When the referenced model is used in “Accelerator” mode, it is compiled once and then reused for all subsequent simulations. As long as the “Control” block is not modified, there is no need to recompile it.
How is a subsystem converted into a referenced model?
The conversion of the subsystem into a referenced model requires several steps to prepare the model so that it respects certain rules. In particular we have:
- defined the input and output buses of the referenced model,
- resolved signals passing directly through the “Control” block using “Signal Conversion” blocks,
- managed the behaviour of the “trigger ports” present in the referenced model,
- solved the algebraic loops of the platform, following the transition of the “Control” block to the atomic model.
The rules to follow for the conversion are defined in the following page: Convert Subsystems to Referenced Models – MATLAB & Simulink (mathworks.com)
Once the referenced model was ready, we wrote a script that made it possible to compile the model with mingw64, and then compress the files into a “.zip” archive. This enables the compiled referenced model files to be stored and shared with other users.
Finally, we launched validation simulations in order to guarantee the strict equality of the simulation results before and after the conversion and to evaluate the simulation time saving obtained.
What are the benefits obtained?
The results we obtained with the “Reference Model” are:
- the simulation time is divided by 3: a simulation sometimes lasts several hours, this time saving is therefore very significant,
- the time lost in compiling the “Control” block is largely compensated by the time saved during the simulations,
- the platform is lighter to handle and opens more quickly: the referenced model is only loaded when necessary,
- this technique allows a modular approach: it is easy to change control algorithm versions by simply modifying the reference of the “Model Reference” block,
- the possibility of protecting the control algorithm with Simulink Coder is relevant: it avoids revealing its intellectual property.
We use the referenced model technique on other applications and in particular for the validation of control algorithms for ADAS systems.
For more information on the technical details and subtleties of referenced models, you can contact us and consult the Mathworks page dedicated to this subject, Model References – MATLAB & Simulink (mathworks.com)