parsim with fast restart does not update variables set in through a PreSimFcn
1 次查看(过去 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!