Calculate capacity reserve and label whether the reserve is stable, watched, or tight.

reserve report Fixed capacity and demand values can produce a replay-friendly reserve label before any scheduler acts on it.

Capacity Reserve Reliability Report

demand
CapacityReserve.kt
Replay: real traced execution (multi-file project)
fun main() {
    val demand = 72
    val capacity = 100
    val reserve = capacity - demand
    var reserveStatus = "tight"

    if (reserve >= 20) {
        reserveStatus = "stable"
    } else if (reserve >= 10) {
        reserveStatus = "watch"
    }

    println("demand=$demand reserve=$reserve status=$reserveStatus")
}
fun main() {
    val demand = 88
    val capacity = 100
    val reserve = capacity - demand
    var reserveStatus = "tight"

    if (reserve >= 20) {
        reserveStatus = "stable"
    } else if (reserve >= 10) {
        reserveStatus = "watch"
    }

    println("demand=$demand reserve=$reserve status=$reserveStatus")
}
fun main() {
    val demand = 95
    val capacity = 100
    val reserve = capacity - demand
    var reserveStatus = "tight"

    if (reserve >= 20) {
        reserveStatus = "stable"
    } else if (reserve >= 10) {
        reserveStatus = "watch"
    }

    println("demand=$demand reserve=$reserve status=$reserveStatus")
}
  1. demand ← 72, capacity ← 100, reserve ← 28, reserveStatus ← tight

    1fun main() {2    val demand→ 72 = 72 //@demand=88, 953    val capacity→ 100 = 1004    val reserve→ 28 = capacity100 - demand725    var reserveStatus→ tight = "tight"
  2. reserveStatus ← stable

    7if (reserve28 >= 20) {8    reserveStatus→ stable = "stable"9} else if (reserve >= 10) {
  3. println("demand=$demand reserve=$reserve status=$reserveStatus")

    13    println("demand=$demand72 reserve=$reserve28 status=$reserveStatusstable")14}
    outputdemand=72 reserve=28 status=stable
  1. demand ← 88, capacity ← 100, reserve ← 12, reserveStatus ← tight

    1fun main() {2    val demand→ 88 = 883    val capacity→ 100 = 1004    val reserve→ 12 = capacity100 - demand885    var reserveStatus→ tight = "tight"
  2. reserveStatus ← watch

    8    reserveStatus = "stable"9} else if (reserve12 >= 10) {10    reserveStatus→ watch = "watch"11}
  3. println("demand=$demand reserve=$reserve status=$reserveStatus")

    13    println("demand=$demand88 reserve=$reserve12 status=$reserveStatuswatch")14}
    outputdemand=88 reserve=12 status=watch
  1. demand ← 95, capacity ← 100, reserve ← 5, reserveStatus ← tight

    1fun main() {2    val demand→ 95 = 953    val capacity→ 100 = 1004    val reserve→ 5 = capacity100 - demand955    var reserveStatus→ tight = "tight"67    if (reserve >= 20) {8        reserveStatus = "stable"9    } else if (reserve >= 10) {10        reserveStatus = "watch"11    }1213    println("demand=$demand95 reserve=$reserve5 status=$reserveStatustight")14}
    outputdemand=95 reserve=5 status=tight