Mimimize initializing time for SimEvent model
조회 수: 1(최근 30일)
표시 이전 댓글
Niklas Larsson 2021년 9월 2일
댓글: Abdolkarim Mohammadi 2021년 9월 3일
I'm working on a project where I'm supposed to simulate a production facility using SimEvent.
The model it self works as intended but as it has grown the initializing time is extremely long in comparison to runtime. At the moment it takes takes about 100-120 seconds to initialize, compiling another 20 seconds and the runtime about 0.2 seconds. So the set simulation time does not affect, e.g. I can simulate one year or 20 years for about the same time.
In the model I make use of multiple "simulink function" (about 35 of them) all of them contains MATLAB Functions, which are called in order to open Entity gates and to keep a certain amount of entities in storage (just like in this example: https://se.mathworks.com/help/simevents/ug/use-an-attribute-queue-to-model-a-storage-tank.html ) or to define the assemle order.
For the assembly I use Composite Entity Creators along with resource Aquires/Releasers and Entity Servers. Each entity is a part of the final product which adds up to a total of 35, that are composed together along the manufacturing. That is the model in a nut shell.
I've tried to use the performance advisor and disabled Zero Crossing, changed to discrete variable step solver and only to compile when dependencies are found/known but it only helped a little. However, when change parameters by just running a few lines like mark and press F9, the initialize time takes just about 20 seconds but if I run the script it will take about 100-120 seconds (the script only contains assignment to variables).
This would be fine if I only wanted to try a few parameter change but my task involves a Sensitivity analysis which takes forever since each iteration takes 100-120 seconds (Parallelization does help thought), here I want to use the Sensitivity Analyzer App (sim. Design Optimization toolbox) since I would like to do a few hundred simulations.
Either way, is there any way for me to speed up the initializing, I'm asking here because I really dont know what Simulink/Matlab is doing while initializing and therefore is it hard to improve.
댓글 수: 0
Abdolkarim Mohammadi 2021년 9월 2일
편집: Abdolkarim Mohammadi 2021년 9월 2일
If you are doing a sensitivity analysis and you execute hundreds of simulations, the correct workflow is to use SimulationInput objects.
There you set parameter values for each of your experiments in one SimulationInput object, run all of the simulations with one line of code, and get the results in one SimulatinOutput object.
In addition to this point that this is how multiple Simulink simulations are intended to run, there is a feature that is there for your problem: Fast restart. Turning fast restart on causes Simulink to compile the model once, and use the compiled model for the whole experiments in the SimulationInput object. Since model compilation takes a lot of time, often more than model execution, especially in large complex models, fast restart helps A LOT.
댓글 수: 4
Abdolkarim Mohammadi 2021년 9월 3일
I'm glad your problem is solved. I also learned that using Simulink blocks for calculating statistics makes the model run faster.
Find more on Discrete-Event Simulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!