Justify Model Advisor Violations from Check Analysis
When you run checks using the Model Advisor app or the
ModelAdvisor.run function, Model Advisor analyzes your design for adherence to modeling guidelines. The results from analysis show which checks pass, fail, are incomplete, are justified, or return a warning. Model Advisor checks that fail or return a warning are considered violations because the results do not comply with the modeling guidelines checked by the Model Advisor check.
If you review a violation and consider the violation to either not be relevant or not feasible for your design, you can justify the result. When you justify a result, you provide a rationale for why you are allowing the violation to exist in your design. Justified checks have a check result status of
Justified in Model Advisor and the Model Advisor Report.
Justifications allow you to add a rationale for violations in the Model Advisor analysis results. If you want Model Advisor to not analyze specific blocks, use exclusions instead. Exclusions can save time during model development and verification, since Model Advisor does not analyze what you exclude. For more information, see Exclude Blocks from the Model Advisor Check Analysis.
This example shows how to:
Justify a violation for check results in Model Advisor.
Justify an edit-time violation from the Simulink® canvas.
Load, view, edit, and delete justifications in Model Advisor.
Create different justifications files for different sets of justifications.
Justify Violation Using Model Advisor
After you run a Model Advisor check, you can justify violations in the results in Model Advisor. For information about how to run Model Advisor checks, see Check Model Compliance by Using the Model Advisor.
1. Open the example model
2. Open Model Advisor. In the Simulink editor, click the Modeling tab and select Model Advisor. When the System Selector dialog box opens, click OK to analyze the model.
3. In the Check Selector pane, select the checks that you want to run on the model. For this example, navigate to the folder Model Advisor > By Product > Simulink and select the check named Check optimization settings.
4. Run the check by clicking Run Checks in the toolstrip. The Model Advisor results show a warning for the check Check optimization settings.
5. In the toolstrip, click Justify. The Result Inspector pane opens, and the Result Details tab shows the results for each violation of the check Check optimization settings.
6. In the Result Inspector pane, enter a rationale in the Justifications field and click Add Justification. The justification applies to the violation that you select in the Result Details tab. By default, Model Advisor automatically selects the first result.
Since you are justifying a check for the first time, Model Advisor prompts you with a Save As dialog box that allows you to create a justifications file with your specified file name and in your specified directory.
7. Specify the file name and directory where you want to save the justifications file. By default, the file name is
_justifications.json and the directory is your current working directory in MATLAB®.
When you click Save, a banner on the Simulink canvas shows the path to the justifications file that you saved, and Model Advisor shows the result as justified.
Justify Violation During Edit-Time Checking
After you enable edit-time checks for a model, you can justify violations directly from the Simulink canvas. For information on edit-time checks, see Check Model Compliance Using Edit-Time Checking.
1. Enable edit-time checking for the model. In the Simulink editor, click the Modeling tab and select Model Advisor > Edit-Time Checks. When the Configuration Parameters dialog box opens, select the check box for Edit-Time Checks and click OK.
In the Simulink canvas, Model Advisor highlights blocks in the model that violate checks in the default Model Advisor configuration.
2. Point to a highlighted block and click the icon above the block. For this example, point to the
Engine Speed block and click the warning icon .
Model Advisor displays a violation summary and the title of the violated check or sub-check. The
Engine Speed block violates the sub-check Characters allowed for block names.
3. Click Suppress and enter your rationale for the justification in the comment field.
4. Click Add Justification.
Since you already created a justifications file for the model, Model Advisor adds the justification to that file.
The violation no longer appears in the Simulink canvas.
If you justify other results, Model Advisor automatically adds those justifications to the current justifications file.
You can load, view, edit, and delete your justifications by using Model Advisor.
After you save a justifications file for a model, Model Advisor automatically loads that justifications file the next time that you open the model.
If you want to load a specific justifications file, open Model Advisor on the model and, in the toolstrip, select Open > Load Justifications File.
To see which justifications file is currently loaded for a model, open Model Advisor and, in the Check Selector pane, select Model Advisor. The Configurations section shows the currently loaded justifications file.
If you want to create a different justifications file for a different set of justifications, see Create Multiple Justifications Files.
View the justifications that you added in Model. Results that you justify have a check result status of
Justified and the Justified icon appears next to the results in Model Advisor and the Model Advisor report.
Note that to view justifications that you add during edit-time checking, you must re-run the checks from the Model Advisor app. For information on how to run checks and view results, see Check Model Compliance by Using the Model Advisor.
To edit the rationale for an existing justification:
1. Open Model Advisor.
2. Make sure the current justifications file is the file containing the justification you want to edit. In the Check Selector pane, click Model Advisor to view the current justifications file.
3. Select the result for which you want to edit the justification. In the Check Selector pane, select the check and in the Result Details tab, select the justified result.
4. Click Edit in the Result Inspector pane to edit the rationale in the Justifications field.
5. Click Add Justification to update the justification with the new rationale.
To delete an existing justification:
1. Open Model Advisor.
2. Make sure the current justifications file is the file containing the justification you want to delete. In the Check Selector pane, click Model Advisor to view the current justifications file.
3. Select the result for which you want to delete the justification. In the Check Selector pane, select the check and in the Result Details tab, select the justified result.
4. Click Delete in the Result Inspector pane to delete the justification from the currently loaded justifications file. The check result status returns to its original status of
Create Multiple Justifications Files
If you already have a justifications file and you want to create a set of justifications in a new file, you must unload your current file. To unload your current file, move or rename it. When you add a justification for the model, Model Advisor prompts you to save a new justifications file.
Note that you can also use the
Justifications argument in
ModelAdvisor.run to perform a Model Advisor analysis with a specific justifications file.