Week 7 Assignment

Based on the model created on Week 3 Assignment, add the schedules, weights and processes that are closely related to your model, if it is a real scenario, or the most probable values, if it is a generic process.

Prepare an essay with a summary of the changes performed on your model, and evaluate how its performance changed from the original model to the modified one.

For Week 3 I modeled a simplified coffee-shop queue in R using the package {simmer}. The first version of the model featured a single cashier with fixed service times, and deterministically specified arrival times. The drawback to this simple model is that it often results in long waits during bursts of arrivals.

For Week 7 I introduced realistic features: a time-of-day demand surge (“morning rush”), stochastic service times, and a two-stage workflow (cashier then barista). I then compared performance versus a baseline with constant arrivals.

library(simmer)
## Warning: package 'simmer' was built under R version 4.3.3
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:simmer':
## 
##     select
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
set.seed(123)
# ---- Trajectory (customer path) ----
cust_traj <- trajectory("customer path") %>%
seize("cashier", 1) %>%
timeout(function() rnorm(1, mean = 4, sd = 1)) %>%
release("cashier", 1) %>%
seize("barista", 1) %>%
timeout(function() rnorm(1, mean = 3, sd = 0.5)) %>%
release("barista", 1)

Helper: run one scenario

run_scenario <- function(name, cashiers, baristas, gen_dist, until_min = 60) {
env <- simmer(name) %>%
add_resource("cashier", capacity = cashiers) %>%
add_resource("barista", capacity = baristas) %>%
add_generator("cust", cust_traj, distribution = gen_dist)

env %>% run(until = until_min)

arr <- get_mon_arrivals(env)
# waiting = (time in system) - (service time)
summ <- arr %>%
mutate(sojourn = end_time - start_time,
wait = pmax(sojourn - activity_time, 0)) %>%
summarise(
customers = n(),
avg_wait_min = mean(wait),
p95_wait_min = quantile(wait, 0.95),
avg_system_min = mean(sojourn),
avg_service_min= mean(activity_time)
) %>%
mutate(scenario = name, .before = 1)

list(env = env, arrivals = arr, summary = summ)
}

Scenario A: Baseline (with constant arrivals)

baseline <- run_scenario(
name = "Baseline: 2 cashiers + 1 barista, constant arrivals",
cashiers = 2,
baristas = 1,
gen_dist = function() 1.5, # interarrival = 1.5 min
until_min = 60
)

Scenario B: Morning Rush (using absolute times)

(0–30 min every 0.5 min, 30–60 min every 2 min)

rush_times <- c(seq(0, 29.5, by = 0.5), # busy window
seq(30, 60, by = 2)) # slower window
morning_rush_dist <- at(rush_times)

rush <- run_scenario(
name = "Morning Rush: 2 cashiers + 1 barista, arrivals by AT()",
cashiers = 2,
baristas = 1,
gen_dist = morning_rush_dist,
until_min = 60
)

Comparison table

comparison <- bind_rows(baseline$summary, rush$summary) %>%
select(scenario, customers, avg_wait_min, p95_wait_min, avg_system_min, avg_service_min)

print(comparison, digits = 3)
##                                                 scenario customers avg_wait_min
## 1    Baseline: 2 cashiers + 1 barista, constant arrivals        17         13.4
## 2 Morning Rush: 2 cashiers + 1 barista, arrivals by AT()        18         20.2
##   p95_wait_min avg_system_min avg_service_min
## 1         25.6           20.1            6.76
## 2         40.9           27.3            7.11

The enhanced Week 7 model with a morning-rush arrival schedule revealed how transient surges dramatically increase queueing and system time even when resource capacities remain constant. While the baseline system handled steady demand efficiently, the morning-rush scenario showed that targeted staffing or workflow adjustments are essential to maintain service quality during peak periods. Simulation provides valuable insights for capacity planning and operational decision-making in service systems.