COP 3223H meeting -*- Outline -*- * Modeling with Programs ** What programs do Imagine a program that flies an airplane (an autopilot)... ------------------------------------------ WHAT A PROGRAM DOES How does a program control an airplane (or a car, etc.)? environment environment | ^ v [---------] | sensors and --> [ Program ] ---> actuators input devices [---------] and output devices ------------------------------------------ This may look like a one time event, but it can be repeated over and over, e.g., every 0.1 second An interactive program just repeats this cycle with the user as part of the environment Q: What are some examples of sensors or input devices? for an airplane, things like: wind speed, position, altitude, ... In a smartphone, things like: position, presses on the screen (with their positions) On a laptop computer: keyboard, mouse (with positions), battery level... Q: What are some examples of actuators or output devices? for an airplane, things like: hydralauics that control flaps, flow of fuel to the engines, ... In a smartphone or laptop, things like: the display, the speakers, a wireless connection to the internet (you could think of a printer or a port connected to it also as an output device) *** The OS helps abstract away devices ------------------------------------------ FROM THE POINT OF VIEW OF THE PROGRAM With the help of the Operating System (OS): [---------] input data --> [ Program ] ---> output data [---------] ------------------------------------------ The operating system allows us to make this abstraction, as it handles dealing with the devices at a low level The OS presents to the program data in a format it can understand (e.g., character strings) *** Why we can model programs using simple inputs and outputs ------------------------------------------ SOPHISTICATED DEVICE CONTROL ISN'T NEEDED An old application: Artillery range finding Problem: what angle to aim an artillery piece at to hit a certain target (at a given distance)? Solution: Some person tells the operator where to shoot (the environment) Some types into the computer the distance (input). The program does a calculation (using physics) The program prints out the angle (output). The operator adjusts the angle (actuator). ------------------------------------------ In this app the program substitutes for a table/book that gives angles ** The conclusion about modeling ------------------------------------------ THE CONCLUSION ABOUT MODELING Abstractly every computer program is "blind" but models the real world environment's change to state environment (user's question) (user's answer) | ^ | encoding | interpretation v | representation -->[Program]--> output as input representation ------------------------------------------ The key idea is that the inputs and outputs of the program are not themselves reality, but *represent* reality. Inputs and outputs are always interpreted (given meaning) by the user or the environment. This leads us to looking at the data we can use in modeling...