Main Content

ModelAdvisor.run

Package: ModelAdvisor

Run Model Advisor checks on systems

Description

example

SysResultObjArray = ModelAdvisor.run(SysList,CheckIDList,Name,Value) runs the Model Advisor on the systems provided by SysList with additional options specified by one or more optional Name,Value pair arguments. CheckIDList contains cell array of check IDs to run.

example

SysResultObjArray = ModelAdvisor.run(SysList,'Configuration',FileName,Name,Value) runs the Model Advisor on the systems provided by SysList. The list of checks to run is specified using a Model Advisor configuration file, specified by FileName.

Input Arguments

SysList

Cell array of systems to run.

CheckIDList

Cell array of check IDs to run. For details on how to find check IDs, see Find Model Advisor Check IDs.

CheckIDList optionally can include input parameters for specific checks using the following syntax; {'CheckID','InputParam',{'IP','IPV'}}, where IP is the input parameter name and IPV is the corresponding input parameter value. You can specify several input parameter name and value pair arguments in any order as IP1,IPV1,…,IPN,IPVN.

FileName

Name of the Model Advisor configuration file. For details on creating a configuration file, see Use the Model Advisor Configuration Editor to Customize the Model Advisor.

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

DisplayResults

Setting DisplayResults to 'Summary' displays a summary of the system results in the Command Window. Setting DisplayResults to 'Details' displays the following in the Command Window:

  • Which system the Model Advisor is checking while the run is in progress.

  • For each system, the pass and fail results of each check.

  • A summary of the system results.

Setting DisplayResults to 'None' displays no information in the Command Window.

Default: 'Summary'

ExtensiveAnalysis

Setting 'ExtensiveAnalysis' to 'On' runs each of the checks in your Model Advisor configuration, including checks that trigger extensive analysis. Setting 'ExtensiveAnalysis' to 'Off' runs only checks that do not trigger extensive analysis.

Checks that trigger extensive analysis of the model use additional analysis techniques, such as analysis with Simulink® Design Verifier™. The checks that trigger extensive analysis have the label ^^ in front of the check name in the Model Advisor.

To use the 'ExtensiveAnalysis' name-value argument, you must specify a check configuration file name with the 'Configuration' argument.

Default: 'On'

Force

Setting Force to 'On' removes existing modeladvisor/system folders. Setting Force to 'Off' prompts you before removing existing modeladvisor/system folders.

Default: 'Off'

ParallelMode

Setting ParallelMode to 'On' runs the Model Advisor in parallel mode if you have a Parallel Computing Toolbox™ license and a multicore 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. For an example, see Create a Function to Check Multiple Systems.

Default: 'Off'

TempDir

Setting TempDir to 'On' runs the Model Advisor from a temporary working folder, to avoid concurrency issues when running using a parallel pool. For more information, see Resolving Data Concurrency Issues. Setting TempDir to 'Off' runs the Model Advisor in the current working folder.

Default: 'Off'

ShowExclusions

Setting ShowExclusions to 'On' lists Model Advisor check exclusions in the report. Setting ShowExclusions to 'Off' does not list Model Advisor check exclusion in the report.

Default: 'On'

ReportFormat

Setting Reportformat to 'html' | 'pdf | 'word' generates the report in the selected format.

Note: Model Advisor displays an error if unsupported formats are selected. For Windows operating system, supported formats are pdf | html | word. For Linux operating system the only supported format is html.

Default: 'html'

ReportPath

Setting ReportPath to 'slprj/model' sets the report generation location to the path as mentioned in the argument.

Default: 'slprj'

ReportName

Setting ReportName to 'Report' generates a Model Advisor report with the selected name.

Output Arguments

SysResultObjArray

Cell array of ModelAdvisor.SystemResult objects, one for each model specified in SysList. Each ModelAdvisor.SystemResult object contains an array of CheckResultObj objects. Save SysResultObjArray to review results at a later time without having to rerun the Model Advisor (see Save and Load Process for Objects).

CheckResultObj

Array of ModelAdvisor.CheckResult objects, one for each check that runs.

Examples

collapse all

Create a list of check IDs and use ModelAdvisor.run to run the specified checks.

Use Model Advisor to run the checks Check model diagnostic parameters and Check for unconnected objects on the subsystems sldemo_auto_climatecontrol/Heater Control and sldemo_auto_climatecontrol/AC Control.

% Create list of checks and models to run
checkIDs = {'mathworks.maab.jc_0021',...
'mathworks.iec61508.UnconnectedObjects'};
systems = {'sldemo_auto_climatecontrol/Heater Control',...
    'sldemo_auto_climatecontrol/AC Control'};

% Run the Model Advisor
results = ModelAdvisor.run(systems,checkIDs);

For more information on Model Advisor checks, see Model Advisor Checks Documentation. For details on how to find check IDs, see Find Model Advisor Check IDs.

Run Model Advisor on the list of checks specified by a Model Advisor configuration file.

Copy the script prepare_cust_chk_code.m to your current folder and run the script. The script copies files necessary for this example to your current folder.

copyfile(fullfile(matlabroot,'examples','slcheck','main',...
    'prepare_cust_chk_code.m'),'prepare_cust_chk_code.m','f');

run('prepare_cust_chk_code.m');

Refresh the Model Advisor check information cache to include the files necessary for this example.

Advisor.Manager.refresh_customizations()

Use the example configuration file demoConfiguration.json to specify which checks to include in Model Advisor analysis on the subsystems sldemo_auto_climatecontrol/Heater Control and sldemo_auto_climatecontrol/AC Control.

% Specify the example configuration file
fileName = 'demoConfiguration.json';

% Create the list of subsystems for Model Advisor to run checks on
systems = {'sldemo_auto_climatecontrol/Heater Control',...
    'sldemo_auto_climatecontrol/AC Control'};

% Run Model Advisor
results = ModelAdvisor.run(systems,'Configuration',fileName);

For more information on Model Advisor checks, see Model Advisor Checks Documentation. For details on how to find check IDs, see Find Model Advisor Check IDs.

Tips

  • If you have a Parallel Computing Toolbox license and a multicore machine, Model Advisor can run on multiple systems in parallel. You can run the Model Advisor in parallel mode by using ModelAdvisor.run with 'ParallelMode' set to 'On'. By default, 'ParallelMode' is set to 'Off'. When you use ModelAdvisor.run with 'ParallelMode' set to 'On', MATLAB® automatically creates a parallel pool.

Alternatives

  • Use the Model Advisor GUI to run each system, one at a time.

  • Create a script or function using the Simulink.ModelAdvisor class to run each system, one at a time.

Extended Capabilities

Introduced in R2010b