Main Content

Analyze Variant Configurations in Models Containing Variant Blocks

Note

This functionality requires Variant Manager for Simulink®.

A model might contain several variant blocks or variant parameters, each with many variant choices. A variant configuration is used to represent a combination of such variant choices across the model hierarchy. For example, in a system with a plant and a controller, a linear controller with an internal plant with no noise and a nonlinear controller with an external low fidelity plant represent two different configurations of the system.

You can use Variant Manager to create and manage variant configurations for a model. Variant Manager defines a variant configuration as a set of variant control variables and their values that can activate a specific variation in the model hierarchy. For more information on variant configurations, see Variant Configurations. For an overview of Variant Manager, see Variant Manager for Simulink.

Analyze Variant Configurations Using Variant Analyzer

Use Variant Analyzer to:

  • Compare different variant configurations for a model to understand the model elements used in each.

  • Check if all variant choices have been activated at least once and whether the model is covered completely for simulation and code generation.

  • Verify if the active, implemented model is different between different variant configurations.

  • Find dependent model artifacts such as referenced models and libraries used by a particular variant configuration.

You can analyze the named variant configurations created for the model or perform an analysis after setting values for the variant control variables. The report generated by the tool displays:

  • Variant configurations analyzed

  • A model hierarchy with all the blocks

  • Variant activeness of each block in each variant configuration

  • Propagated variant conditions on a block for each variant configuration

The analysis results help you to determine which blocks are used in different variant configurations. The unused blocks are highlighted in red, which represents untested and uncovered parts of the model. The heatmap view helps you determine the similarities and differences in the active, implemented model between different variant configurations. This information can be used to refine the variant configurations and to update the model to provide full simulation coverage across all variant configurations.

Run Variant Analyzer

  1. Open the variant model that must be analyzed. Here, open the slexVariantConfigurationAnalysis model using the following command.

    openExample('simulink_variants/AnalyzeVariantConfigurationsInModelRefPageExample');
    open_system('slexVariantConfigurationAnalysis');

    Model with Variant Source and Variant Sink blocks

    This model contains multiple vendor choices for the sensors and different controller implementations based on the sensor input. The choice of vendor sensors is modeled with Variant Source and Variant Sink blocks. The different controller choices is modeled using Variant Subsystem block.

  2. Open Variant Manager. On the Modeling tab, open the Design section and click Variant Manager. Alternatively, right-click the variant badge on any variant block and select Open in Variant Manager.

    Context menu open on variant badge of variant block, with Open in Variant Manager option selected

    The Variant Manager opens and displays the predefined configurations. To open Variant Analyzer, in the Variant Manager toolstrip, in the Apps section, click Variant Analyzer.

    Variant Analyzer window

  3. For Analysis mode, choose whether to analyze the predefined named configurations for the model or if you need to specify values for the variant control variables.

    • Specify variant configurations — Select from the list of named variant configurations in the Configurations tab.

    • Specify variant control values — Analyze the model by specifying values for the variant control variables. You can create multiple variable groups that correspond to different variant configurations to be analyzed. In each variable group, you must specify the variant control variables and the values to be considered for each variable.

      To add a new variable group, click the Add variable group button in the Variable Groups table and set the values for variant control variables. You can either specify a variant control value or select Ignored from the Values list.

      • Variant control value as a vector — Analyze for all combinations of the specified values. For example, if you specify values V = 1 and W = [1,2], then the model is analyzed for the configurations {V == 1, W == 1} and {V == 1, W == 2}.

      • Ignored — The variant control variable is not considered while analyzing the model.

      Variant Analyzer window with Specify variant control values selected and a new variable group added. The variant control variables are shown.

  4. Click Analyze Model. The variant analysis report opens in a new window.

  5. Click Close Variant Analyzer to return to the Manage tab in Variant Manager.

Explore Variant Analysis Report

The variant analysis report displays a tree-table view of the model hierarchy and all of the analyzed variant configurations.

This image shows the analysis report for four named variant configurations.

Variant analysis report shows the variant configurations analyzed and the activeness state of each block in each configuration. It also shows the propagated variant condition on each block.

Icons and Formatting

This table explains the icons and formatting used in the report.

FormattingMeaning

Rows and Columns

Each row in the table corresponds to a block in the model. Each column represents a variant configuration.

Check mark

The check mark symbol is for a visual aid and indicates that the block is active in the corresponding variant configuration.

Background color

An entire row including the block name appears with a red background color if it is not active in any of the variant configurations. Such a block indicates an untested path in the model.

A table field with red background color indicates that a particular block is not active in a specific configuration.

For example, in this model, the Vendor A block is active in the variant configurations VendorACtrlLinear and VendorACtrlNonLinear and inactive in the variant configurations VendorBCtrlLinear and VendorBCtrlNonLinear.

Block activeness icons

The Block is active in all analyzed configurations, Block differs in activeness in analyzed configurations, and Block is inactive in all analyzed configurations icons in the Activeness column indicate if a block is active in all the configurations, active in some configurations, or inactive in all configurations, respectively.

Variant condition annotations (c:#)

The annotations in the table fields represent a variant condition that the block receives for a particular configuration. The propagated variant condition on a block changes according to the active variant configuration.

You can refer the table in the Annotation pane for mapping between the annotations (c:#) and the propagated variant conditions that each of them represent. The propagated variant conditions help you understand why a block is active for a given variant configuration (the variant condition is evaluated based on the values of the control variables defined in the configuration). Click an annotation in the table. All the blocks that have that annotation appear highlighted in the configurations table.

Filter the Report

Filter the report based on your desired type of filter.

Desired FilterFiltering Method

Name of block

Enter the block name in the Search Blocks box and press Enter.

Type of block

Select an option from the View Blocks list:

  • Variant to display only variant blocks in the model.

  • Hierarchical to display all hierarchical blocks in the model, for example, Subsystem or Model blocks. This view allows you to explore subsystems or model references one by one instead of looking through the complete model.

  • All blocks to display all blocks in the model.

Block activeness

Block activeness check box filter

  • Always Active displays blocks that are always active in the model.

  • Partially Active displays blocks that are active in some configurations and inactive in others among the selected configurations.

  • Never Active displays blocks that are never active in the model. These blocks appear highlighted in red, which indicates they are untested and uncovered parts of the model and require updates to provide full simulation coverage.

Example Variant Analysis Reports

Consider this report for a model with several unused blocks. The Never Active option is selected to view the unused blocks.

Variant analysis report for a model with several unused blocks

The blocks in the Second order controller inside the Linear_Control and F1_Unsat filter are unused. To make these unused blocks part of the active model in at least one of the variant configurations, modify the model or update the variant configurations.

This image shows the report for a model with two identical variant configurations. The Partially Active option is selected to get this result.

Variant analysis report for two similar configurations

The variant configurations VendorBCtrlLinear and VendorBCtrlSecondOrder have no differences between them. The resulting active model for both these configurations will be the same. To resolve this result, update the variant configurations or update the model appropriately.

Analyze Variant Configurations Programmatically

Use an instance of the Simulink.VariantConfigurationAnalysis class to analyze variant configurations programmatically.

Limitations

Variant Analyzer does not support models that contain variant blocks that use variant control variables defined in the mask or model workspace.

See Also

|

Related Topics