Use Fast Restart Mode During Response Optimization
This topic shows how to speed up response optimization using Simulink® fast restart. You can use the fast restart feature to speed up response optimization 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 optimize using fast restart in the Response Optimizer (Not supported in Simulink Online™) or at the command line.
Response Optimizer App Workflow for Fast Restart
To optimize a model response using fast restart in the Response Optimizer:
Open the Simulink model.
Enable fast restart in the model.
Click Fast Restart in the model window.
Open the Response Optimizer for the model.
Configure the design variables, design requirements, and, optionally, optimization settings.
For more information, see Specify Design Variables for Optimization, Specify Time-Domain Design Requirements in the App, Specify Frequency-Domain Design Requirements in the App, and Specify Optimization Options.
Click Optimize to optimize the model response in fast restart mode.
Disable fast restart.
In the model window, click Fast Restart .
Command-Line Workflow for Fast Restart
To optimize a model response using fast restart at the command line:
Open the Simulink model.
Create a model simulation scenario. 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.
Simulator = sdo.SimulationTest("model");
Specify model signals to log during model simulation.
For response optimization problems that include frequency-domain requirements, the model is linearized using Simulink Control Design™. Use the
SystemLoggingInfo
property of thesdo.SimulationTest
object,Simulator
, to specify linear systems to log when simulating the model. For an example, see Design Optimization to Meet Frequency-Domain Requirements (Code).Specify design requirements,
Requirements
, and design variables,param
. For and example, see Design Optimization to Meet Step Response Requirements (Code).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 an optimization 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
.optimfcn = @(param) myCostfcn(param,Simulator,Requirements);
Here,
myCostfcn
is a cost function that takes design variables,param
, simulation scenario,Simulator
, and design requirements,Requirements
, as inputs.Run the optimization.
[param_opt,opt_info] = sdo.optimize(optimfcn,param);
Restore the simulator and model settings modified by the
setup
function, which includes disabling fast restart.Simulator = restore(Simulator);
Troubleshooting
Why Don’t I See the Optimization 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 optimization speed.
See Also
sdo.SimulationTest
| sdo.optimize
| setup
| restore