Use Fast Restart Mode During Sensitivity Analysis
This topic shows how to speed up sensitivity analysis using Simulink® fast restart. You can use the fast restart feature to speed up sensitivity analysis of tunable parameters of a model.
Fast restart enables you to perform iterative simulations without compiling a model or terminating the simulation each time. Using fast restart, you compile a model only once. You can then tune parameters and simulate the model again without spending time on compiling. Fast restart associates multiple simulation phases with a single compile phase to make iterative simulations more efficient. You see a speedup of design optimization tasks using fast restart in models that have a long compilation phase. See How Fast Restart Improves Iterative Simulations.
When you enable fast restart, you can only change tunable properties of the model during simulation. For more information about the limitations, see Limitations.
You can perform sensitivity analysis using fast restart in the Sensitivity Analyzer or at the command line.
Sensitivity Analyzer Workflow for Fast Restart
To evaluate a model using fast restart in the Sensitivity Analyzer:
Open the Simulink model.
Enable fast restart in the model.
Click Fast Restart in the model window.
Open the Sensitivity Analyzer for the model.
Specify the parameter set, generate parameter samples, and specify the requirements for sensitivity analysis. Optionally, specify evaluation settings. For example, see Design Exploration Using Parameter Sampling (GUI) and Identify Key Parameters for Estimation (Code).
Click Evaluate to evaluate the model in fast restart mode. The design requirements are evaluated for each combination of parameter values in your parameter set.
Disable fast restart.
In the model window, click Fast Restart .
Command-Line Workflow for Fast Restart
You can use sensitivity analysis to evaluate which model parameters most influence a cost function. You can use these parameters during parameter estimation or response optimization. Suppose that you want to use sensitivity analysis to reduce the number of parameters that you need to estimate to fit a model.
To evaluate the model in fast restart mode using a cost function aimed at parameter estimation:
Open the Simulink model.
Specify the model parameter values,
params
, to estimate and generate parameter samples,params_samples
. For an example, see Identify Key Parameters for Estimation (Code).Create an experiment object,
Exp
.Exp = sdo.Experiment("model");
Store the measured input-output data in
Exp
. For an example, see Identify Key Parameters for Estimation (Code).Create a model simulator from the experiment.
Simulator = createSimulator(Exp);
Simulator
is ansdo.SimulationTest
object.Note
You must create a simulation scenario with logging information before configuring the model for fast restart. You cannot modify logging information once the model has been compiled for fast restart.
Configure the model and simulation scenario for optimization and enable fast restart.
Simulator = setup(Simulator,FastRestart="on");
Before R2024a: Enable and disable fast restart using the
fastRestart
function.Create a cost function,
myCostfcn
, and passSimulator
to the cost function as an input. For more information, see Write a Cost Function. In the cost function, the simulator configured for fast restart is used to update the model parameters, simulate the model, and log signals.Use an anonymous function with one argument that calls
myCostfcn
.evalfcn = @(param) myCostfcn(param,Simulator,Exp);
Evaluate the model.
[param_opt,opt_info] = sdo.evaluate(evalfcn,param,param_samples);
Restore the simulator fast restart settings.
Simulator = restore(Simulator);
The fast restart workflow is similar for sensitivity analysis that identifies design variables using a cost function aimed at response optimization. See Use Fast Restart Mode During Response Optimization.
Troubleshooting
Why Don’t I See the Evaluation Speedup I Expected Using Fast Restart?
You see a speedup of design optimization tasks using fast restart in models that have a long compilation phase. If the compilation phase of your model is not long, you do not see a significant change in estimation speed.
See Also
sdo.SimulationTest
| sdo.evaluate
| setup
| restore