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.
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.
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
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.
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.
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.
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.
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.
Add two Scope blocks. Rename all the Scope blocks with descriptive names, for example, Utilization, Number of entities departed, Average Wait Server.
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.
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.
Open the example to explore simulation results.
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.
Entity Generator | Entity Queue | Entity Server | Entity Terminator