How can I use parsim in combination with a Simulink Variant Subsystem

조회 수: 12 (최근 30일)
Hello,
I included a Variant Subsystem into the following Simulink-model (which is just an example) and run it with "parsim" via a script. Thereby I get this error message, that I don't understand:
-------------
Error due to multiple causes.Caused by:
Variant control 'Variant_1' of variant block 'sldemo_suspn_3dof_variant/Variant Subsystem' must be a condition expression or name of a Simulink.Variant object in the global scope workspace of the model. Ensure that the condition does not match the model name.
Variant control 'Variant_2' of variant block 'sldemo_suspn_3dof_variant/Variant Subsystem' must be a condition expression or name of a Simulink.Variant object in the global scope workspace of the model. Ensure that the condition does not match the model name.
-------------
The Simulink.Variants Variant_1 and Variant_2 and the parameter Variant_Switch are all part of the workspace.
mdl = 'sldemo_suspn_3dof_variant';
isModelOpen = bdIsLoaded(mdl);
open_system(mdl);
delete(gcp('nocreate'));
Variant_Switch = 1;
Cf_sweep = Cf*(0.05:0.1:0.95);
numSims = length(Cf_sweep);
for i = numSims:-1:1
in(i) = Simulink.SimulationInput(mdl);
in(i) = setBlockParameter(in(i), [mdl '/Road-Suspension Interaction'], 'Cf', num2str(Cf_sweep(i)));
end
out = parsim(in, 'ShowProgress', 'on');

채택된 답변

Rahul Kumar
Rahul Kumar 2018년 10월 31일
Hi Simon,
Variant_1, Variant_2, and Variant_Switch, along with any other variables used by the model and defined in the base workspace need to be available to the parallel workers. There are two ways of achieving this
1. Use 'TransferBaseWorkspaceVariables' option with parsim
out = parsim(in, 'TransferBaseWorkspaceVariables', 'on')
The above option will copy all variables in the base workspace over to the base workspace of the parallel workers. The reason that this is not automatically handled by parsim is that in most cases, the model is already configured to load the required variables either using a model callback or via data dictionary so this additional step of transferring variables is usually not required.
2. Define the variables used in the model in a data dictionary . This allows parsim to automatically load the data dictionary on the parallel workers so that the variables are available.
I would suggest the first option if you are just tying out parsim with example models but consider using option 2 for production work.
-- Rahul
  댓글 수: 1
Simon Haslbeck
Simon Haslbeck 2018년 11월 5일
Thank you for your help, solution 1 does work. For solution 2 I first have to check if a data dictionary is integrateable without bigger complications.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Component-Based Modeling에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by