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.

demand
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 = "")
  1. demand ← 72

    1demand <- 722capacity <- 100
    values this step72demand
  2. capacity ← 100

    1demand <- 722capacity <- 1003reserve <- capacity - demand
    values this step100capacity
  3. reserve ← 28

    2capacity <- 1003reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"
    values this step28reserve100capacity72demand
  4. status ← stable

    3reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"5line <- paste(demand, reserve, status)
    values this stepstablestatus28reserve
  5. line ← 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 stableline72demand28reservestablestatus
  6. cat(line, " ", sep = "")

    5line <- paste(demand, reserve, status)6cat(line, "\n", sep = "")
    output72 28 stable
    values this step72 28 stableline
  1. demand ← 88

    1demand <- 882capacity <- 100
    values this step88demand
  2. capacity ← 100

    1demand <- 882capacity <- 1003reserve <- capacity - demand
    values this step100capacity
  3. reserve ← 12

    2capacity <- 1003reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"
    values this step12reserve100capacity88demand
  4. status ← watch

    3reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"5line <- paste(demand, reserve, status)
    values this stepwatchstatus12reserve
  5. line ← 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 watchline88demand12reservewatchstatus
  6. cat(line, " ", sep = "")

    5line <- paste(demand, reserve, status)6cat(line, "\n", sep = "")
    output88 12 watch
    values this step88 12 watchline
  1. demand ← 95

    1demand <- 952capacity <- 100
    values this step95demand
  2. capacity ← 100

    1demand <- 952capacity <- 1003reserve <- capacity - demand
    values this step100capacity
  3. reserve ← 5

    2capacity <- 1003reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"
    values this step5reserve100capacity95demand
  4. status ← tight

    3reserve <- capacity - demand4status <- if (reserve >= 25) "stable" else if (reserve >= 10) "watch" else "tight"5line <- paste(demand, reserve, status)
    values this steptightstatus5reserve
  5. line ← 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 tightline95demand5reservetightstatus
  6. cat(line, " ", sep = "")

    5line <- paste(demand, reserve, status)6cat(line, "\n", sep = "")
    output95 5 tight
    values 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.