This example describes how to build a new SimEvents® model representing a discrete-event system. For more information about discrete-event systems, see Discrete-Event Simulation in Simulink Models. The example features a simple queuing system in which trucks arrive at a gas station to fill up their tanks. The tank of a truck is represented by an entity that arrives at a fixed deterministic rate, waits in a queue, and advances to a server that fills the tanks and also operates at a fixed deterministic rate. This type of system is known as a D/D/1 queuing system in queuing notation. The notation indicates the deterministic arrival rate, the deterministic service rate, and a single server.
The example shows how to perform basic model-building tasks in SimEvents— adding blocks to models and configuring blocks.
To open the model directly without performing the steps, see A Simple Queuing System.
Open a new model window.
On the Home tab, select New > Simulink Model and select Blank Model. Save the model in
your working folder as
Open the SimEvents library.
In the MATLAB® Command Window, enter
The main SimEvents library window appears with the blocks it contains.
Add blocks to the model.
From the SimEvents library, drag these blocks to the model.
Entity Generator — Generates entities to model the arrival of tanks.
Entity Queue — Stores entities in a queue to model the queuing of tanks waiting to be filled.
Entity Server — Serves entities to model the tank filling process.
Entity Terminator — Terminates entities to model the tanks' departure from the station.
In the model window, double-click and type the name of the Scope block. Press Enter to add it.
The added blocks represent the key processes in the simulation: generating entities, storing entities in a queue, serving entities, and creating a plot that shows relevant data.
Each block in a model, in this case,
dd1, has a dialog box that
enables you to specify block parameters. Default parameter values might or might not
fit your case, depending on your modeling needs.
Two important parameters in the D/D/1 queuing system are the arrival rate and service rate. The reciprocals of these rates are the duration between successive entities and the duration of service for each entity. To examine these durations:
Double-click the Entity Generator block. Observe that the
Period parameter is set to
This means that the block generates a new entity every second. A tank
arrives at the station every second.
Double-click the Entity Server block. Observe that the
Service time parameter is set to
1.0. This means that the server spends one-second
processing each entity that arrives at the block. Each tank is filled for
one second duration.
The Period and Service time parameters have the same value, which means that the server completes servicing the entity at the same time that a new entity is being created.
Click Cancel in both dialog boxes to close them without changing any parameters.
Double-click the Entity Server block. Click the Statistics tab to view parameters related to the statistical reporting of the block. Select Number of entities departed, d. Click OK.
The Entity Server block acquires a signal output port labeled d. During the simulation, the block produces an output signal at this d port. The value of the signal is the running count of entities that have completed their service and departed from the server.
Connect the Scope block to the Number of entities departed, d and display the statistics (running count of entities).
Double-click the Entity Queue block. Set the
Capacity parameter to
create a queue with infinite capacity and click
Connect the blocks as shown and save the
dd1 model you
have created. The entity path lengths do not affect the simulation.
SimEvents connects the source block to the destination block. If necessary, the software also routes the connecting line around intervening blocks or lines.
Simulate the model.
Open the example to investigate a simple queuing system that generates, queues, services, and terminates entities.
When the simulation runs, the Simulink® Scope block opens a window containing a plot. The horizontal axis represents the times at which entities depart from the server, while the vertical axis represents the total number of entities that have departed from the server.
After an entity departs from the Entity Server block, the block updates its output signal at the d port.