Browser width
is too narrow.

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

M/M/c Queue Simulation Model

Theoretical Background

This system is a classic example of queuing theory and traffic theory.

It is a multi-server generalization of the M/M/1 system.

In the limit as the number of servers approaches infinity, it becomes the M/M/∞ system.

Entities arrive at the queue according to a Poisson process and are served in FIFO order.

Queue capacity and queue timeout are infinite.

Entities from the queue are assigned to one of the c servers (M/M/c).

If an idle server is available, the entity is passed to it; otherwise, the entity is placed in the queue.

If several servers are idle, one of them is selected at random.

The service time of any server is exponentially distributed.

The characteristics under study are the 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).

Watch the learning video about the M/M/c queue model.
 
M/M/c queue

Model in OpenSIMPLY

The M/M/c model uses the same Generator, Queue, and Server blocks as the M/M/1 model example.

However, since entities should be distributed among the servers, the Selector block is introduced.

Selector block

Selector distributes entities arriving at its input among multiple outputs connected to subsequent blocks.

A block can be either idle or busy. (In this example, these are Server blocks.)

Selector scans the outputs to find those where a connected block is idle.

If there are at least two outputs with idle blocks connected, the Connection Rule determines which output should be selected to pass the entity.

The connection rule may be to find the first available idle block (FirstIdleConnection rule) or to select one randomly among all idle blocks (RandomConnection rule), among others.

In Delphi and Free Pascal, the Selector block is represented by the TSelector class.

The InitialValues parameter of the TSelector constructor contains one mandatory item — the first one — Capacity, which specifies the maximum number of outputs.

The second item is optional and defines the Connection Rule (FirstIdleConnection by default).

Download executable model of the M/M/c queue as an ideal call center.
 
OpenSIMPLY block simulation model of the M/M/c queue

Model Creation

Since the Queue block for the M/M/c model uses the same initial values as for the M/M/1 model, the CreateDefault constructor can be used for the TQueue class instance.

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.

Connect Blocks with Selector

The Connect method of the TServer class has a version that sequentially connects any block class instance to a connection point, but in this case an array of TServer instances would need to be created to represent the servers.

However, the TSelector Connect method has an implementation that can automatically create the required number of the specified block class instances and assign them to the specified range of Connection Points.

Selector Connect Syntax

Connect ( Lower bound, Upper bound, Block class, Initial values )

The Upper bound must not exceed the Capacity specified when creating the TSelector.

For example:

Connect (1, 2, TServer, [ ExpTime, 1.3 ] )

The InitialValues for the TServer class will be specified as parameters for the TSelector block.

This means you do not need to declare a variable for an array of TServer instances.

Model Parameters

The following variables and constants will be used for the Initial Values of the blocks.

Model Behavior

Let's use the variables Gen, Que, and Sel for the instances of the TGenerator, TQueue, and TSelector classes, respectively.

The code below defines the behavior of the M/M/c system as an OpenSIMPLY model.

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

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

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]);        //  Connecting Selector to Servers.

// The specified number (NumberOfServers) of TServer instances are automatically created,
// initialized with [ExpTime, ServiceTime], and connected to the Selector's outputs 1..NumberOfServers.


To compile a model, the code above should be placed in a standard model wrapper.
 

Complete Program Code with Input Data and Results

program MMC;
{$AppType GUI}
{$S-}
uses
  SimBase,
  SimBlocks,
  SimStdGUI;
  
type
  TMyModel = class(TModel)             //  Model declaration.  
    procedure Body; override;
  end;

var                                    //  Model parameters.
  TotalEntities,                       
  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.CreateDefault;
  Sel := TSelector.Create([NumberOfServers]);
  
  Gen.Connect(Que);
  Que.Connect(Sel);
  Sel.Connect(1, NumberOfServers, TServer, [ExpTime, ServiceTime]); 

  Run(Gen);                            //  Launching start block.

                                       //  Results.
                                       
  Que.ShowStats;                       //  Probability of waiting,
                                       //  mean waiting time, mean queue length                     
end;

begin
  TotalEntities := 3000;               //  Initial values of model.
  InterarrivalTime := 1;
  ServiceTime := 1.3;
  NumberOfServers := 2;

  Simulate(TMyModel);                  //  Starting model.
end.

Model Validation

To validate the M/M/c model, verify its results against the exact formula. Key metrics, such as the probability of waiting, mean waiting time, and mean queue length, can be calculated using the Erlang C formula.

For practical applications, the M/M/c model is often extended to include finite queue capacity and customer abandonment in order to better reflect real-world systems.

See also:
  • a more realistic model of the M/M/c/K with finite queue capacity
  • the model of an M/M/∞ with an infinite number of servers