Main Content

Analyze Variant Configurations in Models Containing Variant Blocks

A variant model can have one or multiple variant configurations associated with it. Using the Variant Manager, you can create variant configurations. Each variant configuration contains a set of variant control variable values which activates the variant choices in the model. Each variant configuration can be used to produce a specific implementation of the model. The number of variant configurations can be high depending on the number of variant control variables used in the model. Because of the high number of variant configurations, it can be difficult to make sure all the variant choices have been activated at least once, and that the model is covered completely for simulation and code generation. It is also difficult to ensure that the active, implemented model is different between different variant configurations. You can use the Variant Configuration Analysis tool in the Variant Manager to compare different variant configurations for a model. Additionally, you can get information on the dependent models and libraries used for a particular variant configuration.

The Variant Configuration Analysis tool also helps you to determine which blocks are used in different variant configurations. You can identify which blocks are unused and which are inside variant region and are always used. 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. The analysis results can be used to refine the variant configurations and to update the model to provide full simulation coverage across all variant configurations.

Analyze a Model with Variant Configurations

  1. Open a model containing variant blocks. For example, Sensor Vendors.

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

  2. Right-click the variant badge and select Open in Variant Manager. The Variant Manager opens and displays the predefined configurations. Alternatively, select a variant block and then in the Variant tab of the toolstrip select Variant Manager.

  3. Click Analyze. The Variant Configuration Analysis dialog box opens.

  4. In the Analysis mode, select the required option.

    • Specify variant configurations: Select the required Variant Configurations or select Named configurations to select all configurations.

    • Specify variant control values: If you select this option, you can create multiple variable groups that correspond to different configurations. To create a new variable group, click New variable group and set the values for variant control variables. You can either specify a variant control value or select Ignored from the drop-down list. If you select Ignored, then that variant control variable is not considered while analyzing the model.

  5. Click Analyze. The report for analyzed variant configurations opens.

    Note

    In this example, option Specify variant configurations is selected in Analysis mode.

The report displays the tree-table view of the model hierarchy and all of the analyzed variant configurations. Each row in the table corresponds to a block in the model and each column represents a variant configuration. A check mark indicates that the corresponding block is active in the corresponding variant configuration. Entries highlighted in red indicate that the block is inactive for that specific variant configuration. For example, in the above image, the Vendor A block is active in variant configurations VendorACtrlLinear, VendorACtrlFuzzy and VendorACtrlNonLinear and is inactive in variant configurations VendorBCtrlFuzzy, VendorBCtrlLinear, VendorBCtrlSecondOrder, and VendorBCtrlNonLinear.

The annotations in the report (“c:#”) corresponds to a variant condition. The variant conditions are dependent on which variant configuration is active. The mapping between the annotation and the condition is shown in the image. The variant conditions help you in understanding why a block is active for given variant configuration (the variant condition is evaluated based on the values of the control variable defined in the configuration).

The controls on the Variant Configuration Analysis window allow you to perform the following actions:

  • Search blocks.

  • Filter the results to selectively display blocks.

  • Selectively display analyzed blocks.

View Blocks

Selectively display blocks in the Variant Analysis window by:

  • Selecting Variant to display only variant blocks in the model.

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

  • Selecting All blocks to display all blocks in the model.

Block Activeness

Selectively display blocks by their activeness in the Variant Configuration Analysis window by:

  • Selecting Always Active to display blocks that are always active in the model.

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

  • Selecting Never Active to display blocks that are never active in the model. These blocks are additionally highlighted in red to indicate that they are unused parts of the model and require fixing.

For example, the image below shows a model with several unused blocks. Never Active option is selected to view the 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.

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

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

Viewing Annotation

The annotations in the table correspond to a variant condition. The variant conditions depend on the active variant configuration. The variant conditions help you to understand whether the block is active for the given variant configuration. The variant condition is evaluated based on the values of the control variable defined in the configuration.

Click on the required annotation to view the block that has the selected annotation.

Related Topics