Reduce Variant Models Using Variant Reducer
The Variant Reducer tool in the Variant Manager for Simulink® lets you simplify complex models that contain variant blocks and parameters by generating a standalone model with selected configurations. You can manage different system design variations within a single model using variant source, sync, and subsystem blocks. Reduction can be based on predefined configurations, control values, or current workspace values. Additional options include choosing compile modes for code generation, selecting an output folder, excluding certain files from modification, and deciding whether to preserve signal attributes. A detailed summary can be generated to track changes, and the Variant Reducer automatically updates the working folder and opens the reduced model, which reflects the active configurations and parameters. Generating the summary report requires a Simulink Report Generator™ license.
Published: 31 Jan 2024
This video shows you how to reduce a variant model using the Variant Reducer tool that is available in the Variant Manager for Simulink Software Support Package. In Simulink, variant blocks and variant parameters allow you to represent all possible design variations of a system in a single model. This model uses three types of variant blocks-- a Variant Source block, used to select one input from multiple inputs; a Variant Sync block; used to select one output from multiple outputs; and a Variant Subsystem block, used to represent different choices in a separate hierarchy.
From this original model, you can generate a simplified standalone model that contains only a subset of the variant configurations using the Variant Reducer tool. To open Variant Reducer, launch Variant Manager for the model. If you have not installed the Variant Manager for Simulink Support Package, you will be prompted to do so.
Open Variant Reducer from Variant Manager. Choose a reduction mode. A reduction mode provides multiple ways to specify the configurations you want to retain in the reduced model. To select from the predefined variant configurations for the model, select Specify Variant Configurations. Then, select the desired configurations from the Configurations panel.
If your model does not have variant configurations defined, Variant Reducer uses the Specify Variant Control Values mode by default. You can create variable groups that represent the configurations to be retained. For each variable group, specify the values for the variant control variables as scalars or vectors. Select Full Range to let Variant Reducer consider all valid values of the variant control variable. Select Ignored if a variable should not be considered.
You can also reduce the model based on the variant control variable values in the workspace used by the model by selecting Current Variant Control Values. This example shows reduction results for the named configuration, config1. Selecting a compile mode is useful if variant blocks in your model use the sim codegen Switching Variant Control mode. For such a model, if you want to retain the code generation branches of the blocks in the reduced model, change the Compile mode to codegen.
Specify additional reduction options as needed. You can select an output folder outside the MATLAB root folder to store the reduced model and related artifacts. If there are any model data dictionary or map files that should not be modified or copied to the output folder after reduction, you can exclude them from the process. If needed, the reduced model will refer to these files from their original location.
Use the Preserve Signal Attributes option to attempt to preserve the compiled signal attributes, such as data type and dimension between the original and reduced models. To understand the modifications made to the model or any manual updates that might be required in the reduced model, generate a detailed summary of the reduction process. By default, Variant Reducer removes the outer layer of a variant subsystem block when only one choice of the variant subsystem remains active in the reduced model.
To retain the variant subsystem block, clear the Remove Variant Subsystem Layer checkbox. Reduce the model. Variant Reducer changes the current working folder to the output folder and opens the reduced model. The reduced model retains the active parts for the specified configurations from the input model. If your model contains variant parameters, they are also reduced to retain only the active choices. You need a Simulink Report generator license to generate the summary report. To compare the original and reduced models, navigate to their interactive views or use the text summary.