Simulation model of the M/M/1 loss system
The M/M/1 loss system in terms of queuing theory
This system is really the "Hello,world!" example for the simulation model.
Such a system contains a single server and no queue (waiting line).
Entities arrive at a single server as a Poisson process.
The service time value is exponentially distributed.
If the server is idle, then when an entity arrives, it starts servicing it and becomes busy.
If the server is busy, then when an entity arrives, it is rejected and considered lost.
Therefore, such a system is called a
loss system or otherwise a
blocking system.
Watch the
learning video about the
M/M/1 loss system.
The model of the M/M/1 loss system in terms of OpenSIMPLY
In this example only two blocks are used.
The Generator block produces entities, the Server block simulates the entity serving.
In Delphi and Free Pascal, these blocks are represented by the TGenerator and TServer classes, respectively.
Download executable models of queuing theory and call centers.
Model creation
To describe the model behavior, the instances of required classes should be created.
The variables Gen and Srv will be used for instances of the TGenerator and TServer classes, respectively.
For the Generator block, the initial parameters of the total number of of entities for simulation and
the mean interarrival time of the entities should be specified.
For the Server block, the initial parameter of mean service time value should be specified.
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 a block function returning exponentially distributed random values.
Model behavior
The lines below fully describe the behavior of the
M/M/1 loss system in terms of the OpenSIMPLY model.
Gen := TGenerator.Create( [Capacity, ExpTime, InterarrivalTime] ); // Creating a Generator.
Srv := TServer.Create([ExpTime, ServiceTime]); // Creating a Server.
Gen.Connect(Srv) // Connecting Generator to Server.
Model wrapper
To compile a model, the code above should be placed in a standard wrapper of a model. This wrapper is the same for any model.
program MySimulation;
{$apptype xxx } // xxx is either "GUI" or "Console"
{$S-}
uses
SimBase,
SimBlocks,
SimStdGUI;
type
TMyModel = class(TModel) // Model declaration.
procedure Body; override;
end;
var
// Model parameters.
procedure TMyModel.Body; // Model description.
var
// Blocks declaration.
begin
// Model behavior.
end;
begin
// Assignment of initial values of the model.
Simulate(TMyModel); // Starting a model.
end.
Complete program code containing input data and output of 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
Capacity, // Model parameters.
NumberOfServers: Integer;
InterarrivalTime,
ServiceTime: Double;
procedure TMyModel.Body; // Model description.
var
Gen: TGenerator; // Blocks declaration.
Srv: TServer;
begin // Model behavior.
Gen := TGenerator.Create([Capacity, ExpTime, InterarrivalTime]);
Srv := TServer.Create([ExpTime, ServiceTime]);
Gen.Connect(Srv);
Run(Gen); // Launching the start block.
Gen.ShowStats; // Results.
end;
begin
Capacity := 1000; // Initial values of the model.
InterarrivalTime := 1;
ServiceTime := 0.5;
Simulate(TMyModel); // Starting a model.
end.
To validate the M/M/1 loss model, the simulation results can be verified using the exact formula.
So, the value of loss (blocking) probability can be obtained with Erlang B formula.
Simula-like simulation style
You can also create a simulation model of the
M/M/1 loss system using a Simula-like simulation style.
It is based on the concept of process, which is the cornerstone of the Simula language.
This style does not involve the use of blocks, and there is no provision for automatic statistics gathering.
But despite these “disadvantages”, the simulation execution time is much faster and the possibility of creating any model components is unlimited.
Take a look at an example of a
Simula-like simulation style of the same
M/M/1 loss system.