Borrar filtros
Borrar filtros

parsim with fast restart does not update variables set in through a PreSimFcn

2 visualizaciones (últimos 30 días)
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 comentarios
Afzal
Afzal el 14 de Dic. de 2023
Hi Paul,
I managed to figure out what was causing the issue. It's logging too many parameters to workspace. It seems like it was running out of memory, which was causing Simulink to crash. I was logging 1735 additional parameters compared to a previous run when everything ran fine. By the time it got to the 10th case, it would have had 258,900,170 additional rows of data in the SimulationOutput object, based on the length of each simulation.
I re-ran the same cases without these additional parameters being logged, and it all ran fine.
Have you come across this issue before? Any ideas on what could be done about this, other than just logging fewer parameters to the workspace?
Thanks,
Afzal
Paul
Paul el 14 de Dic. de 2023
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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Run Multiple Simulations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by