Main Content

Verify and Validate Variant Models with Startup Activation Time

This example shows how to verify and validate variant models with startup variant activation time using and Simulink Test.

The startup variant with the fast restart workflow allows you to switch the active variant choice in each iteration without the need to recompile the model to change the active variant. You can create parameter sets with different variant configurations in fast restart mode to test your systems without needing to recompile the model. To make the Simulink Test workflow iterative, use the startup variant activation time and run the test iterations in fast restart.

Model

Open the model slexStartupVariantVnVWorkflow. The model contains a Variant Subsystem block, ComputeTargetSpeed, with two variant choices, ComputeTargetSpeed_Config1 and ComputeTargetSpeed_Config2. To launch the Simulink Test Manager, click the Open Simulink Test Manager button in the model. The Simulink Test Manager is launched with predefined tests cases for the slexStartupVariantVnVWorkflow model. To run each parameter set iteratively across the selected baseline, click Run. Once the test runs successfully, you will notice that the model output matches the expected output.

Start Test Manager

To setup and run the test iterations in Fast restart and compare the model output with the expected output, follow the steps in this tutorial.

1 Open the model, slexStartupVariantVnVWorkflow.

  open_system('slexStartupVariantVnVWorkflow');

2 To start Test manager, on the Apps tab, under Model Verification Validation, and Test click on Simulink Test. On the Tests tab, click Simulink Test Manager.

Associate Model and Test Harness

Test suites contain one or more test cases and the default test case is a baseline test. Create a test suite and a new baseline test.

1 From the Test Manager toolstrip, select New > Test Suite. Right click on Test Suite to create a new Baseline Test.

2 Set the test case to use the model. In the above example, the model in use is slexStartupVariantVnVWorkflow. In Test Manager, under System Under Test, click the Use current model button.

3 Select the slexStartupVariantVnVWorkflow_mdlHarness from the Harness drop down under Test Harness.

Create Parameter Sets

Create parameter sets and add the variant control variable with the respective value. Each parameter set aligns with a specific variant control value. In the above example,there are two parameter sets corresponding to the variant control expressions speedConfig = 1 and speedConfig = 2. To override a model parameter,

1 Expand the Parameter Overrides section in the test case and click Add.

2 Click on update diagram to get model parameters.

3 Select the variant control parameter from the list. In the above example, it is speedConfig.

Simulink Test Manager allows iterations in the Iterations section of the test case. The Table Iterations provide a quick way to add iterations based items in your model or test case. Click on Auto-generate the iterations. Select the Parameter Set option from the list.

Capture Baseline

When a baseline test case executes, the Test Manager captures signal data from signals in the model marked for logging and compares them to the baseline data. You can capture the baseline test outputs in Test Manager as an Excel® file or a MAT-file. Alternatively, you can add an external file to the test case as the baseline. In the test case under Baseline Criteria, click Capture and select the option Capture Baselines for Iterations. Specify the path to the iterations. In the above example,the path to DisengageWithDisable has been specified. Notice that the Baseline gets populated in the Table Iterations corresponding to each parameter set.

Run the Baseline Test

Baseline tests compare the outputs from a simulation against the expected outputs. Ensure you have selected the Run Test Iterations in Fast Restart in the Table Iterations section. To run each parameter set iteratively across the selected baseline, click Run.