Computational Abstractions: Modelling the State and Behaviour of Real-World Systems
Welcome to your study guide on computational abstractions and modelling! Have you ever wondered how computer scientists create realistic video games, how smart central heating keeps your house cosy, or how planners predict traffic jams before building a new road? They do it using models and abstractions.
Don't worry if these terms sound a bit scientific at first. By the end of these notes, you will see that you use abstraction every single day!
1. What is Abstraction and What is a Model?
Let's start by breaking down the two biggest ideas in this chapter:
Abstraction: This is the process of filtering out and removing unnecessary details so that you can focus only on the essential features that really matter to solve a problem.
Model: A simplified representation of a real-world system or problem. Computer scientists build models to test ideas, understand how things work, and predict the future without having to build the real thing first.
Everyday Analogy: The Underground Tube Map
Think about a famous map of the London Underground. Does it show every tree, building, street corner, and curve of the train tracks? No! It uses straight lines and coloured dots. That is abstraction in action:
• Details kept: The names of the stations and the order they connect in (the essential information a passenger needs).
• Details removed: Surface roads, rivers, depth underground, and exact distances (unnecessary details for planning your route).
Important Distinction: Abstraction vs Decomposition
These two computational thinking terms are easy to mix up, but they do completely different jobs:
• Decomposition: Breaking a big, complicated problem down into smaller, manageable chunks.
• Abstraction: Simplifying a problem by removing distracting or unneeded details.
Memory Trick: Think of Decomposition as Dicing an onion into small pieces. Think of Abstraction as Absorbing only the main point!
Key Takeaway: Abstraction means keeping what is important and ignoring what is not, allowing us to create clear and effective computer models.
2. Understanding "State" and "Behaviour"
Every system we model in computing is made up of two key ingredients: State and Behaviour.
What is "State"?
The state is the current condition or a "snapshot" of a system at one specific point in time. It is usually described by data and values stored in variables.
• Traffic light example: The current state is "Red".
• Central heating example: The current state of the boiler is "Off", and the room temperature is \(17^\circ\text{C}\).
• Automated gate example: The current state is "Closed".
What is "Behaviour"?
The behaviour is the set of rules, logic, or actions that dictate how a system changes from one state to another when an event happens or when an input is received.
• Traffic light example: If the timer reaches \(30\) seconds, then change the state to "Red and Amber".
• Central heating example: If the temperature falls below \(18^\circ\text{C}\), then change the boiler state to "On".
• Automated gate example: If the infrared sensor detects a car, then change the state to "Opening".
Key Takeaway: State is what the system is right now (data/snapshot). Behaviour is what the system does when things change (rules/logic).
3. The Input-Process-Output (IPO) Model
To design any working computational model, computer scientists use the Input-Process-Output (IPO) framework:
1. Input: Data or signals entering the system.
Examples: Temperature sensors, infrared motion detectors, buttons pressed by users, or numbers typed into a spreadsheet.
2. Process: The rules and logic (the computational abstractions) that decide what to do with the inputs.
Examples: Checking if a number is bigger than a limit, calculating a total, or running a timer.
3. Output: The result, action, or physical response produced by the system.
Examples: An actuator turning a motor to open a gate, a light turning green, a heater turning on, or a graph showing predicted profits.
Key Takeaway: Every model follows this cycle: Inputs are fed in, the Process applies logical rules, and the Outputs show the result.
4. Modelling Physical Systems
A physical system is a hardware-based system in the real world. When we model physical systems in computing, we write logical rules to control how machines and electronic components react to the world around them.
Example 1: UK Traffic Light System
A traffic light model must follow a strict sequence of states to keep roads safe:
• State 1: Red (Vehicles must stop)
• State 2: Red and Amber (Get ready)
• State 3: Green (Vehicles can proceed if safe)
• State 4: Amber (Stop if safe to do so)
• The cycle repeats back to State 1 (Red).
The Behaviour Rule: When the timer for a state finishes, transition to the next state in the exact sequence.
Example 2: Central Heating System
Central heating systems rely on a sensor called a thermostat to monitor the room temperature.
• Input: Current temperature from the thermostat (e.g. \(16^\circ\text{C}\)).
• Target Threshold: Desired room temperature (e.g. \(18^\circ\text{C}\)).
• Process (Behaviour Rule): If \(\text{Current Temperature} < 18^\circ\text{C}\), then switch the heater to "On". Else, switch the heater to "Off".
• Output: Boiler actuator switches on or off.
Example 3: Automated Security Gate
• Input: Infrared (IR) sensor detecting an approaching car.
• Process (Behaviour Rule): If \(\text{IR Sensor} = \text{Triggered}\), then send a signal to the motor.
• Output: Electric motor runs to open the gate barrier.
Key Takeaway: Physical systems use sensors for inputs and actuators for outputs, linked together by clear conditional logic rules.
5. Modelling Real-World Problems: Spreadsheets and Simulations
Not all models involve physical hardware. Many models are conceptual or data-driven, helping us understand real-world problems such as managing money or studying population growth.
Spreadsheet Financial Models
Spreadsheets are powerful tools used to model budgets, profit, and loss for businesses or school events.
1. Cell References: Spreadsheets use grid coordinates made of a column letter and a row number (e.g. A1, B4, C12). Always use cell references instead of typing plain numbers so that your model updates automatically!
2. Formulas: In spreadsheet modelling, every formula must start with an equals sign (\(=\)). Standard functions include:
• \(=\text{SUM}(\text{A1:A5})\) — Adds together all numbers in cells A1 to A5.
• \(=\text{AVERAGE}(\text{B1:B10})\) — Finds the mean average of a range.
• \(=\text{MAX}(\text{C1:C20})\) — Finds the largest value in a range.
• \(=\text{MIN}(\text{C1:C20})\) — Finds the smallest value in a range.
• \(=\text{IF}(\text{D2} > 50, \text{"Profit"}, \text{"Loss"})\) — Checks a condition and outputs a result based on whether it is true or false.
"What-If" Analysis (Evaluating Models)
The greatest superpower of a computer model is "What-If" analysis. This means changing one or more input values to observe what happens to the output.
Example: "What if ticket prices for the school disco are raised from \(\text{£3}\) to \(\text{£5}\)? Will our total profit increase, or will fewer students attend?"
Simulations
Simulations are models that show how a system changes over time:
• Traffic Flow Simulations: Testing whether adding a roundabout reduces traffic queues without digging up a real road.
• Population Models: Predicting how animal populations grow or shrink based on food supply and predators.
Key Takeaway: Spreadsheet models and simulations let us test scenarios and make predictions safely and quickly using formulas and "What-if" testing.
6. Boolean Logic in Modelling
Computers make decisions inside models using Boolean logic. The three core logical operators are:
• AND: Both conditions must be true.
Example: If \(\text{Temperature} < 18^\circ\text{C}\) AND \(\text{Timer} = \text{"Active"}\), then turn heater "On".
• OR: At least one condition must be true.
Example: If \(\text{Keycard Swiped}\) OR \(\text{Emergency Button Pressed}\), then unlock door.
• NOT: Inverts the condition (true becomes false, false becomes true).
Example: If NOT \(\text{Obstacle Detected}\), then keep moving forward.
Key Takeaway: Boolean operators (AND, OR, NOT) allow models to handle complex, real-world decision making.
7. Common Mistakes and Pitfalls to Avoid
Watch out for these common traps when working with computational models:
1. Over-complicating the Model: Trying to make a model "too realistic" can ruin it. For example, if you are calculating how long a car takes to drive between two towns, adding factors like the weight of the driver's shoes or wind resistance makes the model too complex to build without adding any useful accuracy!
2. Confusing State and Behaviour: Remember, state is the current data value (e.g. Light is Red), while behaviour is the rule that causes a change (e.g. If 30 seconds pass, change colour).
3. Logic Reversal: Be careful with cause and effect in your rules.
Incorrect: "If the heater is on, the temperature is cold." (This confuses what causes what!)
Correct: "If the temperature is cold, turn the heater on."
4. Hard-coding Values in Spreadsheets: Never type raw numbers into a formula (e.g. \(= 10 + 20\)). Always use cell references (e.g. \(= \text{A1} + \text{B1}\)). If you hard-code numbers, your model cannot perform "What-if" analysis!
8. Quick Summary & Key Terms Checklist
Review this quick checklist before you finish:
• Abstraction: Removing unnecessary details to focus on what is important.
• Model: A simplified computer representation of a real-world system.
• State: The snapshot condition/data of a system right now.
• Behaviour: The logic rules that trigger state changes.
• IPO: Input \(\rightarrow\) Process \(\rightarrow\) Output.
• Spreadsheet Tools: Cell references (e.g. A1), functions (\(\text{SUM}\), \(\text{AVERAGE}\), \(\text{MAX}\), \(\text{MIN}\), \(\text{IF}\)), and "What-if" analysis.
• Logic Operators: AND, OR, and NOT.