필터 지우기
필터 지우기

Why SimEvents spends so much time

조회 수: 1 (최근 30일)
Gul Culhan
Gul Culhan 2020년 9월 28일
답변: Krishna Akella 2020년 12월 1일
I am trying to simulate a discrete event system using the simevents blocks. I created a dummy model which only includes an entity generator and an entitiy terminator blocks with stop time 365. I generate entities with matlab action;
persistent rngInit;
if isempty(rngInit)
rng(iterSeed);
%iterSeed is in model properties with iterSeed = randi(500);
rngInit = true;
end
% Interarrival times: Exponential distribution
lambda = 1;
dt=-lambda*log(1-rand());
I ran 1000 replications with following code;
warning('off','all');
numSimulations = 1000;
mdl = 'DummyModel';
for i = 1:numSimulations
out(i) = sim(mdl);
end
display('END');
Even this simple piece of code took 655 seconds. I also tried the accelerator mode but it worsened the total time to 1208 seconds. Why even a dummy SimEvents model spends so much time?

답변 (2개)

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 9월 28일
편집: Abdolkarim Mohammadi 2020년 9월 28일
You should run 1000 simulations using sim() in conjunction with SimulationInput objects. With SimulationInput you can define the variables for each experiment. You can also use the fast restart option for faster execution of models. Please test the following code.
numSimulations = 10;
Model = 'DummyModel';
SimIn = repmat (Simulink.SimulationInput(Model), [numSimulations,1]);
SimOut = sim (SimIn, 'UseFastRestart', 'on');
If you have Parallel Computing toolbox license, you can also try parsim().
SimOut = parsim (SimIn);
Please read the documentation:

Krishna Akella
Krishna Akella 2020년 12월 1일
Hi Gul,
I agree with Abdolkarim's suggestion. Did you try to put the model in 'fast restart' mode? That will ellimiate model compile after the first run.
Thanks & regards,
Krishna

카테고리

Help CenterFile Exchange에서 Discrete-Event Simulation에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by