Speeding up Simulink simulations with event charts and random events

1 回表示 (過去 30 日間)
Altug Emiroglu
Altug Emiroglu 2022 年 3 月 22 日
コメント済み: Altug Emiroglu 2022 年 4 月 1 日
I have a simulink model which consists of about more than 300 blocks that contain basically 5 different custom library blocks. Each block contains 1-2 Discrete Event Charts. The blocks communicate with each other in a hierarchical manner using messages. The communication between the blocks are not one directional meaning the blocks at any level on the hierarchy can be communicating with other blocks in the upper and lower levels. Immediate connections to lower levels are established with duplicated messages and to higher levels are established by making use of the entity multicast blocks.
Events in the discrete event charts take place at some randomly generated times from a matlab function that is defined in the base workspace.
I need to get this simulation as fast as possible such that I can run +10K Monte-Carlo iterations in a reasonable time. I recently read that model referencing is more favourable to get the simulation speed up. Are there any other significant changes that I can make to increase the simulation speed? For instance the profiler in "Normal" mode tells me that a huge amount of time is spent in the initialization phase. It is also the case when I start the simulation with "Step Forward". After that when I click it again, the complete simulation runs in the fraction of a second.
Trying to run the simulation in an automated way via a Matlab Script for Monte Carlo simulations also take a huge amount of time regardless of choosing "FastRestart" option or not due to the initialization.
I would appreaciate any comments and suggestions for improvement.

回答 (1 件)

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2022 年 3 月 29 日
編集済み: Abdolkarim Mohammadi 2022 年 3 月 29 日
You should try parsim() with fast restart enabled. Read my answer here for further details about this methodology.
  1 件のコメント
Altug Emiroglu
Altug Emiroglu 2022 年 4 月 1 日
Hi, and thank you for your answer. My problem is that, when I do profiling, my whole simulation without compile time is around 100 seconds out of which the compilation 95, initialization 3 and simulation/termination time is 2 seconds. When I run the simulation programatically as you mention with FastRestart turned on, it takes about 200 seconds which is nowhere near what the profiling tells me. I am essentially using only one fixed time step for the whole simulation, since I have only discrete events in my system and the events are automatically handled at precise times even if the model does not sample at those specific times.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDiscrete-Event Simulation についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by