Sunteți pe pagina 1din 8

Simulation and Modeling

Chapter -3(General principles)


Ques: Example 3.3: Single Chanel Queue
Reconsider the grocery store with one checkout counter . The system consist of those
customers in the waiting line plus the one(if any) checking out. A stopping time of 60
minutes is set for this example. Prepare a simulation table using event scheduling algorithm
for single channel queue for 7 customers. The model has the following components:
Inter-arrival times 1 1 6 3 7 5 2 4 1
Service time 4 2 5 4 1 5 4 1 4

Solution:
Step :1 Compute Departure time
Inter- Arrival Service Time service begin Time service
arrival time time = Compare (Previous value of Time Ends/Departure
time Service End and current value of time(Service time + time
Arrival Time )= Greater of two values service begin)
0 0 4 0 4 -D1
1 1 – A1 2 4 6 – D2
1 2 – A2 5 6 11- D3
6 8 – A3 4 11 15 –D4
3 11 –A4 1 15 16 -D5
7 18 –A5 5 18 23 -D6
5 23 –A6 4 23 27 -D7
2 25 –A7 1 27 28 -D8
4 29 –A8 4 29 33 -D9
1 30 –A9 33

1
System State Cumulative Statistics
Clk Event LQ(t) LS(t)
type [Number B MQ
[Numbe of Future Event List Comment
(Total (Maximum
r of customer server queue
custome being busy length)
rs in served] time)
waiting
line]

0 0 0 1 (A1,1)(D1,4)(E,60) First A occurs 0 0


Schedule next Arrival
(A1) Next departure
(D1)
1 A1 1 1 (A2,2)(D1,4)(E,60) 2nd A occurs :(A1,1) 1 1
next Arrival(A2)
Next departure
(D1)
2 A2 2 1 (D1,4)(A3,8)(E,60) 3rd A occurs 2 2
(A3):(A2,2)
4 D1 1 1 (D2,6)(A3,8)(E,60) 1st D occurs:(D1,4) 4 2
6 D2 0 1 (D3,11)(A3,8)(E,60) 2nd D occurs 6 2
:(D2,6)
8 A3 1 1 (A4,11)(D3,11)(E,6 4th A occurs: (A3,8) 8 2
0)
11 A4/D3 1 1 (D4,15)(A5,18)(E,6 3rd D occurs :(D3,11) 11 2
0) 5th A occurs
:(A4,11)
15 D4 0 1 (D5,16)(A5,18)(E,6 4th D occurs: 15 2
0) (D4,14)
16 D5 0 0 (A5,18)(E,60) 5th D occurs: 16 2
(D5,16)
18 A5 0 1 (A6,23)(D6,23)(E,6 6th A occurs 16 2
0)
23 A6/D6 0 1 (A7,25)(D7,27)(E,6 7th A occurs: 21 2
0) (A6,23)
6th D occurs:
(D6,23)
25 A7
27 D7
28 D8
29 A8
30 A9
33 D9

Formula:
Arrival event occurs at clock (t): Is LS (t) =1= yes then increase LQ (t) by 1 . If no then set LS (t) =1
Departure event occurs at clock (t): Is LQ (t) >0 =yes then reduce LQ (t) by 1 .IF no then set LS (t) =0
2
Example: The Checkout-Counter Simulation
Reconsider the grocery store with one checkout counter. The system consist of those customers in the
waiting line plus the one (if any) checking out. A stopping time of 60 minutes is set for this example. Prepare
a CHECKOUT LINE using event scheduling algorithm for single channel queue for 7 customers. Estimate
mean response time and mean proportion of customers who spend 5 or more minutes in the system. The
model has the following components:
Inter-arrival 1 1 6 3 7 5 2 4 1
times
Service time 4 2 5 4 1 5 4 1 4
Solution:
“CHECKOUT LINE” the set of all customers currently at the checkout( being served or waiting to be served), ordered by time of arrival.

(Ci, t), representing customer Ci at future time t

S= The sum of customer response times for all customers who have departed by the current time

F= Total number of customers who spend 5 or more minutes at the checkout counter

ND= The total number of departures up to the current simulation time.

System state Future Event List Cumulative Statistics


Clk Event LQ(t) LS(t) CHECKOUTLINE S (sum of ND (The F (Total
Type [Numbe [Number customer total number of
r of of response number of customers
custom customer times for all departures who spend 5
ers in being customers) up to the or more
waiting served] current minutes at
line] simulation the
time. checkout
counter)
0 0 0 1 (C1,0) (A1,C2,1)(D1,C1,4) 0 0 0
(E,60)
1 A1 1 1 (C1,0)(C2,1) (A2,2,C3)(D1,4,C1) 0 0 0
(E,60)
2 A2 2 1 (C1,0)(C2,1)(C3,2) (D1,4,C1)(A3,8,C4) 0 0 0
(E,60)
4 D1 1 1 (C2,1)(C3,2) (D2,6,C2)(A3,8,C4) 4 1 0
(E,60)
6 D2 0 1 (C3,2) (D3,11,C3)(A3,8,C4) 9 2 1
(E,60)
8 A3 1 1 (C3,2)(C4,8) (A4,11,C5)(D3,11,C3) 9 2 1
(E,60)
11 A4/D3 1 1 (C4,8)(C5,11) (D4,15,C4)(A5,18,C6) 18 3 2
(E,60)
15 D4 0 1 (C5,11) (D5,16,C5)(A5,18,C6) 25 4 3
(E,60)
16 D5 0 0 (A5,18,C6)(E,60) 30 5 4
18 A5 0 1 (C6,18) (A6,23,C7)(D6,23,C6) 30 5 4
(E,60)
23 A6/D6 0 1 (C7,23) (A7,25,C8)(D7,27,C7) 35 6 5
(E,60)

For example, at time 4, a departure event occurs for customer C1. The customer entity C1 is removed from the list called
“CHECKOUT LINE”, the attribute “time of arrival” is noted to be 0, so the response time for this customer was 4 minutes.
Hence, S is incremented by 4 minutes. ND is incremented by one customer. But F is not incremented, for the time in system was
3
less than five minutes. Similarly, at time 23, when the departure event (D6, 23, C6) being executed, then the response time for
customer C6 is computed by

Response time =CLOCK TIME – attribute “time of arrival”

=23-18 =5

Then S is incremented by 5 minutes, F and ND by one customer.

For the simulation length of 23 minutes, the average response time was S/N D=35/6=5.83 minutes.

Observed proportion of customer who spend 5 or more minutes in the system was F/N D=5/6= .83

Explanation:
System state Cumulative Statistics
Clk Event LQ(t) LS(t) S (sum of ND (The F( Total
Type customer
[Number of [Number total number of
response times customers
customers of number
for all customers who spend 5
in waiting customer who have of
being or more
line] departed by the departure
minutes at
served] current time) s up to the checkout
কতজন (চলমান ক্লক টাইয়ম the
কতজন কাস্টমার CHECKOUTLINE Future Event র্িপাচ িার অনুযােী মমাট
counter)
current (মচক আউট
কাস্টমার সার্ভিস র্নয়ে List কাস্টমার সার্ভিস টাইম) simulatio লাইয়ন ৫
ওয়েটিং এ n time. র্কিংবা তার
আয়ে (মমাট মবর্ি সমে
র্িপাচ িার
থাকা
হওো
কাস্টমায়রর কাস্টমায়রর
সিংখ্যা) সিংখ্যা)
0 0 0 1 (C1,0) (A1,C2,1)(D1,C1,4) 0 0 0
(E,60)
(Waiting (১ম কাস্টমার ১ম কাষ্টমার(C1) এর পরবতী Clk time
line এ C1 মক সাভি Arrival time =0 , 1sec/min এ ২ে কাস্টমার
কাস্টমার মনই, করা হয়ে, Default র্হয়সয়ব থায়ক। C2 চয়ল আসয়ব। A1 দ্বারা
এজন্য 1 ১ম Arrival event বুঝায়না
তাই ০ হয়েয়ে)
হয়েয়ে) হয়েয়ে। D1 দ্বারা ১ম
কাস্টমায়রর Departure
event বুঝায়না হয়েয়ে।
C1 এর departure time 4
। (E,60) দ্বারা Event End
time 60 sec/min বুঝায়না
হয়েয়ে।
1 A1 1 (Customer 1 (C1,0)(C2,1) (A2,2,C3)(D1,C1,4) 0 0 0
(E,60)
C2 waiting এ (১ম কাস্টমার C1 এর পর ক্লক টাইম 1
আয়ে) C1 মক সাভি এ কাস্টমার C2 পরবতী ক্লক টাইম 2 মত
করা হয়ে, CHECKOUTLINE এ ৩ে কাস্টমার C3 arrive
এজন্য 1 চয়ল এয়সয়ে করয়ব ।
হয়েয়ে)
2 A2 2 1 (C1,0)(C2,1)(C3,2) (D1,4,C1)(A3,8,C4) 0 0 0
(E,60)
(Customer (১ম কাস্টমার এ কাস্টমার C3 মচক
C2 ও C3 C1 মক সাভি আঊট লাইয়ন চয়ল এয়সয়ে পরবতী ক্লক টাইম 4 এ
waiting এ করা হয়ে, কাস্টমার C1 চয়ল যায়ব
আয়ে, এজন্য ২ এজন্য 1 এবিং ইয়ভন্ট A3 মত
হয়েয়ে) হয়েয়ে)
কাস্টমার C4 arrive
করয়ব।

4
1 1 (D2,6,C2)(A3,8,C4)
4(মযয়হতু ক্লক টাইম 1 (একজন
(Customer ( কাস্টমার (E,60) 4পয িন্ত C1 কাস্টমায়রর
C3 waiting C2 মক সাভি (C2,1)(C3,2) কাস্টমায়রর র্িপাচ িার র্িপাচ িার
4 D1 এ আয়ে, এজন্য করা হয়ে, হয়েয়ে তাই মটাটাল হয়েয়ে)
0
পরবতী ক্লক টাইম 6 এ
1 হয়েয়ে) এজন্য 1 কাস্টমার মরস্পন্স
কাস্টমার C2 চয়ল যায়ব
হয়েয়ে) টাইম 4)

9 (ক্লক টাইম 6 এ
0(Customer এয়স C2 কাস্টমায়রর 2 (C1 1
(A3,8,C4) (D3,11,C3)
র্িপাচ িার হয়েয়ে, C2 এবিং C2
C2 চয়ল 1 (E,60)
Arrive কয়রর্েল ক্লক (কাস্টমার
পরবতী ক্লক টাইম 8 এ এর র্িপাচ িার
6 যাওোয়ত ( কাস্টমার টাইম 1 এ। C2, 5 clk
কাস্টমার C4 চয়ল আসয়ব হয়েয়ে)
waiting এ C3 সার্ভিস Departure time- time মচক
মকঊ মনই, তাই র্নয়ে , এজন্য
(C3,2) । পরবতী Departure Arrival time= 6-
আউট লাইয়ন
D2 0 1 হয়েয়ে) event D3 মত ক্লক টাইম 1= 5 তাই মটাটাল
11 এ C3 চয়ল যায়ব। কাস্টমার মরস্পন্স টাইম র্েল )
হয়েয়ে)
4+5= 9)
(A4,11,C5)(D3,11 9 (এখায়ন মকান
,C3) কাস্টমায়রর র্িপাচ িার
(E,60) হের্ন , তাই ওই
8 A3 1 1 (C3,2)(C4,8) পরবতী ক্লক টাইম 11এ পয িন্ত মটাটাল 2 (মকান 1
(Customer ( কাস্টমার ( কাস্টমার C3 সার্ভিস কাস্টমার মরস্পন্স র্িপাচ িারহে
C4 waiting C3 সার্ভিস কাস্টমার C5 চয়ল র্ন, তাই 2
র্নয়ে এবিং C4 waiting টাইম 9 রয়ে মেয়ে)
এ আয়ে, এজন্য র্নয়ে , এজন্য আসয়ব । পরবতী অপর্রবর্তিত
এ আয়ে)
1 হয়েয়ে) 1 হয়েয়ে) Departure event রয়েয়ে)
D3 মত ক্লক টাইম 11
এ C3 চয়ল যায়ব।
11 A4/ 1 1 (C4,8)(C5,11) (D4,15,C4)(A5,18 18 3 (C3 এর 2
(C3 চয়ল ( কাস্টমার ,C6) (ক্লক টাইম 11 এ র্িপাচ িার
D3 হয়েয়ে , তাই
(কাস্টমার
র্েয়েয়ে একই C4 সার্ভিস (E,60) এয়স C3 C3, 9 clk
1 মযাে হয়ে
সায়থ C5 চয়ল র্নয়ে , এজন্য পরবতী Departure কাস্টমায়রর র্িপাচ িার ৩ হয়েয়ে time যাবত
এয়স waiting 1 হয়েয়ে) event D5 মত ক্লক হয়েয়ে, C3 ) মচক আউট
এ আয়ে, এজন্য টাইম 15 এ C4 চয়ল Arrive কয়রর্েল লাইয়ন র্েল
1 হয়েয়ে) যায়ব। ক্লক টাইম 2 এ। ,তাই পূয়ব ির
পরবতী Arrival Departure 1 এর সায়থ 1
Event A5, ক্লক time- Arrival বৃর্ি মপয়ে 2
time=11-2= 9 হয়েয়ে
টাইম 18 মত কাস্টমার তাই মটাটাল
C6 চয়ল আসয়ব । )
কাস্টমার মরস্পন্স
টাইম 9+9=18)
15 D4 0 1 (C5,11) (D5,16,C5)(A5,18 25 4 3
(C4 চয়ল চয়ল ( কাস্টমার ,C6) (ক্লক টাইম 15 এ (C4 এর (কাস্টমার
যাওোয়ত C5 সার্ভিস (E,60) এয়স C4কাস্টমায়রর র্িপাচ িার
C4, 7 clk
waiting এ র্নয়ে , এজন্য পরবতী Departure র্িপাচ িার হয়েয়ে, হয়েয়ে ,
time যাবত
মকঊ মনই, তাই 1 হয়েয়ে) event D5 মত ক্লক C4 Arrive তাই 1 মযাে
হয়ে 4
মচক আউট
0 টাইম 16 এ C5 চয়ল কয়রর্েল ক্লক লাইয়ন র্েল
হয়েয়ে) যায়ব। হয়েয়ে
টাইম 8 এ। ,তাই পূয়ব ির
)
পরবতী Arrival Departure 2 এর সায়থ
Event A5, ক্লক time- Arrival বৃর্ি মপয়ে 3
টাইম 18 মত কাস্টমার time=15 -8= 7 হয়েয়ে
তাই মটাটাল
C6 চয়ল আসয়ব । কাস্টমার মরস্পন্স
)

টাইম 18+7=23)

5
30(ক্লক টাইম
0 16 এ এয়স 5
0 (C5 চয়ল (A5,18,C6)(E,60) C5কাস্টমায়রর
চয়ল যাওোর র্িপাচ িার হয়েয়ে,
16 (C5 চয়ল চয়ল 4 (মকান
পর আর C5 Arrive
D5 যাওোয়ত কাস্টমায়রর
মকান কয়রর্েল ক্লক
waiting এ Departure
মকঊ মনই, তাই কাস্টমার টাইম 11 এ। হের্ন, তাই 4
0 আয়সর্ন তাই Departure অপর্রবর্তিত
হয়েয়ে) time- Arrival রয়েয়ে)
0
হয়েয়ে) time=16 -11=
5 । তাই মটাটাল
কাস্টমার মরস্পন্স
টাইম 25+5=30)
18 A5 0 1 (C6,18) (A6,23,C7)(D6,23,C 30(এখায়ন মকান 5 4(মকান
( কাস্টমার 6) কাস্টমায়রর র্িপাচ িার কাস্টমায়রর
(E,60) হের্ন , তাই ওই
C6 সার্ভিস Departure
পরবতী Arrival Event পয িন্ত মটাটাল হের্ন, তাই 4
র্নয়ে , এজন্য
A6, ক্লক টাইম 23 এ কাস্টমার মরস্পন্স অপর্রবর্তিত
1 হয়েয়ে)
কাস্টমার C7 চয়ল আসয়ব টাইম 9 রয়ে মেয়ে) রয়েয়ে)
। পরবতী Departure
event D6 এ ক্লক টাইম
23 এ C6 চয়ল যায়ব।

23 A6/ 0 1 (C7,23) (A7,25,C8)(D7,27 35(ক্লক টাইম 6 5


D6 (C6 চয়ল চয়ল ( কাস্টমার ,C7) 23 এ এয়স C6
যাওোয়ত C7 সার্ভিস (E,60) কাস্টমায়রর র্িপাচ িার
waiting এ র্নয়ে , এজন্য হয়েয়ে, C6
মকঊ মনই, তাই 1 হয়েয়ে) Arrive কয়রর্েল
0 ক্লক টাইম 18 এ।
হয়েয়ে) Departure
time- Arrival
time=23 -18=
5 । তাই মটাটাল
কাস্টমার মরস্পন্স
টাইম 30+5=35)

6
Exercise 4: Consider the grocery store with one checkout counter. The system consist of those customers
in the waiting line plus the one (if any) checking out. A stopping time of 30 minutes and CLOCK time set
until 15 minutes. Prepare a CHECKOUT LINE using event scheduling algorithm for single channel queue
for 5 customers. Estimate mean response time and mean proportion of customers who spend 5 or more
minutes in the system. The model has the following components:
Inter-arrival times 1 5 6 3 8
Services time 3 5 4 1 5

Solution: Compute Departure time


Inter-arrival Arrival Service Time service begin Time service Ends/Departure
time time time = Compare (Previous value of Time Service time(Service time + time
End and current value of Arrival Time )= service begin)
Greater of two values
0 0 3 0 3 -D1
1 1 – A1 5 3 8 – D2
5 6 – A2 4 8 12- D3
6 12 – A3 1 12 13–D4
3 15 –A4 5 15 20-D5
8 23 –A5 23

Simulation table for Exercise 4


System state Future Event List Cumulative Statistics
Clk Event LQ(t) LS(t) CHECKOUTLINE S (sum of ND (The F (Total
Type [Number [Number customer total number of
of of response number of customers
customers customer times for all departures who spend 5
in waiting being customers) up to the or more
line] served] current minutes at
simulation the
time. checkout
counter)
0 0 0 1 (C1,0) (A1,C2,1)(D1,C1,3) 0 0 0
(E,30)
1 A1 1 1 (C1,0)(C2,1) (D1,C1,3) (A2,6,C2) 0 0 0
(E,30)
3 D1 0 0 (A2,6,C2)(D2,8,C2) 3 1 0
(E,30)
6 A2 0 1 (C2,6) (D2,8,C2)(A3,12,C3) 3 1 0
(E,30)
8 D2 0 0 (A3,12,C3)(D3,12,C3) 10 2 1
(E,30)
12 A3/D3 0 0 (D4,13)(A4,15,C4) 10 3 1
(E,30)
13 D4 0 0 (A4,15,C4)(D5,20,C4) 15 4 2
(E,30)
15 A4 0 1 (C4,15) (A5,23,C5) 4 2
(E,30)
20 D5 0 0
23 A5

For the simulation length of 15 minutes, the average response time was S/ND=15/4=3.76 minutes.

Observed proportion of customer who spend 5 or more minutes in the system was =2/4= .5
7
8

S-ar putea să vă placă și