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.
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 .
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 .
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.
double-click the entity queue block. set capacity to
inf
. click the statistics tab, set average wait toon
, 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
, or1.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
or1.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.
see also
| | |