Main Content

Save SimEvents Simulation Operating Point

This example shows how to save and restore the simulation state of a SimEvents® model by using Save final operating point check box and use it as an initial state for future simulations. For more information about using Save final operating point, see Use Model Operating Point for Faster Simulation Workflow.

The Save final operating point check box is used to save the state of a simple queuing system with an Entity Generator block, an Entity Queue block, an Entity Server block, and an Entity Terminator block. The signal output port n displaying the number of entities departed the Entity Queue block is connected to a Scope block. For more information about performing basic tasks to create this model, see Create a Discrete-Event Model. The only difference in the model is the placement of the scope.

Snapshot of a simple Simulink model with an Entity Generator block connected to an Entity Queue that, in turn, connects to an Entity Server block. The Entity Server block connects to an Entity Terminator block. The Entity Queue block connects to a Scope.

  1. Open the Entity Server Block Parameters dialog box. Set the Service time value to 2.

    The queue length increases throughout the simulation because service time is larger than the entity intergeneration time.

  2. From the Simulink® Toolstrip, select Modeling tab and Model Settings. In the Configuration Parameters dialog box, in the Data Import/Export pane, select the Final states check box with the variable name xFinal and select the Save final operating point check box.

    Snapshot of the Configuration Parameters dialog box showing the Final States check box selected with variable name xFinal. The Save final operating point check box is also selected. Both these check boxes are highlighted with a red square.

  3. Simulate the model and open the Scope block. Observe that the final queue length is 6.

    The queue length increases, with spikes at times 2, 4, 6, 8, and 10 because the Service time value of the Entity Server block is 2. The entity in the Entity Server block departs, and the entity that arrives at the Entity Queue block immediately advances to the Entity Server block.

    Scope block output representing queue length, graphically.

  4. In the Configuration Parameters dialog box, select the Initial state check box and specify the variable name as xFinal.

    xFinal is used as an initial state for the next simulation.

    Snapshot of the Configuration Parameters dialog box showing the Initial State check box selected with variable name xFinal. This check box is highlighted with a red square.

  5. Increase the simulation time to 20.

    Set the simulation time larger than 10 to observe simulation with the saved initial simulation state.

  6. Simulate the model. Open the Scope block. Observe that the simulation starts from the queue length 6, which is the final state of the previous simulation.

    Scope block output representing queue length, graphically.

See Also

| | |

Related Topics