Extend Existing Test Cases by Reusing Model Representation
This example shows how to avoid unneeded model representation builds when reanalyzing a model. Consider a case where you perform test generation and the analysis exceeds maximum analysis time. In the specified analysis time, Simulink Design Verifier analyzes some objectives and saves the generated test cases in a MAT-file.
To reanalyze the model, you update the maximum analysis time and select the extend existing test cases option. To speed up the analysis, set the Rebuild model representation option to
If change is detected. Simulink Design Verifier reanalyzes the model by reusing the model representation. For more information, see Model Representation for Analysis.
Step 1. Open the model and specify analysis options
Generate test cases for
sldvdemo_cruise_control model by specifying the
model = 'sldvdemo_cruise_control'; open_system(model); opts = sldvoptions; opts.Mode = "TestGeneration"; opts.MaxProcessTime = 10; opts.RebuildModelRepresentation = "IfChangeIsDetected";
Analyze the model by using this command.
[ status, files ] = sldvrun('sldvdemo_cruise_control', opts, true);
The Diagnostic Viewer window displays the Test Generation analysis error.
Simulink Design Verifier has exceeded the maximum processing time. You can extend the time limit by modifying the "Maximum analysis time" edit field on the Design Verifier pane of the configuration dialog or by modifying the "MaxProcessTime" attribute of the options object.
After the analysis is completed, the Results Summary window displays the results. The software reports
22/24 objectives as satisfied and
2/24 objectives as undecided.
Step 2. Reanalyze the model by modifying the sldvoptions
To reanalyze the model, you select the extend existing test cases option and update the maximum analysis time. The Rebuild model representation option is set to
If change is detected. The software validates the cache model representation, detects no change, and reuses the model representation for analysis.
opts.MaxProcessTime =500; opts.ExtendExistingTests='on'; opts.IgnoreExistTestSatisfied = 'on'; opts.ExistingTestFile=files.DataFile; sldvrun('sldvdemo_cruise_control', opts, true);
The results show that
24/24 objectives are satisfied and no additional test cases are generated.
Close the model.