Week 10 · Chapter 11 Simulations: models and modelling, simulating with a spreadsheet, random numbers and Monte Carlo, queues · 3 lessons
3
Waiting in line: a queue simulation
ICT Secondary 1 Term 1, Chapter 11: pp. 142–154
GoalSimulate a queue by hand with one and with two counters and compare the average waiting time.
New words
queue · customers waiting in order to be servedwaiting time · the time from arriving to starting serviceservice time · the time one customer needs at the counteraverage · the total divided by the number of customers
Explanation
A queue forms when customers arrive at random times and are served one at a time. To compare two plans fairly, we run both with the same arrivals. Take a small school shop with six customers. The table gives, in minutes after opening, when each arrives and how long the service takes. With one counter, each customer starts when he has arrived and the counter is free. Customer 1 arrives at 0 and starts at 0 (waits 0). Customer 2 arrives at 1 but the counter is busy until 3, so he waits 2. Continue and the waits are 0, 2, 3, 7, 5, 7: total 24 minutes, average 24 ÷ 6 = 4 minutes. With two counters, a customer takes whichever counter is free first. The waits are now 0, 0, 1, 1, 0, 0: total 2 minutes, average 2 ÷ 6 ≈ 0.33 minutes. The second counter cuts the average wait a great deal. A real shop would run many random arrival lists, and would also weigh the cost of a second counter. A single hand-made list shows the method, not the final answer.
Customer
Arrives (min)
Service (min)
1
0
3
2
1
2
3
2
4
4
2
2
5
6
3
6
7
2
Worked examples
Customer
Arrives
Starts
Waits
1
0
0
0
2
1
3
2
3
2
5
3
4
2
9
7
5
6
11
5
6
7
14
7
total
24
One counter. The counter finishes customer 1 at 3, customer 2 at 5, customer 3 at 9, customer 4 at 11, customer 5 at 14 and customer 6 at 16. Each customer starts at the later of his arrival and the time the counter becomes free.
Customer
Arrives
Starts
Waits
1
0
0
0
2
1
1
0
3
2
3
1
4
2
3
1
5
6
6
0
6
7
7
0
total
2
Two counters, same arrivals. Customer 2 finds the second counter free at once; customers 3 and 4 each wait one minute for a counter, and the others do not wait. Total waiting is 2 minutes; the average is about 0.33 minutes.
Class activity
Make your own list of five customers with arrival times and service times. Work out the waits with one counter, then with two counters, and compare the averages. Say why you must keep the same arrivals for both plans.
Practice
1
In the one-counter table, how long does customer 4 wait?
He arrives at 2 and starts at 9, so he waits 7 minutes.
2
What is the average wait with one counter?
24 ÷ 6 = 4 minutes.
3
Why compare the two plans with the same arrivals?
So that the difference comes from the plan, not from luckier arrivals.
4
Give one reason a shop might not open a second counter although it cuts waiting.