Skip to content

Commit 5820fef

Browse files
committed
feat(init): updates arrival msg
1 parent 78a56cb commit 5820fef

File tree

2 files changed

+89
-60
lines changed

2 files changed

+89
-60
lines changed

content/13_warm_up.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"\n",
1212
"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",
1313
"\n",
14-
"> In this tutorial we will focus on coding a warm-up period rather than analysis to determine its length\n",
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",
1515
"\n",
1616
"## But how do you code it?\n",
1717
"\n",
@@ -443,7 +443,7 @@
443443
},
444444
{
445445
"cell_type": "code",
446-
"execution_count": 22,
446+
"execution_count": 10,
447447
"id": "caf52390-5455-4fa1-bb22-60b5b91ad8d0",
448448
"metadata": {},
449449
"outputs": [
@@ -470,7 +470,7 @@
470470
"{'mean_acute_wait': 0.0}"
471471
]
472472
},
473-
"execution_count": 22,
473+
"execution_count": 10,
474474
"metadata": {},
475475
"output_type": "execute_result"
476476
}
@@ -484,7 +484,7 @@
484484
},
485485
{
486486
"cell_type": "code",
487-
"execution_count": 23,
487+
"execution_count": 11,
488488
"id": "ddedb4f1-207d-4295-9ae4-c49b2c7cdcaf",
489489
"metadata": {},
490490
"outputs": [
@@ -494,7 +494,7 @@
494494
"{'n_arrivals': 5, 'waiting_acute': [0.0, 0.0, 0.0, 0.0, 0.0]}"
495495
]
496496
},
497-
"execution_count": 23,
497+
"execution_count": 11,
498498
"metadata": {},
499499
"output_type": "execute_result"
500500
}
@@ -514,7 +514,7 @@
514514
},
515515
{
516516
"cell_type": "code",
517-
"execution_count": 24,
517+
"execution_count": 12,
518518
"id": "72b5284a-1fcb-4126-b663-c0ef0002e4bf",
519519
"metadata": {},
520520
"outputs": [
@@ -541,7 +541,7 @@
541541
"{'mean_acute_wait': 0.0}"
542542
]
543543
},
544-
"execution_count": 24,
544+
"execution_count": 12,
545545
"metadata": {},
546546
"output_type": "execute_result"
547547
}
@@ -555,7 +555,7 @@
555555
},
556556
{
557557
"cell_type": "code",
558-
"execution_count": 25,
558+
"execution_count": 13,
559559
"id": "7f5e282b-0f41-41df-bdca-f128e7d418c1",
560560
"metadata": {},
561561
"outputs": [
@@ -565,7 +565,7 @@
565565
"{'n_arrivals': 3, 'waiting_acute': [0.0, 0.0, 0.0]}"
566566
]
567567
},
568-
"execution_count": 25,
568+
"execution_count": 13,
569569
"metadata": {},
570570
"output_type": "execute_result"
571571
}

content/14_initial_conditions.ipynb

Lines changed: 80 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
},
7070
{
7171
"cell_type": "code",
72-
"execution_count": 31,
72+
"execution_count": 3,
7373
"id": "1ecf0429-f03f-4ad2-abb4-46692a74e559",
7474
"metadata": {},
7575
"outputs": [],
@@ -95,8 +95,8 @@
9595
" \"mode\": \"fixed\",\n",
9696
" \"fixed\": 8,\n",
9797
" \"rnd\": {\n",
98-
" \"values\":[6, 7, 8, 9, 10, 11],\n",
99-
" \"freq\":[0.25, 0.25, 0.2, 0.1, 0.1, 0.1]\n",
98+
" \"values\":[8, 9, 10, 11, 12, 13],\n",
99+
" \"freq\":[25, 25, 2, 1, 1, 1]\n",
100100
" }\n",
101101
"}\n",
102102
" \n",
@@ -354,7 +354,7 @@
354354
},
355355
{
356356
"cell_type": "code",
357-
"execution_count": 35,
357+
"execution_count": 8,
358358
"id": "b3e686ce-5371-4471-a052-b9d43309bc85",
359359
"metadata": {},
360360
"outputs": [],
@@ -381,15 +381,15 @@
381381
"\n",
382382
" args.results[\"n_arrivals\"] += 1\n",
383383
" \n",
384-
" trace(f\"{env.now:.2f}: Stroke arrival.\")\n",
384+
" trace(f\"{env.now:.2f}: Patient {patient_id}. Stroke arrival.\")\n",
385385
"\n",
386386
" # patient enters pathway\n",
387387
" env.process(acute_stroke_pathway(patient_id, env, args))"
388388
]
389389
},
390390
{
391391
"cell_type": "code",
392-
"execution_count": 12,
392+
"execution_count": 9,
393393
"id": "ca37c9cd-158c-416b-8490-b4c5c2e63412",
394394
"metadata": {},
395395
"outputs": [],
@@ -434,7 +434,7 @@
434434
},
435435
{
436436
"cell_type": "code",
437-
"execution_count": 13,
437+
"execution_count": 10,
438438
"id": "0d0ea6cf-7d95-4d2c-9690-fcdbdae35d84",
439439
"metadata": {},
440440
"outputs": [],
@@ -501,7 +501,7 @@
501501
},
502502
{
503503
"cell_type": "code",
504-
"execution_count": 34,
504+
"execution_count": 11,
505505
"id": "caf52390-5455-4fa1-bb22-60b5b91ad8d0",
506506
"metadata": {},
507507
"outputs": [
@@ -517,6 +517,8 @@
517517
"0.00: Patient -6 loaded into queue\n",
518518
"0.00: Patient -7 loaded into queue\n",
519519
"0.00: Patient -8 loaded into queue\n",
520+
"0.00: Patient -9 loaded into queue\n",
521+
"0.00: Patient -10 loaded into queue\n",
520522
"0.00: Patient -1 admitted to acute ward.(waited 0.00 days)\n",
521523
"0.00: Patient -2 admitted to acute ward.(waited 0.00 days)\n",
522524
"0.00: Patient -3 admitted to acute ward.(waited 0.00 days)\n",
@@ -525,54 +527,52 @@
525527
"0.00: Patient -6 admitted to acute ward.(waited 0.00 days)\n",
526528
"0.00: Patient -7 admitted to acute ward.(waited 0.00 days)\n",
527529
"0.00: Patient -8 admitted to acute ward.(waited 0.00 days)\n",
528-
"3.29: Stroke arrival.\n",
529-
"3.29: Patient 1 admitted to acute ward.(waited 0.00 days)\n",
530-
"4.06: Stroke arrival.\n",
531-
"4.22: Patient -3 discharged.\n",
532-
"4.22: Patient 2 admitted to acute ward.(waited 0.16 days)\n",
533-
"5.00: 🥵 Warm up complete.\n",
534-
"5.28: Patient -2 discharged.\n",
535-
"5.31: Stroke arrival.\n",
536-
"5.31: Patient 3 admitted to acute ward.(waited 0.00 days)\n",
537-
"5.53: Stroke arrival.\n",
538-
"5.76: Stroke arrival.\n",
539-
"5.98: Patient -8 discharged.\n",
540-
"5.98: Patient 4 admitted to acute ward.(waited 0.44 days)\n",
541-
"6.60: Patient -6 discharged.\n",
542-
"6.60: Patient 5 admitted to acute ward.(waited 0.84 days)\n",
543-
"7.25: Patient -7 discharged.\n",
544-
"7.56: Stroke arrival.\n",
545-
"7.56: Patient 6 admitted to acute ward.(waited 0.00 days)\n",
546-
"7.62: Stroke arrival.\n",
547-
"7.77: Patient -1 discharged.\n",
548-
"7.77: Patient 7 admitted to acute ward.(waited 0.15 days)\n",
549-
"7.91: Patient -4 discharged.\n",
550-
"8.33: Patient -5 discharged.\n",
551-
"8.52: Stroke arrival.\n",
552-
"8.52: Patient 8 admitted to acute ward.(waited 0.00 days)\n",
553-
"8.82: Stroke arrival.\n",
554-
"8.82: Patient 9 admitted to acute ward.(waited 0.00 days)\n",
555-
"9.80: Patient 1 discharged.\n",
556-
"11.12: Stroke arrival.\n",
557-
"11.12: Patient 10 admitted to acute ward.(waited 0.00 days)\n",
558-
"11.93: Patient 2 discharged.\n",
559-
"12.98: Stroke arrival.\n",
560-
"12.98: Patient 11 admitted to acute ward.(waited 0.00 days)\n",
561-
"12.99: Stroke arrival.\n",
562-
"13.26: Patient 3 discharged.\n",
563-
"13.26: Patient 12 admitted to acute ward.(waited 0.26 days)\n",
564-
"13.80: Patient 5 discharged.\n",
565-
"14.19: Patient 7 discharged.\n",
566-
"14.20: Patient 4 discharged.\n"
530+
"0.00: Patient -9 admitted to acute ward.(waited 0.00 days)\n",
531+
"0.00: 🥵 Warm up complete.\n",
532+
"2.74: Patient 1. Stroke arrival.\n",
533+
"2.78: Patient 2. Stroke arrival.\n",
534+
"3.36: Patient 3. Stroke arrival.\n",
535+
"4.42: Patient 4. Stroke arrival.\n",
536+
"4.68: Patient 5. Stroke arrival.\n",
537+
"5.80: Patient -3 discharged.\n",
538+
"5.80: Patient -10 admitted to acute ward.(waited 5.80 days)\n",
539+
"5.80: Patient -8 discharged.\n",
540+
"5.80: Patient 1 admitted to acute ward.(waited 3.06 days)\n",
541+
"5.97: Patient 6. Stroke arrival.\n",
542+
"6.08: Patient -6 discharged.\n",
543+
"6.08: Patient 2 admitted to acute ward.(waited 3.30 days)\n",
544+
"6.22: Patient -7 discharged.\n",
545+
"6.22: Patient 3 admitted to acute ward.(waited 2.86 days)\n",
546+
"6.33: Patient 7. Stroke arrival.\n",
547+
"7.28: Patient 8. Stroke arrival.\n",
548+
"7.41: Patient -4 discharged.\n",
549+
"7.41: Patient 4 admitted to acute ward.(waited 2.99 days)\n",
550+
"7.43: Patient 9. Stroke arrival.\n",
551+
"7.55: Patient 10. Stroke arrival.\n",
552+
"7.94: Patient -5 discharged.\n",
553+
"7.94: Patient 5 admitted to acute ward.(waited 3.26 days)\n",
554+
"8.11: Patient -2 discharged.\n",
555+
"8.11: Patient 6 admitted to acute ward.(waited 2.14 days)\n",
556+
"8.26: Patient 11. Stroke arrival.\n",
557+
"8.42: Patient 12. Stroke arrival.\n",
558+
"8.68: Patient 13. Stroke arrival.\n",
559+
"8.72: Patient 14. Stroke arrival.\n",
560+
"8.82: Patient -9 discharged.\n",
561+
"8.82: Patient 7 admitted to acute ward.(waited 2.50 days)\n",
562+
"8.95: Patient 15. Stroke arrival.\n",
563+
"9.18: Patient 16. Stroke arrival.\n",
564+
"9.87: Patient -1 discharged.\n",
565+
"9.87: Patient 8 admitted to acute ward.(waited 2.58 days)\n",
566+
"9.92: Patient 17. Stroke arrival.\n"
567567
]
568568
},
569569
{
570570
"data": {
571571
"text/plain": [
572-
"{'mean_acute_wait': 0.16965284328644098}"
572+
"{'mean_acute_wait': 2.8362718457918676}"
573573
]
574574
},
575-
"execution_count": 34,
575+
"execution_count": 11,
576576
"metadata": {},
577577
"output_type": "execute_result"
578578
}
@@ -583,12 +583,41 @@
583583
"init_cond_params[\"mode\"] = \"fixed\"\n",
584584
"\n",
585585
"# uncomment to vary the fixed amount 10 = 1 in queue.\n",
586-
"# init_cond_params[\"fixed\"] = 10\n",
586+
"init_cond_params[\"fixed\"] = 10\n",
587587
"\n",
588588
"experiment = Experiment(init_cond_params=init_cond_params)\n",
589-
"results = single_run(experiment, rep=0, wu_period=5.0, rc_period=10.0)\n",
589+
"results = single_run(experiment, rep=1, wu_period=0.0, rc_period=10.0)\n",
590590
"results"
591591
]
592+
},
593+
{
594+
"cell_type": "code",
595+
"execution_count": 12,
596+
"id": "0aaef408-09ca-49e0-8d39-f4a088a4ef1b",
597+
"metadata": {},
598+
"outputs": [
599+
{
600+
"data": {
601+
"text/plain": [
602+
"{'n_arrivals': 17,\n",
603+
" 'waiting_acute': [3.0586175577655674,\n",
604+
" 3.303449502025928,\n",
605+
" 2.857579305401165,\n",
606+
" 2.9908615153438225,\n",
607+
" 3.2622390398417513,\n",
608+
" 2.136685286636955,\n",
609+
" 2.496306611009193,\n",
610+
" 2.58443594831056]}"
611+
]
612+
},
613+
"execution_count": 12,
614+
"metadata": {},
615+
"output_type": "execute_result"
616+
}
617+
],
618+
"source": [
619+
"experiment.results"
620+
]
592621
}
593622
],
594623
"metadata": {

0 commit comments

Comments
 (0)