Operational Reliability Reports
Capacity Margin Report
Label Reserve
Capacity reports often turn demand and capacity into a reserve label that operators can scan quickly.
Program
Play the script to choose demand and inspect the reserve label.
capacity_margin_report.R
Replay: real traced execution (multi-file project)
demand <- 72
capacity <- 100
reserve <- capacity - demand
status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"
line <- paste(demand, reserve, status)
cat(line, "\n", sep = "")
demand <- 88
capacity <- 100
reserve <- capacity - demand
status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"
line <- paste(demand, reserve, status)
cat(line, "\n", sep = "")
demand <- 95
capacity <- 100
reserve <- capacity - demand
status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"
line <- paste(demand, reserve, status)
cat(line, "\n", sep = "")
demand ← 72
1demand <- 722capacity <- 100values this step72demandcapacity ← 100
1demand <- 722capacity <- 1003reserve <- capacity - demandvalues this step100capacityreserve ← 28
2capacity <- 1003reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"values this step28reserve100capacity72demandstatus ← stable
3reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"5line <- paste(demand, reserve, status)values this stepstablestatus28reserveline ← 72 28 stable
4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"5line <- paste(demand, reserve, status)6cat(line, "\n", sep = "")values this step72 28 stableline72demand28reservestablestatuscat(line, " ", sep = "")
5line <- paste(demand, reserve, status)6cat(line, "\n", sep = "")output72 28 stablevalues this step72 28 stableline
demand ← 88
1demand <- 882capacity <- 100values this step88demandcapacity ← 100
1demand <- 882capacity <- 1003reserve <- capacity - demandvalues this step100capacityreserve ← 12
2capacity <- 1003reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"values this step12reserve100capacity88demandstatus ← watch
3reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"5line <- paste(demand, reserve, status)values this stepwatchstatus12reserveline ← 88 12 watch
4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"5line <- paste(demand, reserve, status)6cat(line, "\n", sep = "")values this step88 12 watchline88demand12reservewatchstatuscat(line, " ", sep = "")
5line <- paste(demand, reserve, status)6cat(line, "\n", sep = "")output88 12 watchvalues this step88 12 watchline
demand ← 95
1demand <- 952capacity <- 100values this step95demandcapacity ← 100
1demand <- 952capacity <- 1003reserve <- capacity - demandvalues this step100capacityreserve ← 5
2capacity <- 1003reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"values this step5reserve100capacity95demandstatus ← tight
3reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"5line <- paste(demand, reserve, status)values this steptightstatus5reserveline ← 95 5 tight
4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"5line <- paste(demand, reserve, status)6cat(line, "\n", sep = "")values this step95 5 tightline95demand5reservetightstatuscat(line, " ", sep = "")
5line <- paste(demand, reserve, status)6cat(line, "\n", sep = "")output95 5 tightvalues this step95 5 tightline
reserve
`capacity - demand` creates the margin used by the rest of the report.
tiered labels
The nested `if` expression maps reserve ranges to stable, watch, or tight.
operator output
The printed line keeps the raw demand and derived reserve visible.