- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
An M/M/n queuing model simulation with Object Pascal and my Thread Pool Engine.
Author: Amine Moulay Ramdane
Description:
It's harder and sometimes impossible to get analytical results
about waiting times and 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 for example at the M/M/n example MMn.pas 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/n queuig model...
If you look at MMn.pas , you will see that the InterArrival rate
is 3 and the Service rate is 4 , so, this will give us a theoretical
value of 1/(4-3) = 1, and the Object Pascal simulation give us 1.02.
You can download the M/M/n queuing model simulation from:
http://pages.videotron.com/aminer/
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 5,6,7 use -DDelphi
For Delphi 2005,2006,2007,2009,2010+ use the switch -DDELPHI2005+
Disclaimer:
This software is provided on an "as-is" basis, with no warranties,
express or implied. The entire risk and liability of using it is yours.
Any damages resulting from the use or misuse of this software will be
the responsibility of the user.
Sincerely,
Amine Moulay Ramdane.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>If you look at MMn.pas , you will see that the InterArrival rate
>is 3 and the Service rate is 4 , so, this will give us a theoretical
>value of 1/(4-3) = 1, and the Object Pascal simulation give us 1.02.
I mean for one server - M/M/1 - it givesa theorerical value
of 1/(4-3) = 1and 1.02 in the simulation..
But as you have noticed MMn.pascan simulatean M/M/n queuig model
with1 or many servers...
Sincerely,
Amine Moulay Ramdane.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello ,
I have updated MMn.pas to version1.01 - i have corrected a bug -
and put it back inside the zip file that you can download from:
Welcome: http://pages.videotron.com/aminer/
Note: MMn.pas - n: numbers of servers - is queuing model simulation with
Object Pascal and my Thread Pool Engine.
Sincerely,
Amine Moulay Ramdane.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Note: next time i will show you how to simulate
a more complex problem in Object Pascal...
Of course, if you want to simulate a 'general' distribution ,
like uniform or normal ,you can do it like this by changing
your variables inside MMn.pas:
Define your variables:
var InterArrivals: TUniformDistribution;
ServiceTimes: TUniformDistribution;
and after that:
InterArrivals:=TUniformDistribution.Create(420623,0,2);
ServiceTimes:=TUniformDistribution.Create(2990623,0,1.5);
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;
Welcome: http://pages.videotron.com/aminer/
That all.
Sincerely,
Amine Moulay Ramdane.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page