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 model to retain subset of variant configurations.
Analyze variant configurations.
For information on analyzing variant configurations from Variant Manager, see
Analyze Variant Configurations in Models Containing Variant Blocks. For
information on analyzing variant configurations from command line, see
For information on analyzing variant configurations from Variant Manager, see Analyze Variant Configurations in Models Containing Variant Blocks. For information
on analyzing variant configurations from command line, see
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 in variant configuration data object.
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 from a
MAT file or a MATLAB script
.m file). To store the variant configuration object in
the model, global workspace and associate it with the model, click
. To store the variant configuration object in
a folder of your choice either as a
MAT-file or a MATLAB
.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 configuration. You can also set a default configuration. When you set a configuration to be default configuration, validating or updating the model activates the variant choice specified in the 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 global 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
A control variable can be either a plain
MATLAB variable or a
Import control variables from entire model reference hierarchy
Control variables from blocks in
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 global workspace. For such cases, the Control Variables that are defined in the Variant Manager overrides the corresponding values in the global workspace unless a default configuration is set. If a default variant configuration is set, the corresponding control variables are applied.
When you open the Variant Manager for a parent model that contains referenced models
(submodels), only the parent model is validated. The referenced models
(submodels) 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 variable usage, active choices, invalid choices, and overridden variant choices.
Selectively display blocks in the variant hierarchy:
Select Variant blocks to display all variant blocks.
Select Label mode variant blocks to display
variant blocks in
Label mode and other Model blocks.
Variant blocks in
Expression mode, which contains
Label mode within their hierarchy are also
Select Expression mode variant blocks to display
variant blocks in
Expression mode and other Model
blocks. Variant blocks in
Label mode, which contains
Expression mode within their hierarchy are
Select All hierarchical blocks to display all hierarchical blocks (for example, Subsystems, Model blocks) in the model.
Navigate among variable usage, active choices, invalid choices, and overridden choices:
Variable usage— selects the previous/next rows in the model where the selected control variable is used.
Active choices— selects the previous/next rows in the model having active variant choices.
Invalid choices— selects the previous/next rows in the model having invalid variant choices.
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.
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.
In the hierarchy table, you can Right-click a block and use one of these options from the context menu, as appropriate:
Open and Highlight Block: Highlights the selected block in the model while displaying selected block location from the top model.
Open Model: Opens the selected model while displaying selected model location from the top-model. This option is available only when you select a model from the hierarchy table.
Open Block Parameters: Opens the block parameter dialog box for the selected block. You can choose to modify the parameter values.
Open Parent Block Parameters: Opens the block parameter dialog box for the parent block of the selected block. You can choose to modify the parameter values.
Set as Label Mode Active Choice: Sets the selected choice of Variant Subsystem, or Variant Sink, or Variant Source blocks as active choice. This option is available only for the Variant Subsystem, or Variant Sink, or Variant Source blocks in label mode.
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
Variant Model block
Simulink® Function block
Trigger Port 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 choices during update diagram and generate preprocessor conditionals option selected.
Variant Subsystem block with
Variant Subsystem block with Propagate conditions outside of variant subsystem and Analyze all choices during update diagram and generate preprocessor conditionals options selected.
Variant Subsystem block with Propagate conditions outside of
variant subsystem option selected. Also,
Inline Variants Block (Variant Source and Variant Sink) with Allow zero active variant control option selected.
Inline Variants Block (Variant Source and Variant Sink)
Inline Variants Block (Variant Source and Variant Sink) with Analyze all choices 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 choices 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.