Browser width
is too narrow.

Rotate the screen
or increase
the width.
OpenSIMPLY Free open source simulation software
▲

Simulation model of the M/M/1 queuing system

This system is a classic example of queuing theory and is a complicated M/M/1 loss system.

Queue

The concept of queue has the following parameters: capacity, timeout and discipline.

The queue capacity is the total number of entities that the queue can accommodate.

The queue timeout is the maximum amount of time an entity can wait in a queue.
Schematic representation of a queue in queueing theory

Queue discipline

The queue discipline determines how entities arriving at the queue input will be ranked in a non-empty queue.

It is assumed that the queue output is connected to a block that can accept entities if it is idle, and cannot accept entities if it is busy. For example, such a block could be a server.

If the queue is empty but the block is busy, the entity arriving at the queue input becomes first in the queue. The same happens if the queue is empty but the queue output is not connected to any block.

If the queue is empty and the block is idle, an entity arriving at the queue input is immediately passed to the queue output.

If the queue is not empty, the entity arriving at the queue input is placed in the queue according to the queue discipline.

If a block changes its status from busy to idle, it requests the queue to pass the entity, and if the queue is not empty, the entity first in the queue is passed to the block.
Queue discipline

FIFO queue discipline

FIFO stands for "First-In, First-Out".

This means that the entity first arriving at the queue input is the first to be retrieved from the queue output (e.g. for servicing).

In case of M/M/1 queuing system the idle server informs the queue about its status, and if the queue is not empty, the certain entity according with the queue discipline is passed further to the server.
FIFO queue discipline

The M/M/1 queuing system in terms of queuing theory

The system consists of a queue and a server.

Entities arrive at a queue according to a Poisson process and are then passed to the server. Service time is exponentially distributed.

The queue capacity and timeout for the M/M/1 queue are assumed to be infinite.

The queue discipline in this system is assumed to be FIFO.

Formally, the correct notation should be M/M/1 FIFO queue.

The characteristics under study are the queue probability, mean waiting time and mean queue length.

Watch the learning video about the M/M/1 queuing system.
 
M/M/1 queuing system

The model of the M/M/1 queuing system in terms of OpenSIMPLY

This example is only a bit more complicated than the M/M/1 loss system example.

In addition to the Generator block to simulate arriving entities and the Server block to simulate entity service, the model of the M/M/1 queuing system requires the Queue block to simulate queue discipline.

In Delphi and Free Pascal, these blocks are represented by the TGenerator, TServer and TQueue classes, respectively.

Download executable models of queuing theory and call centers.
 
OpenSIMPLY block model of the M/M/1 queuing system

Model creation

The variables Gen, Que and Srv will be used for instances of the classes TGenerator, TQueue and TServer, respectively.

The Queue block has the following defaults for initial values:
  • InfiniteCapacity for the Capacity item
  • InfiniteTimeout for the Timeout item
  • FIFO for the Discipline item


So, when creating the Queue block with the defaults, it is not necessary to explicitly specify the initial values.

Model parameters

The following variables and functions will be used for the initial values of the blocks.
  • Capacity: to specify the total number of entities for simulation (Generator)
  • InterarrivalTime: to specify the mean value between entities arrivals (Generator)
  • ServiceTime: to specify the mean value of service time (Server)
  • ExpTime: a block function that returns exponentially distributed random values

Model behavior

The lines below fully describe the behavior of M/M/1 queuing system model in terms of OpenSIMPLY:

Gen := TGenerator.Create([Capacity, ExpTime, InterarrivalTime]);    //  Creating a Generator.

Que := TQueue.CreateDefault;                                        //  Creating a Queue with default initial values. 

Srv := TServer.Create([ExpTime, ServiceTime]);                      //  Creating a Server.

Gen.Connect(Que);                                                   //  Connecting Generator to Queue.

Que.Connect(Srv);                                                   //  Connecting Queue to Server.


To compile a model, the code above should be placed in a standard wrapper of a model as in the M/M/1 system example.
 

Complete program code containing input data and output of results.

program MM1queue;
{$apptype xxx }  // xxx "GUI" or "Console" 
{$S-}
uses
  SimBase,
  SimBlocks,
  SimStdGUI;
  
type
  TMyModel = class(TModel)     //  Model declaration.  
    procedure Body; override;
  end;

var 
  Capacity,                    //  Model parameters.  
  NumberOfServers: Integer;
  InterarrivalTime,
  ServiceTime: Double;

procedure TMyModel.Body;       //  Model description.
var                            
  Gen: TGenerator;             //  Blocks declaration. 
  Que: TQueue;  
  Srv: TServer; 
begin                          //  Model behavior.

  Gen := TGenerator.Create([Capacity, ExpTime, InterarrivalTime]);
  Que := TQueue.CreateDefault;                 
  Srv := TServer.Create([ExpTime, ServiceTime]);
  Gen.Connect(Que);
  Que.Connect(Srv);

  Run(Gen);                    //  Launching the start block.

  Que.ShowStat;                //  Results.
end; 

begin
  Capacity := 3000;            //  Initial values of the model.
  InterarrivalTime := 1;
  ServiceTime := 1.3;
  
  Simulate(TMyModel);          //  Starting a model.
end.


To validate the M/M/1 queuing system model, the simulation results can be verified using the exact formula. The value of queue probability can be obtained with Erlang C formula.

See also the model of the M/M/∞ queuing system with an infinite number of servers.