M/M/1/1 Simulation Model
This is a single-server system.
The server holds (serves) an
entity for a time determined by the service time distribution and its parameters.
When the server is idle and a new entity arrives, it immediately starts serving (holding) that entity and becomes busy.
Entity
An entity can represent various concepts in a model.
For example, it could be a forklift in a warehouse, a barbershop client, a car at a traffic light,
a data packet in a network, a phone call, or a passenger in an airport.
M/M/1/1: Theoretical Background
This system is denoted as
M/M/1/1 in Kendall's notation.
In this system:
- entities arrive according to a Poisson process (M/M/1/1),
- the service time is exponentially distributed (M/M/1/1),
- there is only one server (M/M/1/1),
- and the total system capacity is 1 (M/M/1/1).
The system capacity is the total number of entities being served or waiting.
If the server is busy when an entity arrives, the entity is rejected and considered lost.
Therefore, such a system is called a
loss system.
Watch the
educational video about the
M/M/1/1 loss system.
Blocks for Discrete-Event Simulation
In OpenSIMPLY, a simulation block is a ready-to-use component for building discrete-event models.
A model consists of blocks connected according to the behavior of the system being studied.
The behavior of a block is defined by a class in the programming language.
Any block operates on an entity — an object that passes through the connected blocks.
Using the Simula-like approach, it is possible to create models with better performance; however, this approach has the following significant disadvantages:
- 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 provides powerful and flexible built-in statistics.
M/M/1/1 Model in OpenSIMPLY
To create a model of this system, only two blocks are required:
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 ready-to-run models of queuing theory and call centers.
Model Creation
To describe the model's behavior, create instances of the required block classes.
For instances of the TGenerator and TServer classes, the variables
Gen and
Srv will be used, respectively.
When creating instances of block classes, you must specify certain mandatory items of the initial values.
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 service times (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 — the total number of entities to be simulated
- InterarrivalTime — the mean time between entity arrivals
- ServiceTime — the mean value of service time
- RandExp — a function that returns exponentially distributed random values
Model Behavior
The code below defines the behavior of the
M/M/1/1 system as an 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 the model, place the code above into the standard model wrapper, which is the same for all models.
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 behavior.
var
// Blocks declaration.
begin
// Model behavior.
end;
begin
// Assignment of initial values of the model.
Simulate(TMyModel); // Starting a model.
end.
Complete Program Code with Input Data and Results
program BlocksStyleMM11;
{$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 behavior.
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/1 model, verify its results against the exact formula.
Thus, the blocking (loss) probability can be obtained using the Erlang B formula.
Simula-like Simulation Style
You can also create a simulation model of an
M/M/1/1 using a Simula-like simulation style.
It is based on the concept of a process, which is the cornerstone of the Simula language.
This style does not use blocks and does not provide automatic statistics gathering.
Despite these disadvantages, the simulation runtime is much faster, and you have unlimited flexibility in creating custom components.
Take a look at an example of a
Simula-like simulation style of the same system.