AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Safe to practise

Week 17 · 2.1 Modelling · 3 lessons
2

What the model needs

Computing 8: Topic 2.1, pp. 197–211
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.

pupils arrivingeach minutetills openpupils servedper tillKey featurescolour of thetraysthe menuNot neededCanteen queuesimulator
Worked examples
Pseudocode
1waiting ← 0
2arrivals ← 5
3tills ← 2
4served ← tills * 2
5waiting ← 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 runwaitingserved
10–
404
514
624
734
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 ← 0
2arrivals ← 5
3tills ← 1
4served ← tills * 2
5waiting ← 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.
FeatureKey feature?
(a) number of chairs?
(b) colour of the walls?
(c) people arriving each minute?
(d) size of the room?
2
Trace the pseudocode and give the output.
Pseudocode
1waiting ← 0
2arrivals ← 4
3tills ← 3
4served ← tills * 2
5waiting ← waiting + arrivals - served
6waiting ← waiting + arrivals - served
7OUTPUT waiting
3
Why does the model of the queue not need the colour of the trays, but it does need the number of tills?
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.