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.
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.
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
SystemLoggingInfoproperty of the
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 fast restart.
Simulator = fastRestart(Simulator,'on');
Create an optimization cost function,
myCostfcn, and pass
Simulatorto 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
optimfcn = @(param) myCostfcn(param,Simulator,Requirements);
myCostfcnis 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 fast restart settings.
Simulator = fastRestart(Simulator,'off');
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.