Main Content

Create a Discrete-Event Model

This example describes how to build a new SimEvents®model representing a discrete-event system. For more information about discrete-event systems, seeDiscrete-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, seeA Simple Queuing System.

AddSimEventsBlocks to a Model

  1. Open a new model window.

    On theHometab, selectNew>Simulink Modeland selectBlank Model. Save the model in your working folder asdd1.

  2. Open the SimEvents library.

    In the MATLAB®Command Window, enter

    simevents

    The main SimEvents library window appears with the blocks it contains.

  3. 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 theScopeblock. 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.

    Blocks used in this example model

Configure Blocks

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:

  1. Double-click theEntity Generatorblock. Observe that thePeriodparameter is set to1. This means that the block generates a new entity every second. A tank arrives at the station every second.

  2. Double-click theEntity Serverblock. Observe that theService timeparameter is set to1.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.

    ThePeriodandService timeparameters have the same value, which means that the server completes servicing the entity at the same time that a new entity is being created.

  3. ClickCancelin both dialog boxes to close them without changing any parameters.

  4. Double-click theEntity Serverblock. Click theStatisticstab to view parameters related to the statistical reporting of the block. SelectNumber of entities departed, d. ClickOK.

    TheEntity Serverblock acquires a signal output port labeledd. During the simulation, the block produces an output signal at thisdport. The value of the signal is the running count of entities that have completed their service and departed from the server.

  5. 连接Scopeblock to theNumber of entities departed, dand display the statistics (running count of entities).

  6. Double-click theEntity Queueblock. Set theCapacityparameter toInfto create a queue with infinite capacity and clickOK.

  7. 连接blocks as shown and save thedd1model 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.

  8. Simulate the model.

A Simple Queuing System

Open the example to investigate a simple queuing system that generates, queues, services, and terminates entities.

Results of the Simulation

When the simulation runs, the Simulink®Scopeblock 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.

10 entities depart the server at the end of the simulation

After an entity departs from theEntity Serverblock, the block updates its output signal at thedport.

See Also

|||

遗传代数ed Examples

More About

Baidu
map