Main Content

Compose Variant Configurations for Top Model Using Referenced Model Configurations

A variant configuration represents a combination of variant choices across a Simulink® model hierarchy. It contains a set of variant control variables and their values, which can be used to activate a specific variation in the model hierarchy. Variant Manager allows you to create and manage the variant configurations for a model.

In Variant Manager, a variant configuration for a top-level model must also define the variant control variables used by any referenced components in the model hierarchy, such as referenced models. This approach helps to maintain a single consistent definition for a variant control across the hierarchy.

You can either directly add the variant control variables used by a referenced component to the top-level model configuration or if the referenced component has named variant configurations of its own, you can use them to set up the control variables in the top-level configuration. This topic explains how to use the Component Configurations view in Variant Manager to select the referenced component configurations to be used for the initialization.

To add or remove component configurations programmatically, use the addComponentConfiguration and removeComponentConfiguration methods.

Open Component Configurations View

To open the Component Configurations view for a top-level model configuration:

  1. Open Variant Manager for the top-level model. On the Modeling tab, open the Design section and click Variant Manager.

  2. Click the required configuration in the Configurations tab.

  3. In the Control Variables section for the selected variant configuration, click Show Component Configurations. This action opens the Component Configurations view as a tab in the model hierarchy pane.

This image shows the Component Configurations tab for the slexVariantManagement model.

Component configurations view

To get the name of the referenced model configuration used within a top-level variant configuration programmatically, use the getComponentConfigurationName method.

Select Variant Configuration for Referenced Component

  • Expand the model hierarchy in the Component Configurations tab.

  • Locate the required referenced component in the Component column of the hierarchy.

    The Selected Configuration field for the component is set to unset by default. With this setting, you can directly add the control variables required by the component in the Control Variables table of the top-level configuration and update them with any valid custom value.

  • To use an existing named configuration, select it from the list in the Selected Configuration column. This action adds the control variables defined in that configuration to the top-level model configuration.

    Note

    In the Control Variables table of a top-level variant configuration, the control variables that are populated using a referenced component configuration are read-only and appear with a gray background color.

  • To close the tab, click Hide Component Configurations in the Control Variables section.

  • After selecting component configurations, you can use any of these options in the Manage tab to save or revert your changes:

    • To apply the changes to the base workspace or data dictionary of the model, click Apply changes.

    • To reload the variant configuration object from the base workspace or data dictionary used by the model, click Reload object. This allows you to revert the changes that are not yet exported to the data sources used by the model.

    • To permanently save the changes in the variant configuration data object to a file, click Export to file.

Tip

A Component defines its own configuration icon next to a component in the Component column indicates that it has predefined variant configurations.

Clear Selected Variant Configuration

You can unset the variant configuration that you specified for a referenced component from the Component Configurations tab. This action does not remove the control variables added to the top-level configuration previously.

To unset the variant configuration for a referenced component, in the Component Configurations tab, in the Selected Configuration column, select unset. In the Control Variables table, the control variables populated from this configuration become editable.

Component Configurations View Example

In this example, the External Plant component has two predefined configurations, HighFid and LowFid. Selecting one of them adds or updates the corresponding control variable, FidType, in the top-level model configuration, NonLinExterLowFid. Selecting unset allows you to provide custom values.

Component Browser pane

Validate That Top-Level Model Uses Referenced Component Configuration

For a referenced model that has predefined variant configurations of its own, you can detect when a top-level model does not use one of these configurations to set up its own variant configurations. You can use the model configuration parameter Variant configuration not used by top model for a referenced model to specify the diagnostic action to take for such a scenario. This setting helps you to verify that the referenced model is used only for its tested variant configurations.

  1. To open the Configuration Parameters dialog box, in the Simulink Editor, on the Modeling tab, click Model Settings.

  2. Click the Diagnostics pane in the tree on the left side of the dialog box.

  3. Point to the ellipsis toward the bottom of the dialog box and click Advanced parameters.

  4. In the Modeling issues related to variants section, select the required option for the Variant configuration not used by top model parameter.

Diagnostics pane in the Configuration parameters dialog box

Related Topics