{
 "format": "stockflow-1",
 "id": "lib-homework",
 "name": "The homework spiral",
 "notes": "Normally you finish your homework before bedtime. Then a big project arrives on day 10. You stay up late, lose sleep, and become slower, so the next days you stay up even later: a vicious circle. Whether you recover depends on how much homework keeps coming and how fast you catch up on sleep. Compare the two scenarios: staying up late to catch up leaves you tired and slow for weeks, while going to bed on time (Max_Extra_Hours 0.5) clears the pile within days. Sleep influences how much homework you get done. Try: a smaller project, or a longer Recovery_Time. Time unit: days.",
 "sim": {
  "start": 0,
  "stop": 60,
  "dt": 0.25,
  "unit": "days"
 },
 "elements": [
  {
   "id": "h1",
   "type": "stock",
   "name": "Homework_Left",
   "eq": "2",
   "x": 420,
   "y": 220,
   "units": "tasks",
   "doc": "Homework still to do.",
   "nonneg": true
  },
  {
   "id": "h2",
   "type": "stock",
   "name": "Tiredness",
   "eq": "0",
   "x": 420,
   "y": 520,
   "units": "hours of lost sleep",
   "doc": "Lost sleep that has piled up.",
   "nonneg": true
  },
  {
   "id": "h3",
   "type": "flow",
   "name": "New_Homework",
   "eq": "Homework_per_Day + PULSE(Project_Size, Project_Day)",
   "from": null,
   "to": "h1",
   "fx": 180,
   "fy": 220,
   "units": "tasks/day",
   "doc": "Homework given each day, plus a big project on one day.",
   "biflow": false
  },
  {
   "id": "h4",
   "type": "flow",
   "name": "Doing_Homework",
   "eq": "Hours_Working*Speed",
   "from": "h1",
   "to": null,
   "tx": 680,
   "ty": 220,
   "units": "tasks/day",
   "doc": "Homework finished each day.",
   "biflow": false
  },
  {
   "id": "h5",
   "type": "flow",
   "name": "Staying_Up",
   "eq": "MAX(0, Hours_Working - Free_Evening_Hours)",
   "from": null,
   "to": "h2",
   "fx": 180,
   "fy": 520,
   "units": "hours/day",
   "doc": "Hours of sleep lost because you work past bedtime.",
   "biflow": false
  },
  {
   "id": "h6",
   "type": "flow",
   "name": "Catching_Up_Sleep",
   "eq": "Tiredness/Recovery_Time",
   "from": "h2",
   "to": null,
   "tx": 680,
   "ty": 520,
   "units": "hours/day",
   "doc": "Lost sleep made up again, slowly.",
   "biflow": false
  },
  {
   "id": "h7",
   "type": "aux",
   "name": "Speed",
   "eq": "Speed_When_Rested/(1 + Tiredness*Tiredness_Effect)",
   "x": 640,
   "y": 380,
   "units": "tasks/hour",
   "doc": "How fast you work. Tiredness slows you down."
  },
  {
   "id": "h8",
   "type": "aux",
   "name": "Hours_Working",
   "eq": "MIN(Homework_Left/Speed, Free_Evening_Hours + Max_Extra_Hours)",
   "x": 760,
   "y": 100,
   "units": "hours/day",
   "doc": "Hours spent on homework today: enough to finish, but there is a limit to how late you stay up."
  },
  {
   "id": "h9",
   "type": "aux",
   "name": "Homework_per_Day",
   "eq": "3",
   "x": 120,
   "y": 80,
   "units": "tasks/day",
   "doc": "New homework each day.",
   "slider": {
    "min": 0,
    "max": 6,
    "step": 0.5,
    "kind": "assumption"
   }
  },
  {
   "id": "h10",
   "type": "aux",
   "name": "Project_Size",
   "eq": "10",
   "x": 260,
   "y": 60,
   "units": "tasks",
   "doc": "A big project handed out on one day.",
   "slider": {
    "min": 0,
    "max": 30,
    "step": 1,
    "kind": "assumption"
   }
  },
  {
   "id": "h11",
   "type": "aux",
   "name": "Project_Day",
   "eq": "10",
   "x": 400,
   "y": 60,
   "units": "day",
   "doc": "The day the project is given."
  },
  {
   "id": "h12",
   "type": "aux",
   "name": "Speed_When_Rested",
   "eq": "1.5",
   "x": 820,
   "y": 300,
   "units": "tasks/hour",
   "doc": "How fast you work when fully rested.",
   "slider": {
    "min": 0.5,
    "max": 3,
    "step": 0.1,
    "kind": "assumption"
   }
  },
  {
   "id": "h13",
   "type": "aux",
   "name": "Free_Evening_Hours",
   "eq": "2.5",
   "x": 960,
   "y": 160,
   "units": "hours/day",
   "doc": "Hours you can work before bedtime.",
   "slider": {
    "min": 0,
    "max": 5,
    "step": 0.5,
    "kind": "decision"
   }
  },
  {
   "id": "h14",
   "type": "aux",
   "name": "Max_Extra_Hours",
   "eq": "2",
   "x": 960,
   "y": 60,
   "units": "hours/day",
   "doc": "The most you stay up past bedtime.",
   "slider": {
    "min": 0,
    "max": 4,
    "step": 0.5,
    "kind": "decision"
   }
  },
  {
   "id": "h15",
   "type": "aux",
   "name": "Tiredness_Effect",
   "eq": "0.2",
   "x": 820,
   "y": 560,
   "units": "per hour",
   "doc": "How much each hour of lost sleep slows you down.",
   "slider": {
    "min": 0,
    "max": 0.5,
    "step": 0.01,
    "kind": "assumption"
   }
  },
  {
   "id": "h16",
   "type": "aux",
   "name": "Recovery_Time",
   "eq": "4",
   "x": 560,
   "y": 640,
   "units": "days",
   "doc": "How long it takes to catch up on lost sleep.",
   "slider": {
    "min": 1,
    "max": 14,
    "step": 0.5,
    "kind": "assumption"
   }
  }
 ],
 "plots": [
  "h1",
  "h2",
  "h7",
  "h8"
 ],
 "summary": {
  "kpis": [
   {
    "name": "Homework_Left",
    "agg": "final",
    "label": "Homework left at the end",
    "better": "low",
    "format": "num"
   },
   {
    "name": "Tiredness",
    "agg": "max",
    "label": "Most lost sleep",
    "better": "low",
    "format": "num"
   }
  ]
 },
 "scenarios": [
  {
   "id": "hs1",
   "name": "Work late when needed",
   "values": {
    "Max_Extra_Hours": 2
   }
  },
  {
   "id": "hs2",
   "name": "Go to bed on time",
   "values": {
    "Max_Extra_Hours": 0.5
   }
  }
 ]
}