The system M/M/1 queue in terms of OpenSIMPLY

M/M/1 queue system The M/M/1 queue system is a classical example of queueing theory. This system has a queue before the only server. Thus, this example is only a bit complicated as the example of MM1 loss system.


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

The block "TGenerator" is used for the incoming entities stream simulation. The class "TServer" is used for entites serving (delay) simulation. Besides tese ones, the block for queue (queue discipline) will be introduced.

The queue discipline is the behavior of the queue according to arriving entities from the one side and requests for entity from the server (if idle) from another side.

The queue discipline for M/M/1 queue system is FIFO. It is a default discipline, therefore it can not be indicate explicitly. But formally the correct expression is: M/M/1 FIFO queue system.

The abriviation FIFO stands for "Fisrt-In, First-Out". That means that the entity the first placed into the queue will the first to be retrieved from the queue head for serving.

The parameters that will be used in the model

  • Capacity is the total number of entities for simulation.
  • QCapacity is the number of waiting places. In the classical example is infinite.
  • Timeout is the maximum waiting time. In the classical example is infinite too.
  • lambda is the mean value of arrived entities stream.
  • mu is the mean value of service time.
  • ExpTime is the block parameter for the function for exponentially distributed random values.

M/M/1 queue model in terms of OpenSIMPLY:

As it was already told, only the block for queue simulation has to be added to the model behavior. The indication of FIFO discipline for this block is not needed. This discipline is the default one for the block TQueue (see below).

Gen:=TGenerator.Create([Capacity,ExpTime,lambda]);  

Que:=TQueue.Create([QCapacity,Timeout]);      
    
Srv:=TServer.Create([ExpTime,mu]);                     

Gen.Next:=Que;                                         

Que.Next:=Srv;                                          
      

To compile your model for receiving the executing file, the code of the model description has to be placed in the standard model wrapper that is the same for practically any model.

The complete program code containing the input data and the output of the 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                                    //  Block variables
  Gen: TGenerator;
  Que: TQueue;
  Srv: TServer;
begin
  Gen:=TGenerator.Create([Capacity,ExpTime,lambda]);   //  These 
  Que:=TQueue.Create([QCapacity,Timeout]);             //  lines
  Srv:=TServer.Create([ExpTime,mu]);                   //  are the  
  Gen.Next:=Que;                                       //  model 
  Que.Next:=Srv;                                       //  description.
  
  Run(Gen);                            //  Starting of initial block.
                                    
                                       //  Outputting of results.
  with Que do 
    OutTextRealLn('Queue probability',DelayedCount/Count);    
end;

begin
  Capacity:=3000;                      // The initial values of the model.
  lambda:=1;
  mu:=1.3;
  QCapacity:=100;
  Timeout:=300;
  Simulate(TMyModel);                  // Starting of the model.
end.  
      
OpenSIMPLY tutorial contains the practical examples with detailed description.
Download OpenSIMPLY to play around.