Main Content

Explore Statistics and Visualize Simulation Results

The main purpose of creating a discrete-event simulation is to understand the underlying system or inform decisions about the underlying system.

Statistical data gathered during simulation can be important for interpreting the behavior of a model. For example:

  • If you simulate the operation and maintenance of equipment on an assembly line, you can use the computed production and defect rates to help decide whether to change your maintenance schedule.

  • If you simulate a communication bus under varying bus loads, you might use computed average delays in high- or low-priority messages to help determine whether a proposed architecture is viable.

The number of entities departing a block, the average wait time of entities, utilization, and the average number of entities being served in an Entity Server block are a subset of statistics you would want to visualize.

Many SimEvents® blocks have a Statistics tab, from which you can select the relevant data.

This procedure shows you how to access a statistical output signal for a given SimEvents block.

  1. Determine which statistical output signal you want to access and find the associated parameter in the block dialog box. To see which statistics are available, open the block dialog box. The list of available statistics appears as a list of parameters on the Statistics tab of the dialog box.

    Entity Queue block window that displays supported statistics

  2. Select the check box. After you apply the change, the block has a new signal output port corresponding to that statistic.

    For example, the Entity Queue block can display:

    • Number of entities departed, d

    • Number of entities in the block, n

    • Average wait time of the entities, w

    • Average queue length of entities, l

    Entity Queue block that displays four new ports, one for each statistic

  3. To display the statistics, connect those signal output ports to a Simulink® Scope block.

    Note

    Use scopes and other observer blocks to observe individual statistic ports. However, you cannot use the same scope to observe multiple statistics ports nor use a Scope Viewer for a statistics port. To observe multiple statistic ports, consider using a dashboard or the Simulation Data Inspector.

    See Visualization and Animation for Debugging for a table showing all the visualization tools.

You can use the built-in statistical signals from SimEvents blocks to derive more specialized or complex statistics. One approach is to use a Simulink Function block, and another approach is to compute statistics using MATLAB® code after the simulation is complete. For more information about using statistics for run-time control, see Interpret SimEvents Models Using Statistical Analysis. For an example to save statistics data to workspace, see Optimize SimEvents Models by Running Multiple Simulations.

Explore a D/D/1 System Using Plots

This example shows how to modify a simple queuing system and plot statistical quantities to interpret its behavior. In the example, a dd1 queuing model, which represents the tank filling process of the vehicles arriving at a gas station, is used to view the statistics for entity waiting time and server utilization. For more information about the dd1 queuing model, see Create a Discrete-Event Model.

Simple queueing model using Entity Generator, Entity Queue, Entity Server, and Entity Terminator blocks

To open the model directly without performing the configuration steps, see Visualize and Explore Simulation Results.

View Statistics for Waiting Times and Utilization

The queue length is an example of a statistic that quantifies a state at a particular instant. Other statistics, such as average waiting time and server utilization, summarize behavior between simtime=0 and the current time. Take these steps to modify the model so that you can view the average waiting time of entities in the queue and server, and the proportion of time that the server spends storing an entity.

  1. Double-click the Entity Queue block. Set Capacity to Inf. Click the Statistics tab, set Average wait to On, and click OK.

    An output port, w, representing the average duration that entities wait in a queue appears.Connect the statistic to a scope block and rename it to Average Wait Queue.

  2. Double-click the Entity Server block. Click the Statistics tab, set both the Average wait and Utilization parameters to On, and click OK.

    Two output ports, w and util appear. w represents the average duration that entities wait in the server. util represents the proportion of time that the server spends storing an entity.

  3. Add two Scope blocks. Rename all the Scope blocks with descriptive names, for example, Utilization, Number of entities departed, Average Wait Server.

  4. Connect the util signal output port and the two w signal output ports to the in signal input ports of the unconnected scope blocks. Save the model.

  5. Simulate the model with different values of the Period parameter for the entity intergeneration times in the Entity Generator block. Observe the plots to see how they change if you set the intergeneration time to 0.3, 1.1, or 1.5, for example.

Note

Scope blocks do not support bus objects. SimEvents software supports Scope blocks with only single inputs.

Visualize and Explore Simulation Results

Open the example to explore simulation results.

Observations from Plots

  • For intergeneration time 0.3 or 1.1, the average wait time w in the Server block does not change after the first departure from the block because the service time is fixed for all departed entities. The average waiting time statistic does not include partial wait times for entities that are in the server but have not yet departed.

    Scope block that displays the average wait time. The time is 1 for the entire simulation.

  • For intergeneration time 0.3, the utilization of the server util is nondecreasing because the server is constantly busy once it receives the first entity.

    Scope block that displays the utilization. The utilization is 1 for entire simulation

  • For intergeneration time 1.5, which is larger than the service time (1), the utilization may decrease because the server has idle periods between entities.

    The Scope block that displays that the utilization. The utilization decreases over time.

  • For intergeneration time 0.3, the average waiting time w in the queue increases throughout the simulation because the queue gets longer and longer.

    The Scope block displays the average wait time. The time increases to 3.5 at time 10.

  • For intergeneration time 1.1, which is larger than the service time (1), the average waiting time w in the queue is zero because every entity that arrives at the queue is able to depart immediately.

    The Scope block displays the average wait time. The time is 0 for the entire simulation.

See Also

| | |

Related Topics