|
9 | 9 | "\n",
|
10 | 10 | "## Why do you need a warm-up period?\n",
|
11 | 11 | "\n",
|
12 |
| - "Typically when you are modelling a non-terminating system, you will need to deal with **initialisation bias**. That is the real system always has work-in-progress (e.g. patients in queues and in service), but the model starts from empty. One way to do this is to split the model's run length into warm-up and data collection periods. We discard all results in the warm-up period.\n", |
| 12 | + "Typically when you are modelling a non-terminating system, you will need to deal with **initialisation bias**. That is the real system always has work-in-progress (e.g. patients in queues and in service), but the model starts from empty. One way to deal with this is to split the model's run length into warm-up and data collection periods. We discard all results in the warm-up period.\n", |
13 | 13 | "\n",
|
14 | 14 | "> In this tutorial we will focus on coding a warm-up period in Python and SimPy rather than analysis to determine its length\n",
|
15 | 15 | "\n",
|
|
37 | 37 | },
|
38 | 38 | {
|
39 | 39 | "cell_type": "code",
|
40 |
| - "execution_count": 1, |
| 40 | + "execution_count": null, |
41 | 41 | "id": "c1cee9f9-8696-4b13-94ff-bee2a2a2e5f8",
|
42 | 42 | "metadata": {},
|
43 | 43 | "outputs": [],
|
|
49 | 49 | },
|
50 | 50 | {
|
51 | 51 | "cell_type": "code",
|
52 |
| - "execution_count": 2, |
| 52 | + "execution_count": null, |
53 | 53 | "id": "ea3d507f-9e6d-4ff0-8b90-f9c63c8a8bdf",
|
54 | 54 | "metadata": {},
|
55 | 55 | "outputs": [],
|
|
71 | 71 | },
|
72 | 72 | {
|
73 | 73 | "cell_type": "code",
|
74 |
| - "execution_count": 3, |
| 74 | + "execution_count": null, |
75 | 75 | "id": "1ecf0429-f03f-4ad2-abb4-46692a74e559",
|
76 | 76 | "metadata": {},
|
77 | 77 | "outputs": [],
|
|
96 | 96 | "\n",
|
97 | 97 | "# run variables (units = days)\n",
|
98 | 98 | "WU_PERIOD = 0.0\n",
|
99 |
| - "RC_PERIOD = 100" |
| 99 | + "RC_PERIOD = 100.0" |
100 | 100 | ]
|
101 | 101 | },
|
102 | 102 | {
|
|
109 | 109 | },
|
110 | 110 | {
|
111 | 111 | "cell_type": "code",
|
112 |
| - "execution_count": 4, |
| 112 | + "execution_count": null, |
113 | 113 | "id": "52c9271f-1d05-454d-a199-8768bdf5b6e8",
|
114 | 114 | "metadata": {},
|
115 | 115 | "outputs": [],
|
|
137 | 137 | },
|
138 | 138 | {
|
139 | 139 | "cell_type": "code",
|
140 |
| - "execution_count": 5, |
| 140 | + "execution_count": null, |
141 | 141 | "id": "576ae9b4-b21b-4ed0-9b13-e5898d423173",
|
142 | 142 | "metadata": {},
|
143 | 143 | "outputs": [],
|
|
236 | 236 | },
|
237 | 237 | {
|
238 | 238 | "cell_type": "code",
|
239 |
| - "execution_count": 6, |
| 239 | + "execution_count": null, |
240 | 240 | "id": "dff74a08-37fd-4b18-8bcd-97994f38369a",
|
241 | 241 | "metadata": {},
|
242 | 242 | "outputs": [],
|
|
248 | 248 | " Parameters:\n",
|
249 | 249 | " ----------\n",
|
250 | 250 | " warm_up_period: float\n",
|
251 |
| - " Duration of warm-up period in simultion time units\n", |
| 251 | + " Duration of warm-up period in simulation time units\n", |
252 | 252 | "\n",
|
253 | 253 | " env: simpy.Environment\n",
|
254 | 254 | " The simpy environment\n",
|
|
276 | 276 | },
|
277 | 277 | {
|
278 | 278 | "cell_type": "code",
|
279 |
| - "execution_count": 7, |
| 279 | + "execution_count": null, |
280 | 280 | "id": "911528e1-e4eb-4307-bb26-632faf7769d1",
|
281 | 281 | "metadata": {},
|
282 | 282 | "outputs": [],
|
|
328 | 328 | },
|
329 | 329 | {
|
330 | 330 | "cell_type": "code",
|
331 |
| - "execution_count": 8, |
| 331 | + "execution_count": null, |
332 | 332 | "id": "b3e686ce-5371-4471-a052-b9d43309bc85",
|
333 | 333 | "metadata": {},
|
334 | 334 | "outputs": [],
|
|
371 | 371 | },
|
372 | 372 | {
|
373 | 373 | "cell_type": "code",
|
374 |
| - "execution_count": 9, |
| 374 | + "execution_count": null, |
375 | 375 | "id": "0d0ea6cf-7d95-4d2c-9690-fcdbdae35d84",
|
376 | 376 | "metadata": {},
|
377 | 377 | "outputs": [],
|
|
438 | 438 | "id": "c13f5e57-723c-409b-a1ce-cdb831b4e166",
|
439 | 439 | "metadata": {},
|
440 | 440 | "source": [
|
441 |
| - "## Quick check 1: No warm-up" |
| 441 | + "## No warm-up" |
442 | 442 | ]
|
443 | 443 | },
|
444 | 444 | {
|
445 | 445 | "cell_type": "code",
|
446 |
| - "execution_count": 10, |
| 446 | + "execution_count": null, |
447 | 447 | "id": "caf52390-5455-4fa1-bb22-60b5b91ad8d0",
|
448 | 448 | "metadata": {},
|
449 |
| - "outputs": [ |
450 |
| - { |
451 |
| - "name": "stdout", |
452 |
| - "output_type": "stream", |
453 |
| - "text": [ |
454 |
| - "0.00: 🥵 Warm up complete.\n", |
455 |
| - "3.29: Stroke arrival.\n", |
456 |
| - "3.29: Patient 1 admitted to acute ward.(waited 0.00 days)\n", |
457 |
| - "4.06: Stroke arrival.\n", |
458 |
| - "4.06: Patient 2 admitted to acute ward.(waited 0.00 days)\n", |
459 |
| - "5.31: Stroke arrival.\n", |
460 |
| - "5.31: Patient 3 admitted to acute ward.(waited 0.00 days)\n", |
461 |
| - "5.53: Stroke arrival.\n", |
462 |
| - "5.53: Patient 4 admitted to acute ward.(waited 0.00 days)\n", |
463 |
| - "5.76: Stroke arrival.\n", |
464 |
| - "5.76: Patient 5 admitted to acute ward.(waited 0.00 days)\n" |
465 |
| - ] |
466 |
| - }, |
467 |
| - { |
468 |
| - "data": { |
469 |
| - "text/plain": [ |
470 |
| - "{'mean_acute_wait': 0.0}" |
471 |
| - ] |
472 |
| - }, |
473 |
| - "execution_count": 10, |
474 |
| - "metadata": {}, |
475 |
| - "output_type": "execute_result" |
476 |
| - } |
477 |
| - ], |
| 449 | + "outputs": [], |
478 | 450 | "source": [
|
479 | 451 | "TRACE = True\n",
|
480 | 452 | "experiment = Experiment()\n",
|
481 |
| - "results = single_run(experiment, rep=0, wu_period=0.0, rc_period=6.0)\n", |
| 453 | + "results = single_run(experiment, rep=2, wu_period=10.0, rc_period=6.0)\n", |
482 | 454 | "results"
|
483 | 455 | ]
|
484 | 456 | },
|
485 | 457 | {
|
486 | 458 | "cell_type": "code",
|
487 |
| - "execution_count": 11, |
| 459 | + "execution_count": null, |
488 | 460 | "id": "ddedb4f1-207d-4295-9ae4-c49b2c7cdcaf",
|
489 | 461 | "metadata": {},
|
490 |
| - "outputs": [ |
491 |
| - { |
492 |
| - "data": { |
493 |
| - "text/plain": [ |
494 |
| - "{'n_arrivals': 5, 'waiting_acute': [0.0, 0.0, 0.0, 0.0, 0.0]}" |
495 |
| - ] |
496 |
| - }, |
497 |
| - "execution_count": 11, |
498 |
| - "metadata": {}, |
499 |
| - "output_type": "execute_result" |
500 |
| - } |
501 |
| - ], |
| 462 | + "outputs": [], |
502 | 463 | "source": [
|
503 | 464 | "# check how many patient waiting times recorded.\n",
|
504 | 465 | "experiment.results"
|
|
509 | 470 | "id": "660ea2e1-d9c2-4355-876c-43dfd9dab0fe",
|
510 | 471 | "metadata": {},
|
511 | 472 | "source": [
|
512 |
| - "## Quick check 2: Include a warm-up" |
| 473 | + "## Include a warm-up" |
513 | 474 | ]
|
514 | 475 | },
|
515 | 476 | {
|
516 | 477 | "cell_type": "code",
|
517 |
| - "execution_count": 12, |
| 478 | + "execution_count": null, |
518 | 479 | "id": "72b5284a-1fcb-4126-b663-c0ef0002e4bf",
|
519 | 480 | "metadata": {},
|
520 |
| - "outputs": [ |
521 |
| - { |
522 |
| - "name": "stdout", |
523 |
| - "output_type": "stream", |
524 |
| - "text": [ |
525 |
| - "3.29: Stroke arrival.\n", |
526 |
| - "3.29: Patient 1 admitted to acute ward.(waited 0.00 days)\n", |
527 |
| - "4.06: Stroke arrival.\n", |
528 |
| - "4.06: Patient 2 admitted to acute ward.(waited 0.00 days)\n", |
529 |
| - "5.00: 🥵 Warm up complete.\n", |
530 |
| - "5.31: Stroke arrival.\n", |
531 |
| - "5.31: Patient 3 admitted to acute ward.(waited 0.00 days)\n", |
532 |
| - "5.53: Stroke arrival.\n", |
533 |
| - "5.53: Patient 4 admitted to acute ward.(waited 0.00 days)\n", |
534 |
| - "5.76: Stroke arrival.\n", |
535 |
| - "5.76: Patient 5 admitted to acute ward.(waited 0.00 days)\n" |
536 |
| - ] |
537 |
| - }, |
538 |
| - { |
539 |
| - "data": { |
540 |
| - "text/plain": [ |
541 |
| - "{'mean_acute_wait': 0.0}" |
542 |
| - ] |
543 |
| - }, |
544 |
| - "execution_count": 12, |
545 |
| - "metadata": {}, |
546 |
| - "output_type": "execute_result" |
547 |
| - } |
548 |
| - ], |
| 481 | + "outputs": [], |
549 | 482 | "source": [
|
550 | 483 | "TRACE = True\n",
|
551 | 484 | "experiment = Experiment()\n",
|
|
555 | 488 | },
|
556 | 489 | {
|
557 | 490 | "cell_type": "code",
|
558 |
| - "execution_count": 13, |
| 491 | + "execution_count": null, |
559 | 492 | "id": "7f5e282b-0f41-41df-bdca-f128e7d418c1",
|
560 | 493 | "metadata": {},
|
561 |
| - "outputs": [ |
562 |
| - { |
563 |
| - "data": { |
564 |
| - "text/plain": [ |
565 |
| - "{'n_arrivals': 3, 'waiting_acute': [0.0, 0.0, 0.0]}" |
566 |
| - ] |
567 |
| - }, |
568 |
| - "execution_count": 13, |
569 |
| - "metadata": {}, |
570 |
| - "output_type": "execute_result" |
571 |
| - } |
572 |
| - ], |
| 494 | + "outputs": [], |
573 | 495 | "source": [
|
574 | 496 | "# check how many patient waiting times recorded.\n",
|
575 | 497 | "experiment.results"
|
|
0 commit comments