The Variant Manager is a central tool that allows you to manage various variation points that are modeled using variant blocks in a system model.
A model hierarchy may contain several variant blocks, each with many variant choices, combinations of which correspond to particular configurations of the system. Switching between variant choices and validating them manually can be complicated and erroneous.
Use the Variant Manager to create predefined configurations for a model, and use the model under any of the configurations. You can create the configurations by combinations of different variant choices across the model hierarchy.
Using the Variant Manager, you can:
Define, validate, and visualize variant configurations.
Define and validate constraints for the model.
Specify the default active configuration.
Set control variables to either integer, enumeration
with the model.
Validate a variant configuration or model without updating the model.
Reduce a variant configuration to reduce the model.
Consider the model Variant Management. To open the Variant Manager, you can:
Right-click the variant badge and select Open in Variant Manager.
Right-click the variant block, and in the context menu, click Variant > Open in Variant Manager.
Select the variant block, and click Diagram > Variant > Open in Variant Manager.
Click Open block in Variant Manager available on the variant block's Block Parameter dialog box.
The Variant Manager window is divided into three panes:
The Variant Configuration Data pane which enables you to define variant configurations and constraints, and export them as variant configuration data objects.
The Model Hierarchy pane which enables you to visualize the variant hierarchy.
The Log pane which displays information on the source of control variables and validation errors.
Use this pane to create configurations, define control variables, associate referenced model configurations, and define constraints. The configurations and associated data are stored in a variant configuration data object.
After you add a variant configuration, type a name for the variant
configuration object in the Variant configuration object box.
You can use the drop-down menu to load a variant configuration object
from a file or refresh a loaded variant configuration object. You
can load a variant configuration object either as a
or a MATLAB script (
.m file). To store the variant
configuration object in the base workspace and associate it with the
model, click Export
. To store the variant
configuration object in a folder of your choice either as a
or a MATLAB script (
.m file), click Save
As from the drop-down menu of the Export button.
The Configurations tab is divided into upper and the lower panes. You can use the upper pane to add, delete, or copy a variant configurations. You can also set a default configuration.
The upper pane has these buttons to manage a variant configuration.
|Add variant configuration|
|Delete variant configuration|
|Duplicate variant configuration|
|Set/Clear default active configuration|
After a variant configuration is added, you can use the lower pane on the Configurations tab to add a description, control variables, and the submodel configurations for it. You can add control variables and export them to the base workspace even when a variant configuration is not added. The lower pane contains these tabs:
Description — Provide a description for the selected variant configuration.
Control Variables — Add, delete, copy or import control variables. Toggle data type and import control variables from the workspace.
Add control variable
Delete the selected control variable
Create a copy of the selected control variable
Toggle type of a control variable
variable can be either a character vector or a
Import control variables from base workspace
Submodel Configurations — Define variant configuration for a referenced model.
Add or delete a referenced model configuration.
To refresh and activate the variant model for a configuration, select a configuration from the list of Configurations and click Activate. If you click the Activate button without selecting any configuration, the values for the Control Variables are picked from the base workspace. For such cases, the Control Variables that are defined in the Variant Manager overrides the corresponding values in the base workspace.
When you open the Variant Manager for a parent model that contains
referenced models (Submodel), only the parent model is validated.
The referenced models (Submodel) are validated only when you activate
or expand (click
+) the reference models.
Use the Constraints tab to add or delete the model-level constraints. Similar to the Configurations tab, the Constraints tab also contains upper and lower panes.
The upper pane displays the name and condition of the constraints while the lower pane displays the description. The condition expression of the constraint must be satisfied by all variant configurations in the model.
You can visualize and explore the variant hierarchy of a model and edit the properties of variant blocks, variant choices, and variant objects from the Model hierarchy pane. This pane displays the Name, Submodel Configuration, Variant Control, and associated Conditions of variant objects used as variant controls.
Browse the hierarchy using the navigation icons. The controls on the Model hierarchy pane allow you to perform the following actions:
Refresh and validate hierarchy.
Display only variant blocks.
Navigate among active, invalid, and overridden variant choices.
Selectively display blocks in the variant hierarchy:
Select Model and variant blocks to display only model reference and variant blocks.
Select All hierarchical blocks to display all hierarchical blocks in the model.
The model hierarchy is displayed in a tree, with each block representing a node in the hierarchy. The hierarchy displays active, inactive, overridden, and invalid variants. You can edit referenced model configurations, variant controls, and variant conditions. Expand nodes to view the underlying blocks.
Note: Protected reference models cannot be viewed in the hierarchy.
The hierarchy table consists of these columns:
Name — Name of the model or block.
Submodel Configuration — Configurations used by referenced models. You can only edit the Submodel Configuration for rows that display models referenced by the top model.
Variant Control — Variant control parameter of a variant choice. This column is identical to the Variant Control column of the parameter dialog box of variant blocks. You can edit this column for variant choices across the hierarchy.
Condition — Displays and
allows you to edit the condition for the
when it is used as variant control. You can edit this column for variant
choices across the variant hierarchy.
Tip: Right-click the item on the hierarchy table and use the Override using this Choice or the Open Parent Block Parameters options on the context menu, as necessary.
In the model hierarchy section, each block is represented with an icon. The following table displays the icons and the corresponding block name.
Inline Variants Block (Variant Source and Variant Sink)
Variant Subsystem block
Model Variant block
Simulink® Function block
Function Caller block
Variant Sink output port
Variant Source input port
Variant Subsystem block with Propagate conditions outside of variant subsystem option selected.
Variant Subsystem block with Analyze all choice during update diagram and generate preprocessor conditionals option selected.
Variant Subsystem block with Override variant conditions and use the following variant option selected.
Variant Subsystem block with Propagate conditions outside of variant subsystem and Analyze all choice during update diagram and generate preprocessor conditionals options selected.
Variant Subsystem block with Propagate conditions outside of variant subsystem and Override variant conditions and use the following variant options selected.
Inline Variants Block (Variant Source and Variant Sink) with Allow zero active variant control option selected.
Inline Variants Block (Variant Source and Variant Sink) with Override variant conditions and use the following variant option selected.
Inline Variants Block (Variant Source and Variant Sink) with Analyze all choice during update diagram and generate preprocessor conditionals option selected.
Inline Variants Block (Variant Source and Variant Sink) with Allow zero active variant control and Analyze all choice during update diagram and generate preprocessor conditionals options selected.
Initialize Function block
Event Listener block of Initialize Function block
Reset Function block
Event Listener block of Rest Function block
Terminate Function block
Event Listener block of Terminate Function block
The Log pane displays information and validation results of the source of control variables for the models in the hierarchy.
For example, if a variant configuration is used for a referenced model, the referenced model name is displayed in the row along with name of the variant configuration data object and variant configuration. The pane also displays errors encountered during validation of the variant configuration.