Fast Restart | Five Practical Tips to Speed Up Your Simulink Simulations
From the series: Five Practical Tips to Speed Up Your Simulink Simulations
If you are running hundreds or thousands of iterative simulations while varying parameters or model inputs, see how Fast Restart can help you reduce the overall simulation time.
Published: 3 May 2020
Welcome back to this video series on speeding up Simulink simulations.
In this video, we will look at a specific speedup technique called Fast Restart that will help you run iterative simulations in less time (or more efficiently).
While changing model inputs or tuning parameters between runs, you normally do not need to edit the model structure. But running the simulation after modifying model inputs or parameters will cause the model to recompile, causing an unnecessary waste of time.
To demonstrate this, let’s use the automatic transmission example we were working with in the earlier video. As we know, in a typical Simulink simulation workflow, as we press the run button, Simulink will first update and compile the model, then simulate it. This process repeats for any subsequent run.
Now, the same will be true if you run multiple simulations from the command line.
For example, while running the simulations in accelerator mode, for each simulation, Simulink took close to 6.5 seconds to initialize. This is unnecessary after the first run, and you can understand how this time will add up when you are running hundreds or even thousands of simulations. And for large models with large datasets and model hierarchy, this initialization time could take minutes or sometimes even hours!
So, to save us time, Simulink provides a nice feature called Fast Restart. As the name suggests, it lets you run iterative simulations by compiling the model only once.
Let’s see how it works.
First, let’s turn on Fast Restart from the simulation ribbon.
Now let’s run the simulation.
You see that the simulation completed, but the model did not terminate. Instead, the model is initialized again in Fast Restart, as shown as initialized here in the status bar. That means Simulink will initialize the model by using the compiled information for the next set of simulations. This eliminates the need to recompile when you run the model again for the next simulation, meaning the simulation will start right away.
You will also notice that when Fast Restart is being used, the model is locked down and you will not be able to edit the model structure. That prevents any structural changes to the model until the simulations have finished. The same follows with any of the model settings and configurations that change the model structure. As we see from the Configuration Parameters dialog, values greyed out cannot be changed. Parameters like stop time and inputs can be modified. As we mentioned earlier, this dialog gives us an option to customize our inputs to the model.
Let’s rerun the simulation. The initialization time is significantly shorter now, as expected, thus saving you time.
So, a quick recap. What does Fast Restart do?
It avoids recompilation between simulation runs.
By doing this, it can help with running iterative simulations faster, where you would need to only modify parameters, and inputs and run simulations quickly.
However, please keep these limitations of Fast Restart in mind while using it:
One: you will not be able to edit the model structure while its enabled;
Two: it does not support the rapid accelerator simulation mode.
So, a natural question you might ask is, what if I would like to run iterative simulations in Rapid Accelerator mode, but I expect similar time savings.
Don’t worry; for the rapid accelerator mode, a similar option exists to help. A check called the RapidAcceleratorUpToDateCheck.
So, if we know for sure the model structure will not change while running these iterative simulations, turning this check to off from the MATLAB command line will, as the name says, turn off the rapid accelerator’s initialization phase for subsequent runs.
Let’s give it a try with the same model after setting this check to off. You can see that the recompile of the model is skipped, thus reducing the overall simulation time.
All right!
To summarize, if your workflow involves running iterative simulations where the model structure doesn't change between runs, then Fast Restart is a good technique to try. And if you want to run simulations in rapid accelerator mode, don’t forget to turn off the RapidAcceleratorUpToDateCheck to get a similar benefit.
Thanks for watching!
Now, if you are interested in learning about running multiple simulations parallelly, please check out the next video.