Simulations

Help Questions

AP Computer Science Principles › Simulations

Questions 1 - 10
1

A transportation agency uses a traffic flow simulation to test a new bus-only lane downtown. The real-world problem is predicting whether reallocating one lane improves total travel time or just shifts congestion. The simulation represents vehicles as agents that follow basic rules: maintain safe distance, accelerate when space opens, and stop at red lights. Variables include vehicleDensity (15–90 vehicles/km/lane), lightCycleTime (50–150 seconds), and peakHourFactor (1.0–3.0) that increases arrivals near 8 a.m. The algorithm iterates each second: it spawns vehicles based on peakHourFactor, updates positions and speeds, and records queue lengths at intersections. After a full simulated hour, it computes average delay per vehicle. To refine results, it repeats the hour-long simulation across many random arrival patterns, then modifies lightCycleTime to reduce the worst delays while keeping cross-street waits within a fairness limit. Scenario-specific example: at very high vehicleDensity, even a well-tuned lightCycleTime may not prevent gridlock if too many vehicles enter the network.

Bus paint color, because brighter buses reduce average delay for all drivers.

Weathering of road signs, because it sets peakHourFactor automatically.

vehicleDensity, because it directly determines whether the network approaches gridlock under heavy demand.

Street name length, because longer names slow vehicles at intersections.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models traffic flow to evaluate a bus lane proposal, with variables like vehicleDensity, lightCycleTime, and peakHourFactor affecting congestion levels. Choice A is correct because vehicleDensity directly determines how many vehicles occupy the road network - at very high densities, the network approaches gridlock regardless of signal timing optimization. Choices B, C, and D are incorrect because they reference factors (street name length, bus color, sign weathering) that aren't part of the simulation's mathematical model. To help students, emphasize identifying which variables actually appear in the algorithm versus irrelevant details. Practice recognizing the key parameters that drive simulation behavior. Watch for students being distracted by plausible-sounding but algorithmically irrelevant factors.

2

A county health department runs an epidemiological simulation to decide whether to reopen indoor sports. The real-world problem is balancing normal activities with preventing a surge that overwhelms clinics. The model uses daily steps and tracks Susceptible, Infected, and Recovered people. Variables include infectionRate (0.10–0.50 per close contact), recoveryRate (0.05–0.25 per day), and populationDensity (low/medium/high contact levels). Each day, the algorithm estimates how many susceptible people become infected based on contacts and infectionRate, then estimates recoveries based on recoveryRate. It repeats for 120 days. To refine results iteratively, analysts run 200 simulations per setting, average the infection curves, and then recalibrate infectionRate if the first two weeks of simulated cases do not match observed case counts. Scenario-specific example: if recoveryRate increases from 0.10 to 0.20, infected people leave the infected state faster, often reducing the peak number of simultaneous infections even if infectionRate remains unchanged.

Increasing recoveryRate removes randomness, so only one run is needed for accuracy.

Increasing recoveryRate generally raises the peak by keeping people infectious for longer.

Increasing recoveryRate forces populationDensity to become high in the next iteration.

Increasing recoveryRate generally lowers the peak by shortening how long people remain infected.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models disease spread using an SIR framework, with variables like infectionRate, recoveryRate, and populationDensity affecting epidemic dynamics. Choice A is correct because increasing recoveryRate means infected people recover faster, spending less time in the infectious state, which reduces the number of susceptible people they can infect, thereby lowering the peak number of simultaneous infections. Choice B is incorrect because it reverses the effect - higher recovery rate shortens, not lengthens, the infectious period. To help students, emphasize understanding how each variable affects the system dynamics. Practice tracing through what happens when recovery speeds up versus slows down. Watch for students confusing the direction of effects or mixing up which variables control which aspects of the simulation.

3

An urban planning office builds a traffic flow simulation to reduce commute times near a stadium. The real-world problem is that congestion spikes after events, and officials want to test signal plans without disrupting actual roads. The simulation models roads as connected segments with intersections; each vehicle has a position, speed, and route choice. Variables include vehicleDensity (10–80 vehicles per kilometer per lane), lightCycleTime (40–140 seconds), and peakHourFactor (1.0–2.5 multiplier that increases arrivals). The algorithm advances in small time steps: it injects new vehicles based on peakHourFactor, moves vehicles forward if space is available, and stops vehicles at red lights. At each intersection, it estimates queue length and average delay. To refine results iteratively, it runs a batch of trials, then adjusts lightCycleTime and green-split ratios to reduce the worst intersection delay, repeating until improvements taper off. Scenario-specific example: shortening lightCycleTime from 120 seconds to 60 seconds can reduce long queues on side streets but may increase stops on the main avenue if green time becomes too fragmented.

By changing vehicle routes randomly each step without using delay measurements.

By calculating one perfect timing plan from the first run and never revisiting it.

By rerunning trials, then adjusting signal timing to reduce measured delay until gains plateau.

By increasing peakHourFactor after each run so congestion always rises.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models traffic flow to optimize signal timing, with variables like vehicleDensity, lightCycleTime, and peakHourFactor affecting congestion patterns. Choice A is correct because it accurately describes the iterative refinement process: running multiple trials, measuring delay outcomes, adjusting signal timing based on results, and repeating until improvements plateau. Choice B is incorrect because it suggests a one-time calculation without iteration, missing the core concept of iterative refinement in simulations. To help students, emphasize the iterative nature of simulations and how feedback from results guides parameter adjustments. Practice identifying the refinement loop in simulation descriptions. Watch for students assuming simulations produce perfect answers immediately rather than improving through iteration.

4

A university clinic tests an epidemiological simulation to evaluate mask distribution on campus. The real-world problem is deciding how many masks to stock and where to distribute them to reduce spread. The model tracks Susceptible, Infected, and Recovered individuals using daily updates. Variables include infectionRate (0.08–0.55 per close contact), recoveryRate (0.06–0.22 per day), and populationDensity (low/medium/high), which affects how many close contacts occur. The algorithm starts with a small infected group, then each day computes new infections from contacts and infectionRate and computes recoveries from recoveryRate. It repeats for a semester. To refine results iteratively, the clinic runs many simulations, compares early simulated case counts to actual testing data, and adjusts infectionRate downward to represent mask effectiveness when the model overestimates cases. Scenario-specific example: lowering infectionRate from 0.30 to 0.15 typically reduces total infections and delays the peak, especially in high populationDensity dorm settings.

Lowering infectionRate has no effect because only recoveryRate controls spread.

Lowering infectionRate typically reduces total infections and can delay the infection peak.

Lowering infectionRate forces populationDensity to rise to keep contacts constant.

Lowering infectionRate typically increases infections by making recoveryRate less effective.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models disease spread to evaluate mask distribution effectiveness, with variables like infectionRate, recoveryRate, and populationDensity affecting transmission dynamics. Choice A is correct because lowering infectionRate reduces the probability of transmission per contact, which typically results in fewer total infections and can delay when the infection peak occurs, especially important in high-density settings. Choice B is incorrect because it suggests lowering infection rate increases infections, which contradicts the basic mechanism of disease transmission. To help students, emphasize understanding how each parameter affects the simulation mechanistically. Practice tracing through how reduced transmission probability affects epidemic curves. Watch for students confusing the effects of different parameters or assuming counterintuitive relationships.

5

A coastal research group uses a simplified climate change model to help a town decide whether to raise seawalls. The real-world problem is estimating how different emissions policies influence future flooding risk. The simulation uses yearly time steps. Variables include emissionReduction (0%–80% reduction from today’s emissions), temperatureIncrease (in °C, updated each year), and seaLevelRise (in centimeters). The algorithm begins with current temperature and sea level, then each year adds warming based on remaining emissions (after emissionReduction). It then updates seaLevelRise using a rule that higher temperatureIncrease accelerates melting and expansion. A feedback loop is included: as temperatureIncrease grows, the same emissions cause slightly more warming the next year (representing amplifying effects like reduced ice reflectivity). The model iteratively refines results by running multiple scenarios, comparing simulated temperature trends to recent observed warming, and adjusting a sensitivity setting within a plausible range if the model consistently overshoots or undershoots. Scenario-specific example: moving emissionReduction from 20% to 60% typically lowers temperatureIncrease over decades and slows seaLevelRise, though the sea level may still climb due to earlier warming already “in the system.”

Assuming seaLevelRise instantly stops whenever emissionReduction exceeds 50%.

Assuming emissionReduction is irrelevant because temperatureIncrease is fixed at the start.

Assuming seaLevelRise directly sets next year’s emissions without policy input.

Assuming yearly warming depends on remaining emissions and can amplify as temperatures rise.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models climate change effects on sea level, with variables like emissionReduction, temperatureIncrease, and seaLevelRise interacting through feedback loops. Choice B is correct because it accurately captures the model's assumption that yearly warming depends on remaining emissions (after reduction) and includes amplifying feedback effects as temperatures rise. Choice A is incorrect because it oversimplifies the relationship, suggesting immediate cessation of sea level rise at 50% reduction, which ignores the cumulative nature of warming. To help students, emphasize understanding feedback loops and cumulative effects in simulations. Practice identifying how variables influence each other over multiple time steps. Watch for students assuming immediate cause-effect relationships when processes accumulate over time.

6

A city council commissions a traffic flow simulation to choose between two signal plans for a busy corridor. The real-world problem is that residents complain about long waits, but changing signal timing in the real world can cause accidents and confusion. The simulation models each intersection with a queue and each vehicle with a simple movement rule: move forward if space exists and the light is green; otherwise wait. Variables include vehicleDensity (20–100 vehicles/km/lane), lightCycleTime (45–160 seconds), and peakHourFactor (1.0–2.8) controlling arrival surges. The algorithm proceeds in one-second steps for a simulated hour, updates queues, and records average delay and maximum queue length. It iteratively refines results by rerunning the hour under many random arrival patterns, then adjusting lightCycleTime and green splits to reduce maximum queue length while keeping average delay acceptable. Scenario-specific example: increasing lightCycleTime can reduce lost time from frequent switching, but if too long, it can create very large queues on the red approaches during peakHourFactor surges.

Increasing lightCycleTime can reduce switching loss, but overly long cycles can worsen red-approach queues.

Increasing lightCycleTime eliminates peakHourFactor because arrivals no longer vary by time.

Increasing lightCycleTime directly reduces vehicleDensity by removing cars from the network.

Increasing lightCycleTime always decreases queues, regardless of vehicleDensity or peakHourFactor.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models traffic signal timing effects, with variables like vehicleDensity, lightCycleTime, and peakHourFactor affecting queue formation and delays. Choice B is correct because it accurately captures the trade-off: longer cycles reduce time lost to switching between phases (improving efficiency), but excessively long cycles can create very large queues on approaches waiting for their green phase. Choice A is incorrect because it suggests increasing cycle time always improves conditions, ignoring the queue buildup problem. To help students, emphasize understanding trade-offs in simulation parameters where changes can have both positive and negative effects. Practice analyzing how the same parameter change affects different performance metrics. Watch for students assuming parameter changes have only beneficial or only harmful effects.

7

A science class builds a simplified climate change simulation to evaluate a proposal for cutting school-district emissions. The real-world problem is understanding long-term consequences of policy choices without waiting decades. The model updates once per year. Variables include emissionReduction (0%–70%), temperatureIncrease (°C, cumulative), and seaLevelRise (cm). Each year, the algorithm computes remaining emissions after emissionReduction, increases temperatureIncrease by a small amount based on those emissions, and then increases seaLevelRise based on the updated temperatureIncrease. A feedback loop is included: higher temperatureIncrease slightly increases the next year’s warming rate, representing amplifying processes. The simulation iteratively refines results by running multiple emissionReduction scenarios, comparing early-year temperature changes to recent regional observations, and adjusting a sensitivity parameter within a reasonable range to improve alignment. Scenario-specific example: even with emissionReduction raised from 10% to 50%, seaLevelRise may continue increasing for many years because temperatureIncrease accumulates over time.

Because temperatureIncrease is cumulative, so earlier warming continues influencing seaLevelRise over time.

Because emissionReduction only changes ocean height, not temperatureIncrease in the model.

Because seaLevelRise decreases emissions directly, forcing temperatureIncrease to stabilize quickly.

Because the model assumes feedback loops always cancel warming after one year.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models climate change impacts with cumulative effects, where variables like emissionReduction, temperatureIncrease, and seaLevelRise interact over time. Choice B is correct because the model treats temperatureIncrease as cumulative - warming from previous years remains in the system and continues driving sea level rise even after emissions are reduced. Choice A is incorrect because it suggests sea level rise directly reduces emissions, which reverses the causal relationship in the model. To help students, emphasize understanding cumulative versus instantaneous effects in simulations. Practice identifying when past states continue influencing future outcomes. Watch for students assuming all effects reset each time step rather than accumulating over the simulation run.

8

According to the scenario, a school board uses an epidemiological simulation to evaluate a policy of staggered lunches. The real-world problem is reducing outbreaks while keeping classes in person. The simulation runs in daily steps and tracks Susceptible, Infected, and Recovered students. infectionRate (0.05–0.25) applies per close contact, and contactRate (5–25 contacts per day) changes with lunch scheduling. recoveryRate (0.10–0.35) controls how quickly students leave the infected state. populationDensity (low/medium/high) scales how many close contacts occur in shared spaces. The algorithm performs repeated runs: set initial parameters, simulate 45 days, compare peakInfected to a threshold the nurse can manage, then adjust contactRate assumptions for different lunch schedules and rerun until results stabilize. Example: reducing contactRate from 20 to 12 through staggered lunches often lowers peakInfected even if infectionRate stays the same. What impact does changing contactRate have in the simulation?

Lower contactRate generally reduces transmission opportunities and can decrease peakInfected.

Lower contactRate raises recoveryRate automatically, so the disease disappears instantly.

Lower contactRate affects only recovered students, since susceptible students are unchanged.

Lower contactRate increases populationDensity, so infections spread faster in hallways.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models disease spread in a school with staggered lunch schedules, where contactRate (5-25 contacts per day) represents how many close interactions students have, which can be reduced through policy changes. Choice A is correct because lower contactRate reduces the number of transmission opportunities - with fewer close contacts per infected student per day, the disease spreads more slowly through the population, typically resulting in a lower peak number of infected students. Choice C is incorrect because it misunderstands the independence of parameters - contactRate and recoveryRate are separate variables in the model; changing one doesn't automatically change the other, and lower contact rates slow spread rather than making the disease disappear instantly. To help students, emphasize understanding how behavioral interventions map to model parameters and how reducing transmission opportunities affects epidemic curves. Practice by having students calculate the expected number of new infections per day under different contact scenarios.

9

Based on the simulation described, an environmental science class builds a climate change model to explore local sea-wall planning. The real-world problem is estimating future flooding risk without waiting decades for measurements. The simulation advances year by year from 2025 to 2100. CarbonEmissionIndex starts at 100 and changes by emissionReduction (0%–5% per year). TemperatureIncrease (in °C) rises when emissions stay high, and SeaLevelRise (in cm) increases as temperature rises. A simple feedback loop is included: as TemperatureIncrease grows, iceMeltFactor (low/medium/high) increases, which further accelerates SeaLevelRise in later years. The algorithm runs multiple scenarios, compares outputs to historical temperature records for calibration, and then repeats with slightly adjusted sensitivity values until the 1990–2020 trend is closely reproduced. Example: setting emissionReduction to 3% per year slows TemperatureIncrease, which later reduces SeaLevelRise compared with 0% reduction. Which factor is most critical to the simulation's accuracy?

Using a single fixed iceMeltFactor that never changes with temperature, for simplicity.

Assuming SeaLevelRise decreases whenever TemperatureIncrease increases, to balance the model.

Choosing any emissionReduction value, because outcomes stay nearly identical across scenarios.

Calibrating sensitivity so the model reproduces the historical 1990–2020 temperature trend.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models climate change impacts from 2025 to 2100, with variables like emissionReduction (0%-5% per year) and iceMeltFactor (low/medium/high) affecting temperature increase and sea level rise through feedback loops. Choice A is correct because calibrating sensitivity to reproduce the historical 1990-2020 temperature trend ensures the model's parameters are grounded in reality before making future projections - this validation step is critical for simulation accuracy. Choice C is incorrect because it misunderstands the feedback mechanism - the passage explicitly states that iceMeltFactor increases as temperature rises, not that it remains fixed, which is essential for modeling accelerating effects. To help students, emphasize the importance of model validation against historical data before using simulations for predictions. Practice by having students identify which parameters need calibration and understand how feedback loops create non-linear effects in complex systems.

10

Based on the simulation described, an urban planning team uses a traffic flow simulation to evaluate adding a dedicated bus lane downtown. The real-world problem is that buses run late during peak commuting times. The model treats vehicles as agents that move block by block, constrained by laneCapacity (10–30 vehicles per block) and vehicleDensity (low/medium/high). Traffic lights use greenTime (15–50 seconds) and can prioritize buses with busPriority (on/off), which shortens bus waiting time but may increase car delay. Each iteration simulates 90 minutes, computes busOnTimeRate and carAverageDelay, then adjusts greenTime and busPriority rules to meet a target of 85% on-time buses while keeping carAverageDelay under 3 minutes. The loop repeats until both metrics change by less than 1% across two iterations. Example: turning busPriority on improves busOnTimeRate, but if greenTime stays unchanged, cross-street queues can grow. What assumption is made in the simulation about laneCapacity?

LaneCapacity stays within a chosen range for a run and constrains movement block by block.

LaneCapacity increases automatically whenever vehicleDensity is high, without any constraint.

LaneCapacity is irrelevant because vehicles ignore space limits and never form queues.

LaneCapacity is computed after the simulation ends, so it cannot affect bus delays.

Explanation

This question tests AP Computer Science Principles skills, specifically understanding and analyzing simulations. Simulations use algorithms to model real-world processes, allowing variable manipulation to predict outcomes. They iterate through scenarios, refining results to improve accuracy. In this scenario, the simulation models traffic flow with dedicated bus lanes, where laneCapacity (10-30 vehicles per block) constrains how many vehicles can occupy each road segment. Choice A is correct because it accurately describes how laneCapacity functions as a constraint - it stays within a chosen range for each simulation run and limits vehicle movement block by block, creating realistic queue formation when demand exceeds capacity. Choice B is incorrect because it misunderstands the nature of constraints in simulations - laneCapacity is a fixed parameter for each run that creates bottlenecks, not something that automatically adjusts to accommodate high vehicleDensity. To help students, emphasize understanding how constraints in simulations mirror real-world physical limitations. Practice by having students identify which parameters represent fixed constraints versus dynamic variables, and trace how constraints lead to emergent behaviors like queue formation.

Page 1 of 2