|
5 | 5 | "id": "0be7dabf-cb34-4faf-abb1-e2c8e735beda", |
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | | - "# Setting initial conditions\n", |
| 8 | + "# Setting Initial Conditions\n", |
9 | 9 | "\n", |
| 10 | + "An alternative to including a warm-up period in a model is to set initial conditions. In our stroke example this would mean adding patients to beds and if required the admission queue. \n", |
10 | 11 | "\n", |
11 | | - "**IMPORTANT: There is still an initialisation bias problem:**\n", |
| 12 | + "🎓 **Why use Initial-Conditions over a Warm-Up?**\n", |
| 13 | + "\n", |
| 14 | + "* While warm-up periods are simpler to code, they can also increase how long it takes to run your model. Setting initial conditions is in theory computationally more efficient (no wasted run-time).\n", |
| 15 | + "\n", |
| 16 | + "* Setting initial-conditions also allows you to test specific starting scenarios, such as \"What happens if the day begins with a full ward?\"\n", |
| 17 | + "\n", |
| 18 | + "**In general, adding initial conditions is more complex than including a warm-up period.**\n", |
| 19 | + "\n", |
| 20 | + "Initial conditions could be \n", |
| 21 | + "\n", |
| 22 | + "1. Fixed i.e. the same number of patients for each replication.\n", |
| 23 | + "2. Random i.e. sampled from a discrete distribution specified by a user.\n", |
| 24 | + "\n", |
| 25 | + "In this notebook we will learn how to add initial conditions to a SimPy model. We will again use the acute stroke pathway model.\n", |
| 26 | + "\n", |
| 27 | + "## IMPORTANT: There is still an initialisation bias problem\n", |
12 | 28 | "\n", |
13 | 29 | "* We load patients into the model before we begin the run. \n", |
14 | 30 | "* If there are $n$ acute stroke beds then the first $n$ patients loaded into the queue will begin service immediately and have a zero queuing time.\n", |
15 | 31 | "* This applies if we have one queue in the model or if we have multiple queues and activities: the time in system metrics will be biased for initial condition patients.\n", |
16 | 32 | "* This is the same problem faced when starting the model from time zero with no patients.\n", |
17 | 33 | "\n", |
18 | 34 | "**Some Options:**\n", |
19 | | - "* Include a setting in a process to switch results collection on and off.\n", |
20 | | - "* Code a seperate process for initial conditions that does not include results collection.\n", |
21 | | - "* Mixed initial conditions and (a shorter) warm-up period.\n", |
| 35 | + "1. Include a setting in a process to switch results collection on and off.\n", |
| 36 | + "2. Code a seperate process for initial conditions that does not include results collection.\n", |
| 37 | + "3. Mixed initial conditions and (a shorter) warm-up period.\n", |
22 | 38 | " * You will need to do some analysis to ensure this is working acceptably.\n", |
23 | 39 | " * The warm-up pushes patients into service and also resets results collection. (deletes an initial transient)." |
24 | 40 | ] |
|
83 | 99 | "\n", |
84 | 100 | "# Acute LoS (Lognormal)\n", |
85 | 101 | "ACUTE_LOS_MEAN = 7.0\n", |
86 | | - "ACUTE_LOC_STD = 1.0\n", |
| 102 | + "ACUTE_LOS_STD = 1.0\n", |
87 | 103 | "\n", |
88 | 104 | "# initial conditions for acute queue + service \n", |
89 | 105 | "# if there are 9 beds then 10 = 1 queuing\n", |
|
129 | 145 | "source": [ |
130 | 146 | "def trace(msg):\n", |
131 | 147 | " \"\"\"\n", |
132 | | - " Turing printing of events on and off.\n", |
| 148 | + " Turning printing of events on and off.\n", |
133 | 149 | "\n", |
134 | 150 | " Params:\n", |
135 | 151 | " -------\n", |
|
166 | 182 | " n_streams=N_STREAMS,\n", |
167 | 183 | " iat_strokes=IAT_STROKES,\n", |
168 | 184 | " acute_los_mean=ACUTE_LOS_MEAN,\n", |
169 | | - " acute_los_std=ACUTE_LOC_STD,\n", |
| 185 | + " acute_los_std=ACUTE_LOS_STD,\n", |
170 | 186 | " n_acute_beds=N_ACUTE_BEDS,\n", |
171 | 187 | " init_cond_params=INIT_COND_PARAMS, \n", |
172 | 188 | " ):\n", |
|
273 | 289 | " Parameters:\n", |
274 | 290 | " ----------\n", |
275 | 291 | " warm_up_period: float\n", |
276 | | - " Duration of warm-up period in simultion time units\n", |
| 292 | + " Duration of warm-up period in simulation time units\n", |
277 | 293 | "\n", |
278 | 294 | " env: simpy.Environment\n", |
279 | 295 | " The simpy environment\n", |
|
296 | 312 | "\n", |
297 | 313 | "The key things to recognise are \n", |
298 | 314 | "\n", |
299 | | - "* We include a optional parameter called `collection_results` that defaults to `True`. We may set this `False` in our functions that setup initial conditions" |
| 315 | + "* We include a optional parameter called `collect_results` that defaults to `True`. We may set this `False` in our functions that setup initial conditions" |
300 | 316 | ] |
301 | 317 | }, |
302 | 318 | { |
|
402 | 418 | " \"\"\"Set up initial conditions with patients already in the acute\n", |
403 | 419 | " stroke queue\n", |
404 | 420 | "\n", |
405 | | - " Parmaters:\n", |
406 | | - " ---------\n", |
| 421 | + " Parameters:\n", |
| 422 | + " -----------\n", |
407 | 423 | " env: simpy.Environment\n", |
408 | 424 | " The simpy environment for the simulation\n", |
409 | 425 | "\n", |
|
0 commit comments