parsim with fast restart does not update variables set in through a PreSimFcn
2 ビュー (過去 30 日間)
古いコメントを表示
I have noticed that base workspace variables supposed to be set through a PreSimFcn are not updated for a simulation when running multiple simulations using parsim() with fast restart to accelerate execution.
In my setup, the base workspace variables for each simulation are set by different MATLAB 'run scripts' specified through a cell input ('file') to the SimulationInput object's PreSimFcn as
for casenumber = 1:NumFile
simIn(casenumber)=Simulink.SimulationInput(model);
tmpSimIn = simIn(casenumber); % Use a temporary variable for the SimIn element to avoid runaway memory usage when using a preSimFcn with parsim
preSimFcnInputs = {file{casenumber}, tmpSimIn};
simIn(casenumber)=simIn(casenumber).setPreSimFcn(@(x) parsimPreSimFcn(preSimFcnInputs));
end
The PreSimFcn evaluates the 'run script' as
function parsimPreSimFcn(PreSimFcnInputs)
simIn = PreSimFcnInputs{2};
runScript = PreSimFcnInputs{1};
% Run the run script
eval(runScript)
end
I then run the simulations in parallel using
simOut=parsim(simIn, 'TransferBaseWorkspaceVariables','on','UseFastRestart','on');
When running on 6 workers, I noticed that the 10th simulation had the same parameters as defined by the 'run script' of the 4th simulation. I suspect fast restart is causing this, as the 10th simulation would start on the same worker as the 4th simulation when using 6 workers. I am running MATLAB R2020b
8 件のコメント
Paul
2023 年 12 月 14 日
I have not run across this issue before but have often wondered if there is a limitation on logging variables in large scale simulations.
Suggest a thorough read starging from Save Runtime Data from Simulations; in particular, check the section on "Big Data" which seems to be specfically on point for this problem.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Run Multiple Simulations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!