Note: for academic purpose, all the computations (i.e. computation of Cumulative Arrival Time,Cumulative Departure Time, Queue Length, Idle Time and Waiting Time) have been carried out using different loops.
Abbreviations used:
at: Arrival Time, st: Service Time, cat: Cumulative Arrival Time, cdt: Cumulative Departure Time, ql: Queue Length, idt: Idle Time, wt: Waiting Time.
Assumptions: Time gap between he arrival of any two consecutive customers (at) is between 5 to 30 minutes
Service Time is from 5 to 35 minutes
Simulation has been done for 20 customers
------------------------------------------------------------------------------------------------------------
#include < stdio.h >
#include < conio.h >
#include < math.h >
#include < stdlib.h >
Abbreviations used:
at: Arrival Time, st: Service Time, cat: Cumulative Arrival Time, cdt: Cumulative Departure Time, ql: Queue Length, idt: Idle Time, wt: Waiting Time.
Assumptions: Time gap between he arrival of any two consecutive customers (at) is between 5 to 30 minutes
Service Time is from 5 to 35 minutes
Simulation has been done for 20 customers
------------------------------------------------------------------------------------------------------------
#include < stdio.h >
#include < conio.h >
#include < math.h >
#include < stdlib.h >
void main()
{
clrscr();
int
at[20],st[20],cat[20],cdt[20],ql[20],idt[20],wt[20];
int i,j,k;
idt[0]=0,ql[0]=0,cat[0]=0,wt[0]=0;
randomize();
for(k=0;k<=19;k++)
{
at[k]=(5+rand()%25);
st[k]=(5+rand()%30);
}
at[0]=0;
cdt[0]=st[0];
for(k=1;k<=19;k++)
{
cat[k]=cat[k-1]+at[k];
idt[k]=0;
ql[k]=0;
}
for(k=1;k<=19;k++)
{
if(cat[k]<=cdt[k-1])
cdt[k]=cdt[k-1]+st[k];
else
cdt[k]=cat[k]+st[k];
}
for(j=1;j<=19;j++)
{
k=j-1;
while(cdt[k]>cat[j] && k>=0)
{
ql[j]=ql[j]+1;
k=k-1;
}
}
for(i=1; i<=19; i++)
{
if(cat[i]<=cdt[i-1])
{
wt[i]=cdt[i-1]-cat[i];
idt[i]=0;
}
else
{
idt[i]=cat[i]-cdt[i-1];
wt[i]=0;
}
}
printf(" AT ST
CAT CDT QL
IDT WT \n\n\n");
for(k=0;k<=19;k++)
{
printf("%3d %3d
%3d %3d %3d
%3d
%3d",at[k],st[k],cat[k],cdt[k],ql[k],idt[k],wt[k]);
printf("\n\n");
}
getch();
}
AT ST CAT
CDT QL IDT
WT
0 8
0 8 0
0 0
21 33
21 54 0
13 0
6 9
27 63 1
0 27
12 32
39 95 2
0 24
13 32
52 127 3
0 43
11 14
63 141 2
0 64
20 29
83 170 3
0 58
14 16
97 186 3
0 73
21 30
118 216 4
0 68
27 30
145 246 3
0 71
18 9
163 255 4
0 83
15 17
178 272 4
0 77
14 14
192 286 4
0 80
6 16 198
302 5 0
88
17 13
215 315 6
0 87
24 10
239 325 6
0 76
12 22
251 347 6
0 74
8 33
259 380 6
0 88
25 16
284 396 6
0 96
6 33
290 429 6
0 106
No comments:
Post a Comment