M/M/n queuing model simulation with Object Pascal

An M/M/n queuing model simulation with Object Pascal

An M/M/n queuing model simulation with Object Pascal and my Thread Pool Engine - version 1.04

Author: Amine Moulay Ramdane

Email: aminer@videotron.ca

Description:

It's harder and sometimes impossible to get analytical results about waiting times and queue length for general interarrival and service distributions; so, it's important to be able to estimate these quantities by observing the results of simulation.

It's very easy in Object Pascal to simulate a sequence of arrival times with a given interarrival distribution.

Look at the examples MM1.pas( M/M/1 queuing model) and MMn.pas(M/M/n - n: number of servers -) inside the zip file:

---------------------------

InterArrivals:=TExponentialDistribution.Create(420623,1.0/3.0);

ServiceTimes:=TExponentialDistribution.Create(220623,1.0/4.0);

currtime:=0.0;

for i:=1 to simnumber

do

begin

obj:=TJob.create;

obj.simnumber:=simnumber;

obj.number:=i;

currtime:=currtime+InterArrivals.Sample;

obj.ArrivalTime:=currtime;

obj.Servicetime:= ServiceTimes.sample;

TP.execute(myobj.myproc1,pointer(obj),NORMAL_PRIORITY);

end;

-------------------------------------------

Here we have the InterArrivals object and ServiceTimes object and we are calling InterArrivals.Sample to get our samples from the Exponential Distribution.

After that we are calling myobj.myproc1 to simulate our M/M/1 queuing model...

If you look at MMn.pas , you will see that the arrival rate is: 3 and the service rate is 4 , so, this will give us a theoretical value of 1/(4-3) = 1 for one server, and the Object Pascal simulation gave me 1.02 for one server.

Language: FPC Pascal v2.2.0+ / Delphi 7+:http://www.freepascal.org/

Operating Systems: Win , Linux and Mac (x86).

Required FPC switches: -O3 -Sd -dFPC -dWin32 -dFreePascal

-Sd for delphi mode....

Required Delphi switches: -DMSWINDOWS -$H+

For Delphi use -DDelphi

Required Delphi XE switches: -DMSWINDOWS -$H+ -DXE

The define options inside the defines.inc file:

{$DEFINE CPU32} for 32 bit systems

{$DEFINE CPU64} for 64 bit systems

Please click on the small arrow on the right of the zip file bellow to download...