Main Content

How Fast Restart Improves Iterative Simulations

In a typical simulation, when you simulate a model, the software:

  1. Compiles the model

  2. Simulates the model

  3. Terminates the simulation

While developing a model, you typically simulate a model repeatedly as you iterate the design. For example, you might calibrate input values or block parameters for a particular response. Changing these values or parameters does not always require compiling the model before simulating again. However, in the classic workflow, each simulation compiles the model, even if the changes do not alter the model structurally. Each compile slows down the process and increases overall simulation time.

Fast restart allows 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 change values for root inports, values for model initial state, and from Workspace block data, tune parameters and root inputs and simulate the model again without spending time on recompiling. Fast restart associates multiple simulation phases to a single compile phase to make iterative simulations more efficient.

Use fast restart when your workflow does not require structural changes to the model. Also, fast restart is better suited if the workflow involves any of these factors:

  • The model requires multiple simulations in which simulation inputs or parameters change in every iteration.

  • The compile time of the model is several seconds or longer.

  • You need to switch solvers during runtime to pick the appropriate solvers without having to go through an expensive recompilation process.

You can use fast restart in normal and accelerator simulation modes. When you use fast restart in accelerator mode, you reduce simulation time and perform only a single compilation.

Script Fast Restart Simulations

You can use fast restart in programmatic simulation workflows and scripts you write to run simulations. You can run fast restart simulations programmatically by:

  • Running simulations iteratively, one at a time, using the sim function, the Simulation object, or a simulation command

  • Running multiple simulations as a batch using an array of Simulink.SimulationInput objects and the sim, parsim, or batchsim function

The way to use fast restart in scripts and programmatic simulations depends on which of these workflows you use.

To use fast restart for individual, iterative simulations you run one at a time, use the FastRestart parameter. The FastRestart parameter corresponds to the Fast Restart option in the Simulink® Toolstrip. Enabling fast restart using the Simulink Editor enables the FastRestart parameter. Enabling the FastRestart parameter using the set_param function enables the Fast Restart option in the Simulink Toolstrip.

You can enable fast restart for individual, iterative simulations any of these ways:

  • Use the setModelParameter function to set the FastRestart parameter on a SimulationInput object or a Simulation object.

    s = setModelParameter(s,FastRestart="on");
  • When you specify the name of the model as the first input argument for the sim function, you can specify the FastRestart parameter as a name-value argument for the sim function.

    mdl = "MyModel";
    out = sim(mdl,FastRestart="on");
  • Enable the FastRestart parameter using the set_param function.

    mdl = "MyModel";
    set_param(mdl,FastRestart="on");
  • In the Simulink Toolstrip, on the Simulation tab, click Fast Restart.

No matter how you enable fast restart for individual, iterative simulations, once you enable fast restart, the model remains compiled and initialized in fast restart after each simulation you run until you terminate the simulation. Use one of these options to terminate the simulation and disable fast restart:

  • Disable the FastRestart parameter using the set_param function.

    mdl = "MyModel";
    set_param(mdl,FastRestart="off");
  • In the Simulink Toolstrip, on the Simulation tab, click Fast Restart.

Tip

When you run simulations using the Simulation object, you can terminate the simulation and disable fast restart by calling the terminate function.

To use fast restart when you run multiple simulations as a batch using an array of SimulationInput objects and the sim, parsim, or batchsim functions, specify the UseFastRestart name-value argument as "on" in the call to sim, parsim, or batchsim. The FastRestart parameter does not apply for multiple simulation workflows. When you specify the UseFastRestart name-value argument, the software compiles the model only once per parallel worker. The last simulation on each worker terminates so that after all the simulations complete, the model is no longer initialized in fast restart, and the simulation status is inactive.

The table summarizes how to use fast restart for each programmatic simulation workflow.

Simulation WorkflowHow to Enable Fast RestartStatus After SimulationHow to Exit Fast Restart

Run individual simulations using Simulation object (since R2024a)

Set the FastRestart parameter on the Simulation object using the setModelParameter function.

mdl = "MyModel";
sm = simulation(mdl);
sm = setModelParameter(sm,FastRestart="on");
start(sm)

Model remains compiled and initialized in fast restart.

Simulation status is initialized.

Terminate the simulation using the terminate function.

terminate(sm)

Run individual simulations using the sim function and scalar SimulationInput objects (since R2024a)

Set the FastRestart parameter on the SimulationInput object using the setModelParameter function.

mdl = "MyModel";
simin = Simulink.SimulationInput(mdl);
simin = setModelParameter(simin,FastRestart="on");
out = sim(simin);

Model remains compiled and initialized in fast restart.

Set the FastRestart parameter for the model to "off".

set_param(mdl,FastRestart="off")
Run individual simulations using the sim function

Specify the FastRestart parameter as a name-value argument.

mdl = "MyModel";
out = sim(mdl,FastRestart="on");
Run multiple simulations using an array of SimulationInput objects

Use the UseFastRestart name-value argument for the sim, parsim, or batchsim function.

mdl = "MyModel":
simin(1:10) = Simulink.SimulationInput(mdl);
% Configure each simulation using 
% SimulationInput object
out = sim(simin,UseFastRestart="on");

Model is not compiled or initialized in fast restart. The last simulation terminates and disables fast restart.

Not applicable. The last simulation terminates and disables fast restart.

Limitations

  • Fast restart is not supported for rapid accelerator or external mode simulations.

  • Fast restart is not supported for model hierarchies that contain one or more referenced models configured to use a local solver. For more information, see Use Local Solvers in Referenced Models.

  • When a model is in the reinitialized state, you cannot:

    • Make structural changes.

    • Make changes to nontunable parameters such as sample time.

    • Save changes to the model. You must turn off fast restart to save any changes to the model.

  • You cannot turn on fast restart in a model if it contains blocks that do not support saving and restoring the model operating point. These blocks include:

    • SimEvents® blocks from before R2016a

    • MATLAB® function blocks that contain system objects

    • S-functions that do not implement the model operating point get and set methods but have Pwork vectors declared

    • From Multimedia File

    • To Multimedia File

    • Multipath Rician Fading Channel

    • Multipath Rayleigh Fading Channel

    • Derepeat

    • DC Blocker

    • Stack

    • Queue

    • Read Binary File

    • Write Binary File

    • Video Viewer

    • Frame Rate Display

    • Video From Workspace

    • Video To Workspace

  • You cannot turn on fast restart in a model if it directly or indirectly references a model that simulates in accelerator mode and contains Simscape™ blocks.

  • Between simulations, fast restart does not handle changes to design data, such as bus properties.

  • Parameter tunability limitations apply. See Tunability Considerations and Limitations for Other Modeling Goals.

  • The Fixed-Point Tool provides limited support when a model is simulated in fast restart. You must exit fast restart to collect simulation and derived ranges, and propose data types.

  • When there are multiple model references to the same referenced model, you cannot change the model visibility when the model is in the reinitialized state.

  • Fast restart is not compatible with the Simulink Profiler.

  • When simulating a model in fast restart, you cannot run checks using Model Advisor.

  • When you enable fast restart, the sim function supports only the single output Simulink.SimulationOutput form, regardless of the syntax you use.

  • When you enable fast restart, you cannot pass non-tunable parameters as arguments to the sim function.

  • When you simulate a model with a Subsystem Reference block in fast restart mode, any changes made in the subsystem file will not propagate to the model as they are structural changes.

Related Topics

Go to top of page