Simulation model of the M/M/1 loss system
This system consists of only a single server.
Server
The concept of a server implies the holding of
entities in accordance with the specified delay time distribution function (service time)
and the parameter(s) of this function.
If the server is idle, then when an entity arrives, the server starts servicing it (holding) and becomes busy.
Entity
Entity can represent different concepts in the model.
It can be a forklift in a warehouse, or a barbershop client, or a car at a traffic light, a data packet in a computer network, a phone call, a passenger at an airport etc.
The M/M/1 loss system in terms of queuing theory
Thus, in the
M/M/1 loss system, entities arrive at a single server according to a Poisson process.
Service time is exponentially distributed.
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.
Watch the
learning video about the
M/M/1 loss system.
Blocks for discrete-event simulation
A simulation block in terms of OpenSIMPLY is ready for simulation component of a model.
The model consists of blocks connected in accordance with the behavior of the system under study.
The behavior of a block is described by a class of the programming language.
Any block operates with an entity, an object which passes through the connected blocks.
Using the Simula-like approach it is possible to create models with better performance, but this approach has the following significant drawbacks:
- Model development takes more time
- Model statistics must be manually implemented for each model individually
- It is much more difficult to develop and debug a complex model
Thus, the block simulation approach is much easier and more reliable for model development, and it has built-in powerful and flexible statistics.
The model of the M/M/1 loss system in terms of OpenSIMPLY
To create a model of this system, you will need only two blocks: the Generator block, which creates entities, and the Server block, which simulates their servicing.
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 behavior of the model, you need to create instances of the classes of the blocks used.
For instances of the TGenerator and TServer classes, the variables
Gen and
Srv will be used, respectively.
When creating instances of block classes, some items of initial values must be specified.
For the Generator block
- the capacity (the maximum number of entities to be created during the model run)
- the function that determines the interarrival time of entities
- the function parameter(s)
For the Server block
- the function that determines the time of entity servicing
- the function parameter(s)
Model parameters
The following variables and functions will be used for the initial values of the blocks.
- Capacity: to specify the total number of entities for simulation (Generator)
- InterarrivalTime: to specify the mean value between entities arrivals (Generator)
- ServiceTime: to specify the mean value of service time (Server)
- ExpTime: a block function that returns 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 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.