Simulation model of the M/M/1 queuing system
The M/M/1 queuing system in terms of queuing theory
It is a classic example of queuing theory.
The system consists of a queue and an single server.
Entities arrive at a queue as a Poisson process, then pass the queue and are forwarded to the server.
The service time value of the server is exponentially distributed.
The queue capacity (the number of waiting places) and the queue timeout (the maximum waiting time) are infinite.
The
queue discipline in this system is assumed to be
FIFO.
Formally, the correct notation should be:
M/M/1 FIFO queuing system.
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.
Queue discipline
The queue discipline determines how entities arriving at the queue input will be ranked in the queue if queue is not empty.
It is assumed that the output of the queue is connected to some element, hereafter a block, which can accept entities if it is idle.
If the block is busy, it cannot accept entities.
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, the 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.
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.
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 a Generator block for simulating arriving entities and a Server block for simulating servicing entities,
the
M/M/1 queuing system model requires a Queue block for simulating queue discipline.
In Delphi and Free Pascal, these blocks are represented by the TGenerator, TQueue and TServer classes, respectively.
Download executable models of queuing theory and call centers.
Model creation
The variables Gen, Que and Srv will be used for instances of the classes TGenerator, TQueue and TServer, respectively.
The default values for the Queue block for capacity and timeout is "Infinite capacity" and "Infinite timeout".
The default value of queue discipline for the Queue block is FIFO.
Therefore, when creating the Queue it is not necessary to explicitly specify the initial parameters.
Model parameters
- Capacity is the total number of entities for simulation.
- InterarrivalTime is mean value between entities arrivals.
- ServiceTime is mean value of service time.
- ExpTime is a block function returning 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 an infinite FIFO Queue.
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.