Definitions and Concepts: Run-Time, Compile-Time, Tunable, Inlined. What are these?

98 views (last 30 days)
Hi,
Maybe is missing some basic concepts for me to understand more about Matlab and Simulink. I did research on those topics but they are very complex to understand. For example: run-time, it is a huge amount of information with no examples or videos.
Someone has a better explanation?
Thank you!
  2 Comments
vcmorini
vcmorini on 17 Jul 2017
Simscape Run-time: By default, Simscape parameters are compile-time, which means you cannot change the value of a compile-time parameter in the model or in the generated code, without recompiling the model. By default, all Simscape parameters are compile-time configurable parameters. If you change the value of a compile-time parameter, recompile before simulating the modified model. If you want to change the value without recompiling between iterative simulations or in generated code, you must specify a Simscape dialog box parameter as run-time. Therefore, Simscape run-time parameters help you work more efficiently than compile-time configurable parameters because they allow you to forgo model recompiling when you change parameter values.
Some of the Simscape blocks allows to change compile-time to run-time. To see if is allowed, fist go into Matlab Preferences > Simscape > Show run-time parameters settings and check it. Than, open the Simulink, and see if the Simscape blocks constains the option Run-Time and Compile-Time. Some might have this option, some might not have. In the 2017a, more blocks support run-time, specially multibody. Two illustrations to explain:
Simulink Tunable: Many block parameters are tunable. A tunable parameter is a parameter whose value can be changed without recompiling the model. For example, the gain parameter of the Gain block is tunable. You can alter the block's gain while a simulation is running. If a parameter is not tunable and the simulation is running, the dialog box control that sets the parameter is disabled. When you change the value of a tunable parameter, the change takes effect at the start of the next time step. Nontunable block parameters are parameters whose values you cannot change during simulation. For example, you cannot tune the Sample time block parameter. If a parameter is nontunable, you cannot change its value during simulation by changing the value in the block dialog box or by changing the value of a workspace variable. If you generated code from a model, parameters are not tunable when Default parameter behavior is set to Inlined in the model's Configuration Parameters dialog box. Including tunable parameters in your model can also increase the simulation time.
Run-time vs Tunable: Simscape run-time parameters are similar to, but different from Simulink tunable parameters. For example, you can forgo recompiling when you change the value of a tunable parameter while a simulation is either running or stopped. You can change the value of a run-time configurable parameter, without having to recompile the model, only if do so while the simulation is stopped.
Code Generation: While Simscape run-time parameters can make iterative simulation more efficient, using them can decrease the efficiency of code that you generate. Code that contains compile-time or inlined run-time parameters is more computationally efficient because it does not have to store or retrieve parameter values. If you set the default parameter behavior for code generation to inlined, the generated code algorithm inlines the numeric values of all block parameters as constants.
To set Inlined or Tunable for code generation, go to Model Configuration Parameters > Optimization > Signal and Parameters dialog box, select the Default parameter behavior. Options are:
  • Inline — The Simulink Coder algorithm hard-codes the numeric values of all the block parameters as constants in the generated C code, rendering them non-modifiable. When you set Default parameter behavior to Inlined (the default when you use an ERT-based system target file such as ert.tlc), the generated code algorithm inlines the numeric values of block parameters. Therefore, you cannot tune the block parameters during code execution. Workspace variables that use the storage class Auto, such as numeric MATLAB variables, also appear in the generated code as inlined constants.
  • Tunable — Simulink Coder generates data structures that you can modify to change parameters without recompiling between simulation runs.
These informations clarified me a lot. Hopefully will help you also. All informations were found in User Guide of Simulink, Simscape and Simuink Coder. Feel free to contact me.
Paul Schmitz
Paul Schmitz on 19 Oct 2023
I have already developed a rather indepth model and would like to change all of the compile time selections to run time.. is this possible to do globally or does it have to be done for each component?

Sign in to comment.

Answers (0)

Categories

Find more on Run-Time Parameters in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!