M/M/c/K Queue Simulation Model
Theoretical Background
This queuing system provides a more realistic representation of real-world systems, as it limits the queue size.
It is a natural extension of the
M/M/c system.
What remains the same as in the
M/M/c:
- Entities arrive at the queue according to a Poisson process and are served in
FIFO order.
- Entities from the queue are assigned to one of the c servers.
- If an idle server is found, the entity is passed to it, otherwise the entity is placed in a queue.
- If several servers are idle, one of them is selected at random.
- The service time of any server is exponentially distributed.
The key difference is that the queue capacity is finite.
If the queue is full, arriving entities are lost (blocked).
The
K in
M/M/c/K denotes the number of waiting places.
The characteristics under study are the
blocking probability,
probability of waiting,
mean waiting time, and
mean queue length.
Since the method of selecting an idle server does not affect the characteristics of interest, any selection rule can be applied (not necessarily random).
Model in OpenSIMPLY
This model uses the same blocks as the
M/M/c model: Generator, Queue, Selector and Server.
The Generator and Server blocks are described in the
M/M/1/1 model example.
The Selector block is described in the
M/M/c model example.
The Queue block is described in the
M/M/1 model example.
Since you can specify the queue capacity as the first item of
InitialValues parameter,
the same
TQueue class is used to simulate both queue types with infinite and limited capacities.
Since FIFO is the default discipline for the Queue block, it does not need to be specified explicitly.
In Delphi and Free Pascal, these blocks are represented by the classes
TGenerator,
TQueue,
TSelector and
TServer, respectively.
Download executable model of the
M/M/c/K queue as almost real call center.
Model Creation
The
QueueCapacity variable will be used to specify the queue capacity.
The Connection Rule item of the
Initial Values parameter for the
TSelector class should be specified as
RandomConnection.
However, because the method of selecting an idle server does not affect the results, the default
FirstIdleConnection value can be used instead.
Therefore, this parameter can be omitted.
The
TSelector Connect method is used in the same way as in the
M/M/c model.
Let's use the variables
Gen,
Que, and
Sel for the instances of the
TGenerator,
TQueue, and
TSelector classes, respectively.
Model Parameters
The following variables and constants will be used for the
Initial Values of the blocks.
TotalEntities — the total number of entities to be simulated during the model run.
QueueCapacity — the number of waiting places in the queue.
NumberOfServers — the number of servers in the system.
InterarrivalTime — the mean time between entity arrivals.
ServiceTime — the mean service time.
ExpTime — a pointer to a function that returns exponentially distributed random values.
Model Behavior
The code below defines the behavior of the
M/M/c/K system as an OpenSIMPLY model.
Gen := TGenerator.Create([TotalEntities, ExpTime, InterarrivalTime]); // Creating Generator.
Que := TQueue.Create([QueueCapacity]); // Creating limited capacity FIFO Queue.
Sel := TSelector.Create([NumberOfServers]); // Creating Selector with default rule.
Gen.Connect(Que); // Connecting Generator to Queue.
Que.Connect(Sel); // Connecting Queue to Selector.
Sel.Connect(1, NumberOfServers, TServer, [ExpTime, ServiceTime]); // Creating Servers and assigning them to Selector.
To compile a model, the code above should be placed in a
standard model wrapper.
Complete Program Code with Input Data and Results
program MMCK;
{$apptype xxx } // xxx "GUI" or "Console"
{$S-}
uses
SimBase,
SimBlocks,
SimStdGUI;
type
TMyModel = class(TModel) // Model declaration.
procedure Body; override;
end;
var // Model parameters.
TotalEntities,
QueueCapacity,
NumberOfServers: Integer;
InterarrivalTime,
ServiceTime: Double;
procedure TMyModel.Body; // Model behavior.
var
Gen: TGenerator; // Blocks declaration.
Que: TQueue;
Sel: TSelector;
begin
Gen := TGenerator.Create([TotalEntities, ExpTime, InterarrivalTime]);
Que := TQueue.Create([QueueCapacity]);
Sel := TSelector.Create([NumberOfServers]);
Gen.Connect(Que);
Que.Connect(Sel);
Sel.Connect(1, NumberOfServers, TServer, [ExpTime, ServiceTime]);
Run(Gen); // Launching start block.
// Results.
Gen.ShowStats; // Blocking probability
Que.ShowStats; // Probability of waiting,
// mean waiting time, mean queue length
end;
begin
TotalEntities := 3000; // Initial values of model.
InterarrivalTime := 1;
QueueCapacity := 3;
ServiceTime := 1.3;
NumberOfServers := 2;
Simulate(TMyModel); // Starting model.
end.
The
M/M/c/K model is more realistic than the
M/M/c,
but applies only to certain cases where systems have limited waiting space.
See also:
This system features a queue with both limited capacity and limited waiting time.
Such a model can be used to simulate a wide range of systems, such as a barbershop or a simple call center.