This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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.

  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

  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 Visualize and Animate Simulations for the 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.

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.

  • 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.

  • 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.

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

  • 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.

Visualize and Animate Simulations

These tools help you explore various elements of a SimEvents model.

Items to ObserveVisualization Tool and Its Purpose

Statistics

  • Simulation Data Inspector — Show the statistic throughout the simulation. For more information, see Inspect and Analyze Simulation Results (Simulink).

  • Simulink To Workspace block — Write the data set to the MATLAB workspace when the simulation stops or pauses.

  • Simulink Scope block — Create a plot using the statistic.

  • Simulink Display block — Show the statistic throughout the simulation.

  • Simulink To File block — Write the data set into a MAT-file.

  • Simulink Dashboard Scope block — Create a plot using the statistic.

Entities passing through model

Entity animation

Display > SimEvents Animation — Highlight active entities in the simulation.

Step of a Simulation

Simulink Simulation Stepper — Step forward and back through a simulation. For more information, see Use Simulation Stepper (Simulink).

Custom animation

Use SimEvents custom visualization API — Create custom observers of the entities and events in a model. For more information, see Interface for Custom Visualization.

Note

The Simulink Floating Scope does not support SimEvents models.

Simulation Data Inspector is a unified user interface for viewing both entities and signal (for example, statistics) data. For more information, see Inspect and Analyze Simulation Results (Simulink).

During simulation, animation provides visual verification that your model behaves as you expect. Animation highlights active entities in a model as execution progresses. You can control the speed of entity activity animation during simulation, or turn off animation. In the Simulink editor, select Display > SimEvents Animation Menu, then select:

  • Fast

  • Medium

  • Slow

  • None

The Fast animation speed shows the active highlights at each time step. To add delay with each time step, set the animation speed to Medium or Slow. To turn off animation, in the Simulink editor, select Display > Message Animation > None.

Animation is disabled by default in SimEvents models.

Explore the System Using the Simulink Simulation Stepper

Simulation Stepper enables you to step through major time steps of a simulation. Use this tool to explore your discrete-event system. For more information, see Simulation Stepper (Simulink).

Information About Race Conditions and Random Times

You can vary the processing sequence for simultaneous events or make the intergeneration times or service times random.

See Also

| | |

Related Topics