M/M/1 queue system in terms of OpenSIMPLY

M/M/1 queue system M/M/1 queue system is a classical example of queueing theory. The system consists of a queue with FIFO discipline and an single server. Entities are arrived as a Poisson process. Queue capacity and timeout (waiting time) are infinite. Service time value is exponentially distributed.

This example is only a bit complicated as an example of MM1 loss system.


Watch also the learning video about M/M/1 queue system.

This model requires three blocks: block for entities generation, block for queue (queue discipline), and block for entities serving (delay block). The classes "TGenerator", "TQueue" and "TServer" are used for these purposes.

Queue discipline is a queue behavior for arriving entities from one side (input) and requests for entity from another side (output). In case of M/M/C1 queue idle server can inform queue about that.

Queue discipline for M/M/1 queue system is FIFO. It is a default discipline, and therefore it can not be indicated explicitly. But formally correct expression should be: M/M/1 FIFO queue system.

The abbreviation FIFO stands for "First-In, First-Out". That means an entity first placed into a queue will first to be retrieved from queue for serving.

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 the block parameter for function returning exponentially distributed random values.

For assignment of instances for classes TGenerator, TQueue and TServer, the variables "Gen", "Que" and "Srv" will be used accordingly.

Model behavior

Gen:=TGenerator.Create([Capacity,ExpTime,InterArrivalTime]);    // Creating TGenerator instance.

Que:=TQueue.CreateDefault;                                      // Creating TQueue instance with default parameters.

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

Gen.Next:=Que;                                                  // Connecting the "Gen" block to the "Que" block.

Que.Next:=Srv;                                                  // Connecting the "Que" block to the "Srv" block.
	  



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

Complete program code containing input data and output of results.

program MM1queue;
{$apptype xxx }  // xxx "GUI" or "Console" 

uses
  SimBase,
  SimBlocks,
  SimStdGUI;
  
type
  TMyModel = class(TModel)             //  Model declaration.  
    procedure Body; override;
  end;	

var                                    //  Global variables of the model.
  Capacity, QCapacity: integer;
  lambda, mu, Timeout: Double;
                                       
procedure TMyModel.Body;               //  Model description.                      
var                                    
  Gen: TGenerator;                     //  
  Que: TQueue;                         // Model variables.  
  Srv: TServer;                        //
begin
  Gen:=TGenerator.Create([Capacity,ExpTime,InterArrivalTime]);  //   
  Que:=TQueue.CreateDefault;                                    //  
  Srv:=TServer.Create([ExpTime,ServiceTime]);                   //  Model behavior.  
  Gen.Next:=Que;                                                //   
  Que.Next:=Srv;                                                //  
  
  Run(Gen);                            //  Starting of initial block.
             
                                       //  Outputting of results.
									   
  OutTextRealLn('Queue probability',Que.QueueProbability);    
end;

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


To validate the model of M/M/1 queue system, simulation results can be verified using traffic theory analytics.
The value of queue probability can be obtained by the Erlang_C formula.


The OpenSIMPLY tutorial will help you quickly get started. The tutorial contains practical examples with detailed descriptions.

The project documentation is available in different formats and compatible with any IDE.

Discrete event simulation software OpenSIMPLY is free and open source. Free download. Free use. Try it.