Simple simulation example M/M/1 as block-simulation

M/M/1 loss system This example demonstrates the block-simulation style for system with losses M/M/1. For the model two blocks are needed only: the block for entities generation and the block for entities serving. The block "TGenerator" is used for incoming entities stream simulation, the class "TServer" is used for entites serving (delay) simulation.

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

The parameters that will be used in the model

  • Capacity is the total number of entities for simulation.
  • 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.

The lines below fully describe the model in terms of OpenSIMPLY:

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

Gen.Next:=Srv;  // Block "Gen" is connected to block "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 BlocksStyleMM1;
{$apptype xxx }  // xxx is either "GUI" or "Console" 

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

var                                 //  Global variables of the model.
  Capacity: integer;
  lambda, mu: Double;
 
procedure TMyModel.Body;            //  Model description.
var                                 //  Block variables.
  Gen: TGenerator;                  
  Srv: TServer;                       
begin
  Gen:=TGenerator.Create([Capacity,ExpTime,lambda]);     //  These lines
  Srv:=TServer.Create([ExpTime,mu]);                     //  are the model
  Gen.Next:=Srv;                                         //  description.
  
  Run(Gen);                         //  Starting of initial block.
  
                                    //  Outputting of results.
  with Gen do                      
    OutTextRealLn('Loss probability',BusyCount/Count);   
end;

begin
  Capacity:=1000;                   // The initial values of the model.
  lambda:=1;
  mu:=0.5;
  Simulate(TMyModel);               // Starting of the model.
end.   
      

Simula-like simulation style

See also advanced Simula-like style simulation example of the same M/M/1 system with losses. Compare the code.
OpenSIMPLY tutorial contains the practical examples with detailed description.
Download OpenSIMPLY to play around.