Performance Advisor | Five Practical Tips to Speed Up Your Simulink Simulations - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 5:21
Loaded: 0%
Stream Type LIVE
Remaining Time 5:21
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 5:21

    Performance Advisor | Five Practical Tips to Speed Up Your Simulink Simulations

    From the series: Five Practical Tips to Speed Up Your Simulink Simulations

    Here, we will take a look at the capabilties of the performance advisor tool and how it lets you make systematic changes to the model configurations, solvers, and block types to improve simulation performance.

    Published: 3 May 2020

    Welcome back! In the last video, we looked at accelerating simulations by toggling through simulation modes.

    Today, we will discuss another very useful tool called the Performance Advisor that you can utilize to better understand your model and improve your simulation performance.

    Let’s start with a Simulink model, which shows modeling of an automatic transmission system. Running the Simulink Performance Advisor from the debug tab lets you make systematic changes to the model to improve simulation performance.

    The advisor first creates a baseline test run for the model to compare the performance improvement against it.

    For this baseline test, let’s set the run time to 500 seconds.

    Now, let’s run all these selected checks. The Performance Advisor runs through these different checks and comes up with recommendations of how we may want to change our model configuration settings, solvers selections, and model block types to improve performance from the baseline run, which right now took about 19 seconds.

    The checks in green mean that they are complete and confirm that the model has been optimally configured.

    On the other hand, if a yellow exclamation is shown next to a check then it means that the check has been completed, and the Performance Advisor has identified a possibility for improvement in performance.

    For example, let’s look at the check to identify resource-intensive diagnostic settings. We see that there are resource-intensive diagnostic settings enabled for this model that can cause it to slow down. While you are building a model, having diagnostics like these enabled can be helpful to better understand the model behavior. However, they come at a computational cost. So, when you are wanting to run the model as efficiently as possible, it can be beneficial to turn them off.

    Here the model has the solver inconsistency diagnosis turned on to show warnings, but the Performance Advisor suggests turning the diagnosis off.

    Note that in the Performance Advisor setting, by default it chose to automatically implement the change, so we see that the diagnostics have been turned off.

    One interesting thing is that if we want to know more about this diagnostic setting, we can just click on the item and it will bring you to the setting.

    Also, the Performance Advisor shows a summary of the actions that it has taken.

    But although the Performance Advisor may make some changes for us, it will not save the changes to the model. If needed, we can go over this summary and see which of the changes seem reasonable and then save the model.

    On the other hand, there are some checks that the Performance Advisor by default acts based on advice manually. For example, this check identifies interpreted ML function blocks in the model that can affect simulation speed. If we click on this item, it will bring us to where these blocks are used. Interpreted ML function blocks can be slow, as it calls the MATLAB parser during each integration step.

    So, the advisor gives us an option to switch this out with a MATLAB function block.

    We can do just that by using the modify all and validate button to automatically replace the ML interpreted functions with ML function blocks.

    Additionally, it evens shows how much performance we will get by this one single change. Clicking on the blocks in the results window, we can see that the model has been updated.

    Now let’s look at some of the checks that require the simulation to run.

    Looks like the advisor is recommending us to look at the solver selection.

    The default solver for this model is ODE3, but the Performance Advisor recommended and tried a new solver ODE14x based on its analysis.

    Let’s validate this recommendation. Looking at the results, the Performance Advisor notices that while switching solvers, there is a performance speedup, but the new recommended solver would violate the given tolerance at some points during the simulation. So, the Performance Advisor didn’t apply this change to the model and leaves it for us to decide. Let’s just leave the original solver setting in place, since we don’t want to violate this tolerance in the design.

    Now that we have made recommended changes to the model and its configuration, let’s look at how we have fared in improving performance by doing a final validation. With all the changes we have made, we see that the model runs in less than a second. That is an improvement of almost 96% from the baseline model which we started off with.

    Now if we are happy with the results, we can save the model with these changes.

    What you should take away is not that all models will see this level of improvement, but that the Performance Advisor can systematically apply the right advice for your model to improve its simulation performance. So, in summary, we saw how the Performance Advisor can recommend optimal settings of the model configuration, solvers, and model block types to influence a better simulation performance.

    Be sure to check out the next video where we talk about Fast Restart as a method of speeding up simulations. Thanks for watching!

    Related Products

    Learn More