This example describes how to build a new model representing a discrete-event system. The system is a simple queuing system in which “customers” — entities — arrive at a fixed deterministic rate, wait in a queue, and advance to a server that 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 a deterministic arrival rate, a deterministic service rate, and a single server.
The example system shows how to perform basic model-building tasks, such as:
Adding blocks to models
Configuring blocks using their parameter dialog boxes
On the Home tab, select New > Simulink Model. An empty model window opens.
To name the model and save it as a file, select File > Save from the model window's menu. Save the model in your
working folder as
In the MATLAB® Command Window, enter
The main SimEvents® library window appears. This window contains an icon for each SimEvents library. To open a library and view the blocks it contains, double-click the icon that represents that library.
In the Simulink® editor, click the Library Browser button. The Simulink Library Browser opens, using a tree structure to display the available libraries and blocks. To view the blocks in a library listed in the left pane, select the library name, and the list of blocks appears in the right pane. The Library Browser provides access not only to Simulink blocks but also to SimEvents blocks.
To move blocks from libraries into the model window, follow these steps:
In the SimEvents library window, drag the Entity Generator block from the library into the model window.
Drag the Entity Queue block into the model window.
Drag the Entity Server block into the model window.
Drag the Entity Terminator block into the model window.
From the Simulink Sinks library, drag the Scope block into the model window.
As a result, the model window contains blocks that represent the key processes in the simulation: blocks that generate entities, store entities in a queue, serve entities, and create a plot showing relevant data.
Each block in a model, in this case,
has a dialog box that enables you to specify block parameters. Default
parameter values might or might not be appropriate, depending on what
you are modeling.
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
to open its dialog box. Observe and that the Period parameter
is set to
1. This means that the block generates
a new entity every second.
Double-click the Entity Server block
to open its dialog box. 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.
Click Cancel in both dialog boxes to dismiss them without changing any parameters.
The Period and Service time parameters have the same value, which means that the server completes an entity's service at exactly the same time that a new entity is being created.
Configure blocks to create a plot that shows when each entity departs from the server, and to make the queue have an infinite capacity.
Double-click the Entity Server block to open its dialog box.
Click the Statistics tab to view parameters related to the statistical reporting of the block.
Select Number of entities departed, d.
Then click OK. The Entity Server block acquires a signal output port labeled d. During the simulation, the block will produce an output signal at this d port; the signal's value is the running count of entities that have completed their service and departed from the server. You can connect a Scope block to this entity line and display the statistics (running count of entities).
Double-click the Entity Queue block to open its dialog box.
Set the Capacity parameter to
The model window now contains blocks that represents key processes.
Connect the blocks as shown and save the
you have created.
SimEvents connects the source block to the destination block. If necessary, the software also routes the connecting line around intervening blocks or lines.
To start the simulation, select Simulation > Run from the model window's menu.
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.
Composite Entity Creator | Composite Entity Splitter | Discrete Event Chart | Entity Gate | Entity Generator | Entity Input Switch | Entity Multicast | Entity Output Switch | Entity Queue | Entity Replicator | Entity Server | Entity Terminator | MATLAB Discrete Event System | Multicast Receive Queue | Resource Acquirer | Resource Pool | Resource Releaser