GoalChoose the key features a simulator must include, and leave out what does not matter.
New words
key feature · an important part of a real system that the model must copypurpose · the reason the simulator is built, which decides what is includedinput data · numbers or choices the user gives to the simulator
Explanation
A model cannot copy everything, so the builder chooses key features. These are the parts that matter for the purpose of the simulator. Suppose the purpose is to find out how long a school canteen queue grows. Key features are how many pupils arrive each minute, how many tills are open and how many pupils each till serves. The colour of the trays does not affect the queue, so it is left out. If the key features are wrong, the answers are wrong. A good simulator lets the user change features, such as the number of tills, to see what happens. A model made of rules can even be traced by hand, line by line, like any algorithm.
Worked examples
Pseudocode
1waiting ← 02arrivals ← 53tills ← 24served ← tills * 25waiting ← waiting + arrivals - served
6waiting ← waiting + arrivals - served
7waiting ← waiting + arrivals - served
8OUTPUT waiting
Output
3
A very small canteen model written in pseudocode. 5 pupils arrive each minute, and each of the 2 tills serves 2 pupils a minute, so 4 are served. The model is run for three minutes by repeating the same line.
Line run
waiting
served
1
0
–
4
0
4
5
1
4
6
2
4
7
3
4
The trace of the model. After each minute the queue has grown by 1, because 5 arrive and 4 are served. After three minutes, 3 pupils are waiting. Lines 2 and 3 only store arrivals and tills, so only the lines that change waiting or served are shown.
Pseudocode
1waiting ← 02arrivals ← 53tills ← 14served ← tills * 25waiting ← waiting + arrivals - served
6waiting ← waiting + arrivals - served
7waiting ← waiting + arrivals - served
8OUTPUT waiting
Output
9
A what-if test with the same model: with only 1 till, the served number is 2, so the queue grows by 3 each minute. After three minutes 9 pupils are waiting. The model shows why one till is not enough.
Class activity
Queue game (no computer). Use counters or coins. Each round, move 5 counters into the “waiting” area to show arrivals, then move 4 away to show pupils served. Do three rounds and count how many are left, then compare with the model. Now change one key feature, for example 1 till (2 served), and play three rounds again. Then change a feature that does not matter, such as the tray colour, and see that the answer stays the same. Explain why the colour is not a key feature. If you have a computer or tablet, ask an adult to run a similar model in a spreadsheet.
Practice
1
A simulator will show how many people can use a school library at the same time. Which of these are key features? (a) the number of chairs; (b) the colour of the walls; (c) how many people arrive each minute; (d) the size of the room.
Feature
Key feature?
(a) number of chairs
?
(b) colour of the walls
?
(c) people arriving each minute
?
(d) size of the room
?
(a), (c) and (d) are key features, because they affect how many people can be inside. (b) does not matter for the purpose.
2
Trace the pseudocode and give the output.
Pseudocode
1waiting ← 02arrivals ← 43tills ← 34served ← tills * 25waiting ← waiting + arrivals - served
6waiting ← waiting + arrivals - served
7OUTPUT waiting
served is 2 * 3 = 6. After one minute, waiting is 0 + 4 − 6 = −2. After two minutes it is −4. The program prints −4, which shows a flaw in the model: a queue cannot be below 0.
3
Why does the model of the queue not need the colour of the trays, but it does need the number of tills?
The purpose is to find out how long the queue grows. The number of tills changes how fast pupils are served, but the colour of the trays has no effect on it.
4
The queue model shows 9 pupils waiting after three minutes. Suggest one change a user could try with the simulator to reduce the queue, and say how you would check that it worked.
Open more tills, for example 3 tills if they can serve 6 pupils a minute. Run the model again and compare the number waiting with 9.