Main Content

Reduce a Variant Model for Selected Variant Configuration

A variant model can have multiple variant configurations associated with it. Each configuration represents a combination of variant control values that activates a specific variant choice. You can generate a reduced version of a variant model that represents a single variant configuration using the Variant Reducer. A Simulink® Design Verifier™ license is required to reduce your model. This example shows how to reduce a model programmatically and using the Variant Manager.

Explore the Model

Open the model slexVariantReducer. The model contains a Variant Source block, a Variant Sink block, and a Variant Subsystem block with these variant choices:

  • Variant Source: V==1 and V==2

  • Variant Sink: W==1, W==2, and W==3

  • Variant Subsystem: V==1 and V==2

On the Modeling tab of the Simulink® toolstrip, select Model Explorer > Model Properties > Callbacks. The PostLoadfn callback function of the model defines the variant control variables V and W and loads the slexVariantReducer_config.mat file.

The model has two predefined variant configurations, named config1 (V==1 && W==2) and config2 (V==2 && W==2). These configurations are saved in a variant configuration data object, slexVariantReducer_config, which is in turn saved in the slexVariantReducer_config.mat file.

open_system('slexVariantReducer');

Reduce the Model from Variant Manager

  • To open the Variant Manager, right-click the variant badge on any of the variant blocks and select Open in Variant Manager. The Variant Manager shows the predefined variant configurations.

  • Click Reduce Model. The Variant Reducer dialog box opens. Select the Specify variant configurations option and select the configuration to be retained in the reduced model from Named Configurations.

  • Click Reduce. The reduced model for the required configuration is created. If the model contains resolved library links or referenced models, the corresponding parent is reduced for the specified configuration and is referenced in the model. The reduced model, reduced referenced model, and the reduced library get their names from the corresponding model, referenced model, or the library with _r (model suffix) appended to it.

Reduce Model Programmatically

To reduce the model programmatically, execute these steps in the MATLAB® Command Window:

% %Generate the reduced model for the configuration config1 to the default
% %output folder, reducedModel.
  Simulink.VariantManager.reduceModel...
  ('slexVariantReducer','NamedConfigurations', {'config1'});
  cd ./reducedModel;
  open_system('slexVariantReducer_r');
Successfully created reduced model
'/tmp/Bdoc21a_1606923_176263/tpfc98c21a/ex21847392/reducedModel/slexVariantReducer_r.slx'.

See Also