Checking multiple systems in parallel reduces the processing time required by the Model Advisor to check multiple systems. If you have the Parallel Computing Toolbox™ license, you can check multiple systems in parallel on a multicore host machine.
The Parallel Computing Toolbox does not support 32-bit Windows® machines.
Each parallel process runs checks on one model at a time. In parallel mode, load the model data from the model workspace or data dictionary. The Model Advisor in parallel mode does not support model data in the base workspace.
In the MATLAB® window, select New > Function.
Save the file as run_fast_configuration.m
.
In the function, right-click on untitled
and select
Replace function name by file name. The function name
is updated to run_fast_configuration
function [outputArg1, outputArg2] = run_fast_configuration(inputArg1,inputArg2)
Define the output and input arguments. For the output arguments, press Shift-Enter after entering each value to automatically update all instances in the function.
output_Arg1
as fail
output_Arg2
as warn
inputArg1, inputArg2
to
SysList
function [fail, warn] = run_fast_configuration(SysList) fail = inputArg1; warn = inputArg2;
Inside the function, specify the list of checks to run using the example Model Advisor configuration file:
fileName = 'slvnvdemo_mdladv_config.mat';
Call the ModelAdvisor.run
function and set
'ParallelMode'
to 'On'
.
SysResultObjArray = ModelAdvisor.run(SysList,'Configuration',fileName,... 'ParallelMode','On');
Determine the number of checks that return warnings and failures:
fail = 0; warn = 0; for i=1:length(SysResultObjArray) fail = fail + SysResultObjArray{i}.numFail; warn = warn + SysResultObjArray{i}.numWarn;
The function should now look like this:
function [fail, warn] = run_fast_configuration(SysList) %RUN_FAST_CONFIGURATION Check systems in parallel with Model Advisor % Return number of warnings and failures. fileName = 'slvnvdemo_mdladv_config.mat'; fail=0; warn=0; SysResultObjArray = ModelAdvisor.run(SysList,'Configuration',fileName,... 'ParallelMode','On'); for i=1:length(SysResultObjArray) fail = fail + SysResultObjArray{i}.numFail; warn = warn + SysResultObjArray{i}.numWarn; end end
Save the function.
Test the function. In the MATLAB Command Window, create a list of systems:
SysList={'sldemo_auto_climatecontrol/Heater Control',... 'sldemo_auto_climatecontrol/AC Control','rtwdemo_iec61508'};
Run run_fast_configuration
on the
list of systems:
[failures, warnings] = run_fast_configuration(SysList);
Review the results. Click the Summary Report link to open the Model Advisor Command-Line Summary report.