TODO: incorporate Skill 5 tasks, rm old lab 7
Skills: 4, 11
The goal of this lab will be to build many functions related to tracking tags.
Given Data Definitions
A PhoneId is a String
Interpretation: a unique identifier for a person's phone
Examples:
PHONE1 = "p1"
PHONE2 = "p2"
Template:
fun phone-id-temp(pi :: String) -> Any:
... pi ...
end
A TagId is a String
Interpretation: a unique identifier for a tracking tag
Examples:
TAG1 = "t1"
TAG2 = "t2"
TAG3 = "t3"
Template:
fun tagid-temp(ti :: String) -> Any:
... ti ...
end
An Owner is a:
data Owner:
| owner(phoneid :: String, tagid :: String)
end
Interpretation: a record of a particular phone owning a tracking tag. There should only ever be one phone per tag, though can be many tags per phone.
Examples:
OWNER1 = owner(PHONE1, TAG1)
OWNER2 = owner(PHONE1, TAG2)
OWNER3 = owner(PHONE2, TAG3)
Template:
fun owner-temp(o :: Owner) -> Any:
... o.phoneid ... o.tagid ...
end
A Time is a Number
Interpretation: a time represented by the number of seconds since Jan 1, 2025.
Examples:
TIME1 = 10
TIME2 = 20
TIME3 = 30
Template:
fun time-temp(t :: Number) -> Any:
... t ...
end
An Encounter is a:
data Posn:
| posn(x :: Number, y :: Number)
end
data Encounter:
| encounter(phoneid :: String, tagid :: String, time :: Number, posn :: Posn)
end
Interpretation: a record of a tag being seen by a given phone at a given time and location. Note that location is represented as X,Y coordinates for simplicity.
Examples:
ENCOUNTER1 = encounter(PHONE1, TAG1, TIME1, posn(0, 0))
ENCOUNTER2 = encounter(PHONE2, TAG1, TIME2, posn(100, 100))
ENCOUNTER3 = encounter(PHONE1, TAG2, TIME3, posn(0, 0))
Template:
fun encounter-temp(e :: Encounter) -> Any:
... e.phoneid ... e.tagid ... e.time ... e.posn ...
end
Problem 1
Design a function tag-activity-count
that takes a TagId, a List<Encounter>
, a start Time, and an end Time, and calculates how many times the tag has been encountered between the two times, including encounters at exactly the start and end times. Assume that the second time is greater than the first.
Problem 2
Design a function tag-encounter-position
that identifies all positions (0-indexed) where a specific TagId appears within a list of Encounters. If the tag id does not occur, the list may be empty.
Problem 3
Location tags can be used maliciously, most prominently for stalking. Abusive ex-partners (or other people) can secretly put tags in their target's car or in an item such as a bag and then use the location mechanism to track the person driving the car or carrying the bag.
Location tags have some privacy protections: tags often will emit an audible beep after separated from their owner for long enough (but those speakers can be intentionally damaged or removed), and given the right software support, might notify a non-owner that they are near. However, these privacy protections are recent additions. The risk of abuse was only taken seriously well after the products were initially released, and indeed, after lawsuits filed alleging the particular use of these tools for stalking.
For more information, see these articles:
- https://freedium.cfd/https://onezero.medium.com/-cybersecurity-workers-need-to-learn-from-victims-9db34f3db198
- https://apnews.com/article/apple-airtags-stalking-lawsuits-e59166988920c4ba1e82956ea85c1677
In order to design location tags to minimize privacy risks from the beginning, we should analyze their privacy using the below table:
Question | Answer |
---|---|
What type of information is shared? | [to be filled in] |
Who is the subject of the information? | [to be filled in] |
Who is the sender of the information? | The location tag device |
Who are the potential recipients of the information? | Intended: The purchaser of the tag who uses it to track their own belongings Unintended: [to be filled in] |
What principles govern the collection and transmission of the information? | Purchase implies consent to tracking one's own items. People who are unknowingly being tracked have not consented to the transmission of information about their location. There is minimal regulation on who can buy/use tags or what properties the tags have. Data is transmitted through global phone network without verification of legitimate use. |
For any gaps, include them in comments. For unintended recipients, list one recipient directly mentioned in the setup above and two additional unique categories of unintended recipients.
OLD LAB:
Skills: 4, 5, 12
Introduction
In this lab, you're developing the management system for a smart renewable energy grid. The system tracks solar panels, wind turbines, battery storage units, and energy consumption across multiple facilities. You have been given the following data definitions to work with:
# DEFINITION
data EnergySource:
| solar-panel(location :: String, capacity :: Number, efficiency :: Number, hours-sunlight :: Number)
| wind-turbine(location :: String, capacity :: Number, wind-speed :: Number, operational :: Boolean)
| battery-storage(location :: String, max-capacity :: Number, current-charge :: Number, charge-rate :: Number)
| energy-consumer(location :: String, demand :: Number, priority :: String, building-type :: String)
end
# EXAMPLES
empty-grid = empty
residential-grid = [list:
solar-panel("Roof A", 10, 85, 8),
battery-storage("Garage", 50, 30, 5),
energy-consumer("House 1", 15, "high", "residential")]
industrial-grid = [list:
solar-panel("Factory Roof", 100, 90, 7),
wind-turbine("Hill Site", 150, 25, true),
wind-turbine("Coast Site", 200, 30, true),
battery-storage("Main Storage", 500, 200, 25),
battery-storage("Backup Storage", 300, 150, 15),
energy-consumer("Factory A", 80, "critical", "industrial"),
energy-consumer("Office Block", 25, "medium", "commercial"),
energy-consumer("Warehouse", 40, "low", "industrial")]
campus-grid = [list:
solar-panel("Library Roof", 50, 88, 6),
solar-panel("Gym Roof", 30, 82, 6),
wind-turbine("Campus Hill", 75, 20, false),
battery-storage("Central Battery", 200, 120, 20),
energy-consumer("Library", 35, "high", "educational"),
energy-consumer("Dorm", 45, "high", "residential"),
energy-consumer("Cafeteria", 20, "medium", "commercial")]
Problem 1
Design a function count-sources
that counts the total number of energy sources in the given grid.
Problem 2
Design a function count-operational-turbines
that counts only wind turbines that are operational.
Problem 3
Design a function total-solar-capacity
that calculates the total capacity of all solar panels in a grid.
Problem 4
Design a function repair-all-turbines
that sets all wind turbines to operational status.
Problem 5
Data centers are putting a strain on energy grids across the country. Currently around 4% of electricity goes to data centers. (For context: roughly 15% of energy use, including electricity, goes to residences.) This is expected to increase to 15% by 2028.
For more, see these articles:
- https://www.boston25news.com/news/local/rise-ai-use-puts-larger-strain-aging-electrical-grid/EMU75CUB6BCJJB6VS5ZTPX55KM/
- https://www.economist.com/business/2025/07/28/how-big-tech-plans-to-feed-ais-voracious-appetite-for-power
In most cases, the costs of building out the power plants and new transmission lines to meet this new demand are passed onto the consumer.
When data centers use more energy, this leaves less energy for things like air conditioning, heating, and lighting. Imagine your analysis of the energy grid reveals that data centers are using 10% of the local electricity. During the hot months of summer, when people are cranking their AC, this has contributed to power outages in certain neighborhoods. There is a proposal to add another data center which will bump data centers’ total energy use up to 13% of the local electricity. You estimate this addition will double the number of summer outages.
Part A
In order to assess the proposal, fill out the stakeholder matrix. Identify one more stakeholder. Identify at least two interests for each stakeholder.
Stakeholders | Interests or Values |
---|---|
Vulnerable Populations (e.g. elderly) | [to be filled in] |
Standard Populations (e.g. healthy adults) | [to be filled in] |
[Additional stakeholder to be identified] | [to be filled in] |
Part B
What are two conflicts of interests in your chart? For each case of conflict, which one do you think is more important? Why?
Part C
Do you think the additional data center should be added? Why or why not?