Main Content

Use Model Advisor Configuration Editor to Customize Model Advisor

Overview of the Model Advisor Configuration Editor

The Model Advisor Configuration Editor provides a way for you to specify the checks that you want to use for edit-time checking, as well as the checks included in the Model Advisor. This organizational hierarchy is saved as a configuration file, which is loaded when you initiate the Model Advisor. You can use the Model Advisor Configuration Editor to modify existing configurations, create new Model Advisor configurations, and specify the default configuration.

The Model Advisor Configuration Editor gives you the flexibility to customize the Model Advisor analysis to meet the needs of your organization by allowing you to:

  • Review all available Model Advisor checks.

  • Add, remove, and organize built-in checks and folders in the Model Advisor tree.

  • Integrate custom Model Advisor checks in your verification and validation workflow.

  • Disable and enable checks and folders.

  • Rename checks and folders.

  • Specify whether a check is marked as a warning or failure when it is flagged during a Model Advisor analysis.

  • Suppress the warning about missing checks when loading the Model Advisor configuration.

  • Upgrade old check configuration files to be compatible with newer versions of MATLAB®.

The Model Advisor Configuration Editor includes:

  • The Library pane — A read-only pane that lists all checks and folders that are available for use in the configuration. There are three filter options to view the checks:

    • Show All — Lists all the checks.

    • By Product — Lists the checks based on the product folders they belong.

    • By Task — Lists the checks based on the task folders they belong.

    On selecting the filter, you can view the checks in a tree structure. To permanently display the Library tab, click Show Library on the toolstrip.

  • The Configuration pane — This pane lists all the checks and folders in the current Model Advisor configuration and enables you to select a particular check to view its details in the Information tab.

  • Information tab — This tab provides:

    • Details about the check or folder, such as the Display Name, Check Instance ID or Check Group ID, and the Check result when issues are flagged.

    • Fix button — Fixes outdated checks.

    • Delete button — Deletes checks that are no longer supported.

    • Help button — Opens the help page of the particular check.

    • Apply button — Applies your changes to the display name of the selected check, folder, and other settings of the check.

Use the search functionality in the Library and Configuration panes to locate specific checks and folders.

Model Advisor Configuration Editor showing the Library pane, Configuration pane, and Information tab

Open the Model Advisor Configuration Editor

Before opening the Model Advisor Configuration Editor, verify that the current folder is writable. If the folder is not writable, you see an error message when you start the Model Advisor Configuration Editor.

When implementing custom checks or Model Advisor customizations by using the Model Advisor API, you must first update the Simulink® environment to include your sl_customization.m file. At the MATLAB command line, enter

Advisor.Manager.refresh_customizations

Use one of these methods to open the Model Advisor Configuration Editor:

  • Programmatically ― At the MATLAB command line, enter Simulink.ModelAdvisor.openConfigUI.

  • From the Simulink editor ― In the Modeling tab, select Model Advisor > Configuration Editor.

  • From the Model Advisor ― Select Open > Open Configuration Editor.

The configuration file that is currently being used by the Model Advisor displays when you open the Model Advisor Configuration Editor. The file name for the configuration is displayed at the top of the window. Verify that you are evaluating the correct configuration file. To open a different configuration file, click Open and browse to the file you would like to review.

To create a new configuration, click the New button on the toolstrip. Use Save As to rename the configuration file. Model Advisor configuration files are saved in .json format.

Note

If your configuration file contains checks that are incompatible with the newer version of MATLAB you use, fix the issues in the configuration as described in Upgrade Incompatible Checks in Model Advisor Configuration Files.

Specify a Default Configuration File

You can use the Model Advisor Configuration Editor to specify a default configuration that loads automatically when the Model Advisor opens. To set the default configuration, open the configuration file in the Model Advisor Configuration Editor and click the Set As Default button on the toolstrip.

Note

If you have previously designated a default configuration, you can use Clear default configuration setting to clear the setting that designates the current default configuration file. Clicking the button does not modify the configuration that is currently displayed in the Model Advisor Configuration Editor. When you do not specify a default configuration, the Model Advisor uses the standard configuration that is defined by your system administrator.

If you do not specify the configuration file as the default, when you save the file, you are prompted as to whether to make the file the default configuration. To make this file the default configuration, click Yes.

To associate a custom configuration with a model, so that the Model Advisor uses that configuration each time you open that model, see Load and Associate a Custom Configuration with a Model.

Customize the Model Advisor Configuration

You can use the Model Advisor Configuration Editor to customize the Model Advisor configuration tree, including adding and removing checks and folders and specifying the order in which checks are executed. You can also disable the ability for users to select whether to include or exclude a check from an analysis. You can also use the Model Advisor Configuration Editor to define the input parameters for a check.

Note

Checks that are copied from the Library tab retain their default parameter settings. When they are pasted into your custom configuration folder, the box beside each check is not selected.

Checks that are copied or cut from a folder in the Model Advisor tab retain their user-define parameter settings. When a check is included in multiple folders, you can specify different parameters for each check individually.

Organize the Hierarchy

You can customize the layout of the checks and folders in the Model Advisor configuration tree by using:

  • New Folder to create a folder.

  • Copy, Cut, and Paste to add, copy, and move checks and folders.

  • Delete to remove checks and folders.

  • Move Up or Move Down to shift the position of the check or folder in the configuration tree. The folders and checks that are higher in the configuration tree are executed first in the analysis.

Note, you can customize the Model Advisor by using the ModelAdvisor.Group and ModelAdvisor.FactoryGroup classes instead of the Model Advisor Configuration Editor. However, these APIs are a less flexible and more time-consuming way of customizing the Model Advisor. To place customized checks in custom folders at the top-level of the Model Advisor tree (the Model Advisor root), use the ModelAdvisor.Group class. To place customized checks in new folders in the By Task folder, use the ModelAdvisor.FactoryGroup class. You must include methods that register these tasks and folders in the sl_customization function.

Enable or Disable Checks

You can use the Model Advisor Configuration Editor to disable the check box control for checks and folders in the Model Advisor. By doing so, the check is still listed in the Model Advisor configuration tree, but it is dimmed and you do not have the ability to add or remove the check from the analysis.

In the Configuration pane, right-click on a folder or check and select Disable. Depending on the check box selection in the Model Advisor Configuration Editor, the following results occur in the Model Advisor:

  • If the box beside check is selected in the Model Advisor Configuration Editor, then in the Model Advisor, the check is automatically selected. Because you selected Disable, the check is dimmed and you cannot choose to remove the check from the analysis.

    If the box beside the check is not selected and the Disable option is applied in the Model Advisor Configuration Editor, then in the Model Advisor, the check is not selected and you cannot included it in the analysis.

  • If the box beside folder is selected in the Model Advisor Configuration Editor, then in the Model Advisor, the checks within the folder are automatically selected. Because you selected Disable, the folder and its checks are dimmed and you cannot choose to remove the checks from the analysis.

    If the box beside the folder is not selected and the Disable option is applied in the Model Advisor Configuration Editor, then in the Model Advisor, none of the checks within the folder are selected and you cannot include it in the analysis.

When a check or folder is disabled, you can use the Enable option to allow users to determine whether to include the check(s) in an analysis.

Note

Enable and Disable affects the execution of checks in the analysis for both the Model Advisor user interface and edit-time checking.

Specify Parameters for Check Customization

You can use the Model Advisor Configuration Editor to customize a Model Advisor check, such as the display name and input parameters for the check.

In the Information tab, review the content that you can customize for the check:

  • Display Name — Provide a new name for the check, which is displayed in the Model Advisor. Note that changing the display name does not change the check title.

  • Check result when issues are flagged — Specify whether you want the check to be marked as a warning or failure in the results when the check flags an issue in your model. The default value is Warning. Select Fail to mark a flagged check as failed in the results.

  • Input Parameters — Specify additional characteristics and functionality for the check. The Model Advisor uses these parameters to further define the emphasis of the analysis. For example, you can choose to include only subcheck jc_0736_b and specify the acceptable number of single-byte spaces in the analysis for Model Advisor check Check indentation of code in Stateflow states.

Suppress Warning Message for Missing Checks

The Model Advisor automatically warns you of checks that are missing when loading a Model Advisor configuration. You can use the Model Advisor Configuration Editor to suppress this message. Select the Model Advisor Configuration Editor root node and, in the Information tab, select Suppress warning message for missing checks when loading configuration.

Alternatively, you can programmatically suppress the Model Advisor warning by entering this command at the MATLAB command line:

warning('off','Simulink:tools:MALoadConfigMissCorrespondCheck')

Upgrade Incompatible Checks in Model Advisor Configuration Files

You can use the Model Advisor Configuration Editor to upgrade your Model Advisor configurations to the newer version of MATLAB. Upgrading configurations enables you to view and use newly introduced or updated input parameters and check IDs. You can also delete the checks that are no longer supported. Model Advisor Configuration Editor facilitates you to automatically bulk update or delete the incompatible checks in your configuration. You can also update or delete incompatible checks individually and then validate the configuration for compatibility.

Update or Delete Checks in Configuration Files Automatically Using Model Advisor

  1. In Model Advisor Configuration Editor, when you load an old configuration file which contains checks that are incompatible with the newer version of MATLAB in use, you get a dialog box asking whether to automatically fix issues in the configuration. To learn how to load a configuration, see Open the Model Advisor Configuration Editor.

  2. To fix the issues automatically, click Yes. Model Advisor alters the fixable checks and deletes the nonfixable checks from the configuration file.

    • A check is fixable if it contains outdated input parameters or check IDs. Or else, it does not have the input parameters or check IDs introduced in the newer version of MATLAB in use.

    • A check is nonfixable if it is no longer supported in the newer version of MATLAB in use.

    The Validation Summary window displays the list of updated and deleted checks. For more information, see View Updated and Deleted Checks in Validation Summary.

  3. Click Save to save the upgraded configuration file in JSON format. You can now use the upgraded configuration file to review your models in the newer version of MATLAB.

Update or Delete Checks in Configuration Files Individually

  1. In Model Advisor Configuration Editor, when you load an old configuration file which contains checks that are incompatible with the newer version of MATLAB in use, you get a dialog box asking whether to automatically fix issues in the configuration. To learn how to load a configuration, see Open the Model Advisor Configuration Editor.

  2. To open the Model Advisor Configuration Editor with check issues highlighted and fix the issues individually, click No. The Configuration pane lists the folders of the loaded configuration. The red cross mark over the folder icon Icon of folder that contains incompatible checks indicates that the folder contains incompatible checks.

  3. Expand a folder that contains incompatible checks. The wrench exclamation icon Icon of incompatible checks denotes incompatible checks. When you click an incompatible check on the list, the Information tab displays a banner. If the check is a fixable check, you can update it or delete it. If the check is a nonfixable check, you can only delete it.

    Fix or delete fixable checks

  4. If you want Model Advisor to automatically update or delete the rest of the incompatible checks within the configuration file, click the Validate button in the toolstrip. Model Advisor alters the fixable checks and deletes the nonfixable checks from the configuration file. The Validation Summary window displays the list of updated and deleted checks. For more information, see View Updated and Deleted Checks in Validation Summary.

  5. Click Save to save the upgraded configuration file in JSON format. You can now use the upgraded configuration to review your models in the newer version of MATLAB.

View Updated and Deleted Checks in Validation Summary

After you upgrade an old configuration file to verify your models in a newer version of MATLAB, Model Advisor generates a Validation Summary. The Validation Summary window lists the updated and the deleted checks.

This table explains the sections in the Validation Summary window.

IconSection

Checks with updated input parameters and Check IDs

Checks with updated input parameters — The checks that are altered to include input parameters which are introduced or updated in the newer version of MATLAB.
Checks with updated Check IDs — The checks that are altered to include check IDs which are introduced or updated in the newer version of MATLAB.

Checks which are deleted

Checks which are deleted — The checks that are no longer supported in the newer version of MATLAB.

Use the Model Advisor Configuration Editor to Create a Custom Model Advisor Configuration

You can use the Model Advisor Configuration Editor to organize the hierarchy of the Model Advisor and specify checks that are included in check analyses. This example shows how to create a new configuration file, specify checks for the Model Advisor and edit-time checking, define check parameters, and load the configuration to the Model Advisor.

Create a Model Advisor Configuration

In this example, you will create a custom configuration file named custom_Configuration.json. This configuration will consist of MathWorks Advisory Board (MAB) modeling guidelines checks and industry standard checks that you want to execute by using the Model Advisor.

1. Open the Model Advisor Configuration editor by entering this command at the command prompt:

Simulink.ModelAdvisor.openConfigUI

2. In the toolstrip, select Show Library to display the Library pane. In the By Product tab search field, enter ISO 26262.

3. Right-click on the Simulink Check > Modeling Standards > IEC 61508, IEC 62304, ISO 26262, ISO 25119, EN 50128, and EN 50657 Checks folder and select Copy. Right-click on the Model Advisor Configuration Editor root folder and click Paste. Verify that the folder and checks have been copied to the root folder.

Note: Checks that are copied from the Library pane retain their default parameter settings. When they are pasted into your custom configuration folder, the box beside each check is not selected.

4. In the By Task folder on the Configuration pane, right-click on the Modeling Standards for MAB folder and select Cut. Click on the Model Advisor Configuration Editor root folder and click Paste. The folder is removed from the By Task folder and is added as a new subfolder in the Model Advisor Configuration Editor root folder.

Note: Checks that are copied or cut from a folder in the Configuration pane retain their user-defined parameter settings. When a check is included in multiple folders, you can specify different parameters for each check individually.

5. Select the IEC 61508, IEC 62304, ISO 26262, ISO 25119, EN 50128, and EN 50657 Checks folder and use the Move Down button to change the position this folder in the hierarchy. The Model Advisor will execute the checks in the Modeling Standards for MAB folder first.

6. Select the By Product and By Task folders and select Delete.

7. Click Save As and name the configuration file to custom_Configuration. Select Yes at the prompt to save the configuration as the default configuration. The file automatically saves in .json format.

Note: If you have previously designated a default configuration, you can use Clear default configuration setting to clear the flag that specifies the current default configuration file. Clicking the button does not modify the configuration that is currently displayed in the Model Advisor Configuration Editor.

8. Close the Model Advisor Configuration Editor.

9. Open the AdvisorCustomizationExample.slx model by entering the following in the MATLAB command line:

open_system('AdvisorCustomizationExample.slx');

10. On the Modeling tab, click Model Advisor > Edit-Time Checks. In the Configuration Parameters dialog box, select Edit-Time Checks and Apply. Close the Configuration Parameters dialog box.

11. In the model, notice that three blocks are highlighted. These blocks contain edit-time check violations for this configuration. Place your cursor over a warning and click the block to discover the issue.

model_edit_time.png

12. Open the Model Advisor and confirm that the Model Advisor displays the folders Modeling Standards for MAB and IEC 61508, IEC 62304, ISO 26262, ISO 25119, EN 50128, and EN 50657 Checks.

13. Close the Model Advisor.

Update a Model Advisor Configuration

You will now customize the checks in your custom configuration file, custom_Configuration.json file and review the effect that your customizations have on the Model Advisor analysis of the AdvisorCustomizationExample.slx model.

1. On the Modeling tab, click Model Advisor > Configuration Editor.

2. Clear the check box the box beside the Model Advisor Configuration Editor root node folder. (This step is optional. However, deselecting the checks allows you to more easily view the results of using the Model Advisor Configuration Editor to specify checks for display in the Model Advisor.)

3. To allow you to use the Model Advisor to specify which checks to include in the Model Advisor analysis, right-click on the Model Advisor Configuration Editor root folder and click Enable. (Note: Enable is the default setting. This option is dimmed when none of the checks are disabled.)

4. Check the box beside the Modeling Standards for MAB > Naming Conventions > Content > Check character usage in block name check.

5. Right-click on each of these checks and select Disable:

  • Modeling Standards for MAB > Naming Conventions > Content > Check character usage in block names

  • Modeling Standards for MAB > Naming Conventions > Content > Check length of subsystem name

6. Click the Modeling Standards for MAB > Simulink > Diagram Appearance > Check whether block names appear below blocks check and, in the Information tab, select Fail for the Check result when issues are flagged option. Click Apply.

Note: The default for the Check result when issues are flagged option is Warning.

7. Click Save to save the configuration. Close the Model Advisor Configuration Editor and the model.

8. Refresh the Model Advisor cache and open model AdvisorCustomizationExample.slx by entering the following in the MATLAB command line:

Advisor.Manager.refresh_customizations();
open_system('AdvisorCustomizationExample.slx');

9. Open the Model Advisor.

Observe these checks, which reflect the settings that you chose in the Model Advisor Configuration Editor:

  • The Modeling Standards for MAB > Naming Conventions > Content > Check character usage in block names check is dimmed and the check box is selected. This check will always execute in a Model Advisor analysis and, because it is dimmed, you cannot choose to exclude it from the analysis.

  • The Modeling Standards for MAB > Naming Conventions > Content > Check length of subsystem names check is dimmed and the check box is not selected. This check will not be included in the analysis and, because it is dimmed, you cannot select it for inclusion in the analysis.

10. Check the box beside the Modeling Standards for MAB > Simulink > Diagram Appearance > Check whether block names appear below blocks check.

11. To run the Model Advisor analysis, right-click on the Model Advisor Standards for MAB root node and select Run Selected Checks.

12. Click on the following checks and review the Model Advisor analysis results:

  • The Modeling Standards for MAB > Naming Conventions > Content > Check character usage in block names check is marked with a warning icon and the results specify the check violation is in the Gain block.

  • There are no results for the Modeling Standards for MAB > Naming Conventions > Content > Check length of subsystem check because it could not be selected for the analysis.

  • The Modeling Standards for MAB > Simulink > Diagram Appearance > Check whether block names appear below blocks check is marked with a fail icon. This behavior is intended; you specified this check settings by using the Model Advisor Configuration Editor.

See Also

|

Related Topics