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.
  • QCapacity is the number of waiting places. For M/M/1 queue is infinite.
  • Timeout is the maximum waiting time. For M/M/1 queue is infinite.
  • lambda is mean value between entities arrivals.
  • mu 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,lambda]); // Creation of TGenerator instance.

Que:=TQueue.Create([QCapacity,Timeout]); // Creation of TQueue instance.

Srv:=TServer.Create([ExpTime,mu]); // Creation of TServer instance.

Gen.Next:=Que; // Connection of block "Gen" to block "Que".

Que.Next:=Srv; // Connection of block "Que" to block "Srv".


For compiling and receiving of executable file, the code of model behaviour has to be placed into the standard model wrapper 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,lambda]);     //   
  Que:=TQueue.Create([QCapacity,Timeout]);               //  
  Srv:=TServer.Create([ExpTime,mu]);                     //  Model behavior.  
  Gen.Next:=Que;                                         //   
  Que.Next:=Srv;                                         //  
  
  Run(Gen);                            //  Starting of initial block.
                                    
                                       //  Outputting of results.
  with Que do 
    OutTextRealLn('Queue probability',DelayedCount/Count);    
end;

begin
  Capacity:=3000;                      // Initial values of the model.
  lambda:=1;                           //
  mu:=1.3;                             //
  QCapacity:=100;                      // (for M/M/1 queue it is infinite)  
  Timeout:=300;                        // (for M/M/1 queue it is infinite)
  
  Simulate(TMyModel);                  // Starting of the model.
end.  
      


To verify the model the simulation results of M/M/1 system can be checked with analytics of traffic theory.
The queue probability can be obtained with Erlang_C formula.
OpenSIMPLY tutorial contains the practical examples with detailed description.
Discrete event simulation software OpenSIMPLY is absolutely free. Try it. Free download. Free use.