-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathLECTURE-SLIDES.html
More file actions
3840 lines (3691 loc) · 262 KB
/
LECTURE-SLIDES.html
File metadata and controls
3840 lines (3691 loc) · 262 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en"><head>
<script src="day-5_files/libs/clipboard/clipboard.min.js"></script>
<script src="day-5_files/libs/quarto-html/tabby.min.js"></script>
<script src="day-5_files/libs/quarto-html/popper.min.js"></script>
<script src="day-5_files/libs/quarto-html/tippy.umd.min.js"></script>
<link href="day-5_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="day-5_files/libs/quarto-html/light-border.css" rel="stylesheet">
<link href="day-5_files/libs/quarto-html/quarto-html.min.css" rel="stylesheet" data-mode="light">
<link href="day-5_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="day-5_files/libs/quarto-contrib/glightbox/glightbox.min.js"></script>
<link href="day-5_files/libs/quarto-contrib/glightbox/glightbox.min.css" rel="stylesheet">
<link href="day-5_files/libs/quarto-contrib/glightbox/lightbox.css" rel="stylesheet"><meta charset="utf-8">
<meta name="generator" content="quarto-1.5.56">
<meta name="author" content="John McLevey">
<meta name="author" content="Johannes B. Gruber">
<title>Simulation & Agent-based Models</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="day-5_files/libs/revealjs/dist/reset.css">
<link rel="stylesheet" href="day-5_files/libs/revealjs/dist/reveal.css">
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ color: #d8dee9; background-color: #2e3440; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span { color: #d8dee9; } /* Normal */
code span.al { color: #bf616a; background-color: #3b4252; font-weight: bold; } /* Alert */
code span.an { color: #d08770; } /* Annotation */
code span.at { color: #8fbcbb; } /* Attribute */
code span.bn { color: #b48ead; } /* BaseN */
code span.bu { color: #88c0d0; font-style: italic; } /* BuiltIn */
code span.cf { color: #81a1c1; font-weight: bold; } /* ControlFlow */
code span.ch { color: #ebcb8b; } /* Char */
code span.cn { color: #eceff4; font-weight: bold; } /* Constant */
code span.co { color: #616e88; } /* Comment */
code span.cv { color: #e5e9f0; } /* CommentVar */
code span.do { color: #5e81ac; } /* Documentation */
code span.dt { color: #81a1c1; } /* DataType */
code span.dv { color: #b48ead; } /* DecVal */
code span.er { color: #bf616a; text-decoration: underline; } /* Error */
code span.ex { color: #8fbcbb; font-weight: bold; } /* Extension */
code span.fl { color: #b48ead; } /* Float */
code span.fu { color: #88c0d0; } /* Function */
code span.im { color: #a3be8c; } /* Import */
code span.in { color: #ebcb8b; } /* Information */
code span.kw { color: #81a1c1; font-weight: bold; } /* Keyword */
code span.op { color: #81a1c1; } /* Operator */
code span.ot { color: #8fbcbb; } /* Other */
code span.pp { color: #5e81ac; } /* Preprocessor */
code span.re { color: #88c0d0; background-color: #3b4252; } /* RegionMarker */
code span.sc { color: #ebcb8b; } /* SpecialChar */
code span.ss { color: #d08770; } /* SpecialString */
code span.st { color: #a3be8c; } /* String */
code span.va { color: #5e81ac; } /* Variable */
code span.vs { color: #a3be8c; } /* VerbatimString */
code span.wa { color: #bf616a; } /* Warning */
/* CSS for citations */
div.csl-bib-body { }
div.csl-entry {
clear: both;
margin-bottom: 0em;
}
.hanging-indent div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
} </style>
<link rel="stylesheet" href="day-5_files/libs/revealjs/dist/theme/quarto.css">
<link href="day-5_files/libs/revealjs/plugin/quarto-line-highlight/line-highlight.css" rel="stylesheet">
<link href="day-5_files/libs/revealjs/plugin/reveal-menu/menu.css" rel="stylesheet">
<link href="day-5_files/libs/revealjs/plugin/reveal-menu/quarto-menu.css" rel="stylesheet">
<link href="day-5_files/libs/revealjs/plugin/quarto-support/footer.css" rel="stylesheet">
<style type="text/css">
.callout {
margin-top: 1em;
margin-bottom: 1em;
border-radius: .25rem;
}
.callout.callout-style-simple {
padding: 0em 0.5em;
border-left: solid #acacac .3rem;
border-right: solid 1px silver;
border-top: solid 1px silver;
border-bottom: solid 1px silver;
display: flex;
}
.callout.callout-style-default {
border-left: solid #acacac .3rem;
border-right: solid 1px silver;
border-top: solid 1px silver;
border-bottom: solid 1px silver;
}
.callout .callout-body-container {
flex-grow: 1;
}
.callout.callout-style-simple .callout-body {
font-size: 1rem;
font-weight: 400;
}
.callout.callout-style-default .callout-body {
font-size: 0.9rem;
font-weight: 400;
}
.callout.callout-titled.callout-style-simple .callout-body {
margin-top: 0.2em;
}
.callout:not(.callout-titled) .callout-body {
display: flex;
}
.callout:not(.no-icon).callout-titled.callout-style-simple .callout-content {
padding-left: 1.6em;
}
.callout.callout-titled .callout-header {
padding-top: 0.2em;
margin-bottom: -0.2em;
}
.callout.callout-titled .callout-title p {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
.callout.callout-titled.callout-style-simple .callout-content p {
margin-top: 0;
}
.callout.callout-titled.callout-style-default .callout-content p {
margin-top: 0.7em;
}
.callout.callout-style-simple div.callout-title {
border-bottom: none;
font-size: .9rem;
font-weight: 600;
opacity: 75%;
}
.callout.callout-style-default div.callout-title {
border-bottom: none;
font-weight: 600;
opacity: 85%;
font-size: 0.9rem;
padding-left: 0.5em;
padding-right: 0.5em;
}
.callout.callout-style-default div.callout-content {
padding-left: 0.5em;
padding-right: 0.5em;
}
.callout.callout-style-simple .callout-icon::before {
height: 1rem;
width: 1rem;
display: inline-block;
content: "";
background-repeat: no-repeat;
background-size: 1rem 1rem;
}
.callout.callout-style-default .callout-icon::before {
height: 0.9rem;
width: 0.9rem;
display: inline-block;
content: "";
background-repeat: no-repeat;
background-size: 0.9rem 0.9rem;
}
.callout-title {
display: flex
}
.callout-icon::before {
margin-top: 1rem;
padding-right: .5rem;
}
.callout.no-icon::before {
display: none !important;
}
.callout.callout-titled .callout-body > .callout-content > :last-child {
padding-bottom: 0.5rem;
margin-bottom: 0;
}
.callout.callout-titled .callout-icon::before {
margin-top: .5rem;
padding-right: .5rem;
}
.callout:not(.callout-titled) .callout-icon::before {
margin-top: 1rem;
padding-right: .5rem;
}
/* Callout Types */
div.callout-note {
border-left-color: #4582ec !important;
}
div.callout-note .callout-icon::before {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABA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/1m7QfDgEuvgUUEIJPq3DhX/5DWNqIXDOweC2wvIR90Oq3lDpdMIgD2r0dXvGdsEW5H6x6HLRJYU7C69VefO1x8Gde1ZFSJLfWS1jbCnhtOPxmpfv2LXOA2Xk2tvnwKKPFuZ/oRmwBwqRQDcKNeVQkYcOjtWVBuM/JuYw5b6isojIkYxyYAFn5K7ZBF10fea52y8QltAg6jnMqNHFBmGkQ1j+U43HMi2xMar1Nv0zGsf1s8nUsmUtPOOrbFIR8bHFDMB5zL13Gmr/kGlCkUzedTzzmzsaJXhYawnA3UmARpiYj5ooJZiUoxFRtK3X6pgNPv+IZVPcnwbOl6f+aBaO1CNvPW9n9LmCp01nuSaTRF2YxHqZ8DYQT6WsXT+RD6eUztwYLZ8rM+rcPxamv1VQzFUkzFXvkiVrySGQgJNvXHJAxiU3/NwiC03rSf05VBaPtu/Z7/B8Yn/w7eguloAAAAAElFTkSuQmCC');
}
div.callout-note.callout-style-default .callout-title {
background-color: #dae6fb
}
div.callout-important {
border-left-color: #d9534f !important;
}
div.callout-important .callout-icon::before {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAACshmLzAAAEKklEQVRYCcVXTWhcVRS+575MJym48A+hSRFr00ySRQhURRfd2HYjk2SSTokuBCkU2o0LoSKKraKIBTcuFCoidGFD08nkBzdREbpQ1EDNIv8qSGMFUboImMSZd4/f9zJv8ibJMC8xJQfO3HPPPef7zrvvvnvviIkpC9nsw0UttFunbUhpFzFtarSd6WJkStVMw5xyVqYTvkwfzuf/5FgtkVoB0729j1rjXwThS7Vio+Mo6DNnvLfahoZ+i/o32lULuJ3NNiz7q6+pyAUkJaFF6JwaM2lUJlV0MlnQn5aTRbEu0SEqHUa0A4AdiGuB1kFXRfVyg5d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v6xyQsYk//moVFsN2zP6fRImjfq7/n/wFDguUQFNEwugAAAABJRU5ErkJggg==');
}
div.callout-important.callout-style-default .callout-title {
background-color: #f7dddc
}
div.callout-warning {
border-left-color: #f0ad4e !important;
}
div.callout-warning .callout-icon::before {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAACshmLzAAAETklEQVRYCeVWW2gcVRg+58yaTUnizqbipZeX4uWhBEniBaoUX1Ioze52t7sRq6APio9V9MEaoWlVsFasRq0gltaAPuxms8lu0gcviE/FFOstVbSIxgcv6SU7EZqmdc7v9+9mJtNks51NTUH84ed889/PP+cmxP+d5FIbMJmNbpREu4WUkiTtCicKny0l1pIKmBzovF2S+hIJHX8iEu3hZJ5lNZGqyRrGSIQpq15AzF28jgpeY6yk6GVdrfFqdrD6Iw+QlB8g0YS2g7dyQmXM/IDhBhT0UCiRf59lfqmmDvzRt6kByV/m4JjtzuaujMUM2c5Z2d6JdKrRb3K2q6mA+oYVz8JnDdKPmmNthzkAk/lN63sYPgevrguc72aZX/L9C6x09GYyxBgCX4NlvyGUHOKELlm5rXeR1kchuChJt4SSwyddZRXgvwMGvYo4QSlk3/zkHD8UHxwVJA6zjZZqP8v8kK8OWLnIZtLyCAJagYC4rTGW/9Pqj92N/c+LUaAj27movwbi19tk/whRCIE7Q9vyI6yvRpftAKVTdUjOW40X3h5OXsKCdmFcx0xlLJoSuQngnrJe7Kcjm4OMq9FlC7CMmScQANuNvjfP3PjGXDBaUQmbp296S5L4DrpbrHN1T87ZVEZVCzg1FF0Ft+dKrlLukI+/c9ENo+TvlTDbYFvuKPtQ9+l052rXrgKoWkDAFnvh0wTOmYn8R5f4k/jN/fZiCM1tQx9jQQ4ANhqG4hiL0qIFTGViG9DKB7GYzgubnpofgYRwO+DFjh0Zin2m4b/97EDkXkc+f6xYAPX0KK2I/7fUQuwzuwo/L3AkcjugPNixC8cHf0FyPjWlItmLxWw4Ou9YsQCr5fijMGoD/zpdRy95HRysyXA74MWOnscpO4j2y3HAVisw85hX5+AFBRSHt4ShfLFkIMXTqyKFc46xdzQM6XbAi702a7sy04J0+feReMFKp5q9esYLCqAZYw/k14E/xcLLsFElaornTuJB0svMuJINy8xkIYuL+xPAlWRceH6+HX7THJ0djLUom46zREu7tTkxwmf/FdOZ/sh6Q8qvEAiHpm4PJ4a/doJe0gH1t+aHRgCzOvBvJedEK5OFE5jpm4AGP2a8Dxe3gGJ/pAutug9Gp6he92CsSsWBaEcxGx0FHytmIpuqGkOpldqNYQK8cSoXvd+xLxXADw0kf6UkJNFtdo5MOgaLjiQOQHcn+A6h5NuL2s0qsC2LOM75PcF3yr5STuBSAcGG+meA14K/CI21HcS4LBT6tv0QAh8Dr5l93AhZzG5ZJ4VxAqdZUEl9z7WJ4aN+svMvwHHL21UKTd1mqvChH7/Za5xzXBBKrUcB0TQ+Ulgkfbi/H/YT5EptrGzsEK7tR1B7ln9BBwckYfMiuSqklSznIuoIIOM42MQO+QnduCoFCI0bpkzjCjddHPN/F+2Yu+sd9bKNpVwHhbS3LluK/0zgfwD0xYI5dXuzlQAAAABJRU5ErkJggg==');
}
div.callout-warning.callout-style-default .callout-title {
background-color: #fcefdc
}
div.callout-tip {
border-left-color: #02b875 !important;
}
div.callout-tip .callout-icon::before {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAACshmLzAAADr0lEQVRYCe1XTWgTQRj9ZjZV8a9SPIkKgj8I1bMHsUWrqYLVg4Ue6v9BwZOxSYsIerFao7UiUryIqJcqgtpim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SAawGWFn5tDhLMYz6nWeU2wJfIhmIJBefcd/A5FWQWGgrWzyORZ3Q6HuV+Jf0Bj+BTX69fm1zWgK7By1YTXchFDORywnfQ7GpzOo6S+qECrsx2ifVQAAAABJRU5ErkJggg==');
}
div.callout-tip.callout-style-default .callout-title {
background-color: #ccf1e3
}
div.callout-caution {
border-left-color: #fd7e14 !important;
}
div.callout-caution .callout-icon::before {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAACshmLzAAACV0lEQVRYCdVWzWoUQRCuqp2ICBLJXgITZL1EfQDBW/bkzUMUD7klD+ATSHBEfAIfQO+iXsWDxJsHL96EHAwhgzlkg8nBg25XWb0zIb0zs9muYYWkoKeru+vn664fBqElyZNuyh167NXJ8Ut8McjbmEraKHkd7uAnAFku+VWdb3reSmRV8PKSLfZ0Gjn3a6Xlcq9YGb6tADjn+lUfTXtVmaZ1KwBIvFI11rRXlWlatwIAAv2asaa9mlB9wwygiDX26qaw1yYPzFXg2N1GgG0FMF8Oj+VIx7E/03lHx8UhvYyNZLN7BwSPgekXXLribw7w5/c8EF+DBK5idvDVYtEEwMeYefjjLAdEyQ3M9nfOkgnPTEkYU+sxMq0BxNR6jExrAI31H1rzvLEfRIdgcv1XEdj6QTQAS2wtstEALLG1yEZ3QhH6oDX7ExBSFEkFINXH98NTrme5IOaaA7kIfiu2L8A3qhH9zRbukdCqdsA98TdElyeMe5BI8Rs2xHRIsoTSSVFfCFCWGPn9XHb4cdobRIWABNf0add9jakDjQJpJ1bTXOJXnnRXHRf+dNL1ZV1MBRCXhMbaHqGI1JkKIL7+i8uffuP6wVQAzO7+qVEbF6NbS0LJureYcWXUUhH66nLR5rYmva+2tjRFtojkM2aD76HEGAD3tPtKM309FJg5j/K682ywcWJ3PASCcycH/22u+Bh7Aa0ehM2Fu4z0SAE81HF9RkB21c5bEn4Dzw+/qNOyXr3DCTQDMBOdhi4nAgiFDGCinIa2owCEChUwD8qzd03PG+qdW/4fDzjUMcE1ZpIAAAAASUVORK5CYII=');
}
div.callout-caution.callout-style-default .callout-title {
background-color: #ffe5d0
}
</style>
<style type="text/css">
.reveal div.sourceCode {
margin: 0;
overflow: auto;
}
.reveal div.hanging-indent {
margin-left: 1em;
text-indent: -1em;
}
.reveal .slide:not(.center) {
height: 100%;
overflow-y: auto;
}
.reveal .slide.scrollable {
overflow-y: auto;
}
.reveal .footnotes {
height: 100%;
overflow-y: auto;
}
.reveal .slide .absolute {
position: absolute;
display: block;
}
.reveal .footnotes ol {
counter-reset: ol;
list-style-type: none;
margin-left: 0;
}
.reveal .footnotes ol li:before {
counter-increment: ol;
content: counter(ol) ". ";
}
.reveal .footnotes ol li > p:first-child {
display: inline-block;
}
.reveal .slide ul,
.reveal .slide ol {
margin-bottom: 0.5em;
}
.reveal .slide ul li,
.reveal .slide ol li {
margin-top: 0.4em;
margin-bottom: 0.2em;
}
.reveal .slide ul[role="tablist"] li {
margin-bottom: 0;
}
.reveal .slide ul li > *:first-child,
.reveal .slide ol li > *:first-child {
margin-block-start: 0;
}
.reveal .slide ul li > *:last-child,
.reveal .slide ol li > *:last-child {
margin-block-end: 0;
}
.reveal .slide .columns:nth-child(3) {
margin-block-start: 0.8em;
}
.reveal blockquote {
box-shadow: none;
}
.reveal .tippy-content>* {
margin-top: 0.2em;
margin-bottom: 0.7em;
}
.reveal .tippy-content>*:last-child {
margin-bottom: 0.2em;
}
.reveal .slide > img.stretch.quarto-figure-center,
.reveal .slide > img.r-stretch.quarto-figure-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.reveal .slide > img.stretch.quarto-figure-left,
.reveal .slide > img.r-stretch.quarto-figure-left {
display: block;
margin-left: 0;
margin-right: auto;
}
.reveal .slide > img.stretch.quarto-figure-right,
.reveal .slide > img.r-stretch.quarto-figure-right {
display: block;
margin-left: auto;
margin-right: 0;
}
</style>
</head>
<body class="quarto-light">
<div class="reveal">
<div class="slides">
<section id="title-slide" class="quarto-title-block center">
<h1 class="title">Simulation &<br>Agent-based Models</h1>
<p class="subtitle"><span class="kn-pink">DAY FIVE</span> <span class="kn-blue">GESIS Fall Seminar in Computational Social Science</span></p>
<div class="quarto-title-authors">
<div class="quarto-title-author">
<div class="quarto-title-author-name">
John McLevey
</div>
<p class="quarto-title-affiliation">
University of Waterloo
</p>
</div>
<div class="quarto-title-author">
<div class="quarto-title-author-name">
Johannes B. Gruber
</div>
<p class="quarto-title-affiliation">
VU Amsterdam
</p>
</div>
</div>
</section>
<section class="slide level2 scrollable">
<p><br></p>
<div class="columns">
<div class="column" style="width:30%;">
<h3 id="today">Today</h3>
<p>Agent-based modelling with <span class="kn-pink">Mesa</span></p>
</div><div class="column" style="width:5%;">
</div><div class="column" style="width:65%;">
<ol type="1">
<li>What are agent-based <span class="nord-light">(individual-based)</span> models?<br><span class="nord-footer">From equation-based models to agent-based models<br>Example: SIR models of disease diffusion</span></li>
<li>Designing, documenting, and developing ABMs<br><span class="nord-footer">The agent-based modelling cycle</span></li>
<li>Model design concepts and pattern-oriented modelling</li>
<li>Developing your first ABM in Mesa<br><span class="nord-footer">OOP and Mesa 101<br>Extended example: developing a SIR model</span></li>
<li>Analyzing an ABM<br><span class="nord-footer">Parameter sweeps and sensitivity analysis</span></li>
<li>Social Learning, Influence, and Opinion Dynamics<br><span class="nord-footer">Bounded confidence models</span></li>
<li>Reduction, Realism, and Model Trade-offs<br><span class="nord-footer"><span class="math inline">\(\longleftarrow\)</span> Fine-grained vs. course-grained models <span class="math inline">\(\longrightarrow\)</span><br>What’s hot now?</span></li>
</ol>
</div></div>
</section>
<section id="section" class="slide level2 scrollable">
<h2></h2>
<p><br></p>
<div class="columns">
<div class="column" style="width:30%;">
<h3 id="approach">Approach</h3>
<p>Python, R</p>
</div><div class="column" style="width:55%;">
<p>I will spend a lot of time explaining how the models are implemented in Python, but the primary <span class="kn-pink">learning objectives</span> are to</p>
<p><br></p>
<ol type="1">
<li>understand these models conceptually</li>
<li>set up their inputs and</li>
<li>analyze their outputs within a theoretical or applied context</li>
</ol>
<p><br></p>
<p><strong>If you are in the R course</strong>, focus on the logic of the Python code to better understand the models themselves; there is no expectation that you will “learn Python.” Johannes will still show you how to setup, run, and analyze these models using R.</p>
</div><div class="column" style="width:15%;">
</div></div>
</section>
<section>
<section id="what-are-agent-based-models-abms" class="title-slide slide level1 center" data-background-image="media/flocking.jpg" data-background-opacity="1">
<h1><span class="light-against-image">What are<br>Agent-based Models<br>(ABMs)?</span></h1>
</section>
<section id="what-are-abms" class="slide level2">
<h2>What are ABMs?</h2>
<p><span class="nord-footer"><span class="citation" data-cites="macy2002factors squazzoni2012agent bruch2015agent wilensky2015introduction crooks2018agent railsback2019agent smaldino2023modeling">(<a href="#/section-16" role="doc-biblioref" onclick="">Macy and Willer 2002</a>; <a href="#/section-16" role="doc-biblioref" onclick="">Squazzoni 2012</a>; <a href="#/section-16" role="doc-biblioref" onclick="">Bruch and Atwell 2015</a>; <a href="#/section-16" role="doc-biblioref" onclick="">Wilensky and Rand 2015</a>; <a href="#/section-16" role="doc-biblioref" onclick="">Crooks et al. 2018</a>; <a href="#/section-16" role="doc-biblioref" onclick="">Railsback and Grimm 2019</a>; <a href="#/section-16" role="doc-biblioref" onclick="">Smaldino 2023</a>)</span></span></p>
<p>ABMs have been central to computational social science from the start. There are plenty of good review articles, applications, and textbooks in just about any field going back 30 years or more.</p>
<p><img data-src="media/factors_to_actors.png" class="shadow-img" style="width:17.75%" alt="Sociology"> <img data-src="media/abm-polisci.png" class="shadow-img" style="width:22.0%" alt="Political Science"> <img data-src="media/abms-micro-simulation.png" class="shadow-img" style="width:21.5%" alt="Statistics"></p>
</section>
<section id="section-1" class="slide level2">
<h2></h2>
<div class="columns">
<div class="column" style="width:25%;">
<p><br><br><br></p>
<h3 id="an-illustration">An Illustration</h3>
<p>SIR Models</p>
<p><span class="nord-footer">Equation vs. Agent-based</span></p>
</div><div class="column" style="width:5%;">
</div><div class="column" style="width:70%;">
<div class="quarto-figure quarto-figure-left">
<figure>
<p><a href="media/kelly-sikkema-r2hTBxEkgWQ-unsplash.jpg" class="lightbox" data-gallery="quarto-lightbox-gallery-1" title="Photo by Kelly Sikkema on Unsplash"><img data-src="media/kelly-sikkema-r2hTBxEkgWQ-unsplash.jpg" class="shadow-img" style="width:100.0%" alt="Photo by Kelly Sikkema on Unsplash"></a></p>
<figcaption><span class="nord-light">Photo by <a href="https://unsplash.com/@kellysikkema?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Kelly Sikkema</a> on <a href="https://unsplash.com/photos/girl-in-black-long-sleeve-shirt-reading-book-r2hTBxEkgWQ?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a></span></figcaption>
</figure>
</div>
</div></div>
</section>
<section id="classic-sir" class="slide level2">
<h2>Classic SIR</h2>
<div class="columns">
<div class="column" style="width:45%;">
<p>How do diseases spread through a population?</p>
<ul>
<li>Divide the population into three “compartments”<br><strong><span class="kn-pink">S</span>usceptible</strong>, <strong><span class="kn-pink">I</span>nfected</strong>, <strong><span class="kn-pink">R</span>ecovered/Removed</strong></li>
<li>Model the movement of people in and out of the compartments in continuous time</li>
<li>Traditionally done with differential equations</li>
</ul>
<p><br></p>
<p><span class="math display">\[
\begin{align}
\frac{{dS}}{{dt}} &= - \left( \frac{{a}}{{N}}\right) I S \\
\frac{{dI}}{{dt}} &= \left( \frac{{a}}{{N}}\right) I S - b I \\
\frac{{dR}}{{dt}} &= bI
\end{align}
\]</span></p>
</div><div class="column" style="width:10%;">
</div><div class="column fragment" style="width:45%;">
<p>Don’t worry if your calculus is rusty! A <strong>derivative</strong> describes how one quantity changes in response to another quantity.</p>
<p><span class="math display">\[\frac{{d}}{{dt}}\]</span></p>
<p>is the derivative with respect to time, which represents the <strong>rate of change</strong> for a quantity given another quantity.</p>
<p><br></p>
<ul>
<li><span class="math inline">\(\frac{{dS}}{{dt}}\)</span> changes in the <span class="kn-pink">s</span><strong>usceptible</strong> compartment over time</li>
<li><span class="math inline">\(\frac{{dI}}{{dt}}\)</span> changes in the <span class="kn-pink">i</span><strong>nfected</strong> compartment over time</li>
<li><span class="math inline">\(\frac{{dR}}{{dt}}\)</span> changes in the <span class="kn-pink">r</span><strong>ecovered</strong> compartment over time</li>
</ul>
</div></div>
</section>
<section id="classic-sir-1" class="slide level2">
<h2>Classic SIR</h2>
<div class="columns">
<div class="column" style="width:45%;">
<p>How do diseases spread through a population?</p>
<ul>
<li>Divide the population into three “compartments”<br><strong><span class="kn-pink">S</span>usceptible</strong>, <strong><span class="kn-pink">I</span>nfected</strong>, <strong><span class="kn-pink">R</span>ecovered/Removed</strong></li>
<li>Model the movement of people in and out of the compartments in continuous time</li>
<li>Traditionally done with differential equations</li>
</ul>
<p><br></p>
<p><span class="math display">\[
\begin{align}
\frac{{dS}}{{dt}} &= - \left( \frac{{a}}{{N}}\right) I S \\
\frac{{dI}}{{dt}} &= \left( \frac{{a}}{{N}}\right) I S - b I \\
\frac{{dR}}{{dt}} &= bI
\end{align}
\]</span></p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:45%;">
<h4 id="the-susceptible-compartment">The Susceptible Compartment</h4>
<p><span class="math display">\[
\frac{{dS}}{{dt}} = - \left( \frac{{a}}{{N}}\right) I S
\]</span></p>
<ul>
<li><span class="math inline">\(I S\)</span> means that the more infected people (<span class="math inline">\(I\)</span>) and susceptible people (<span class="math inline">\(S\)</span>) there are, the more likely it is that susceptible people will become infected.</li>
<li><span class="math inline">\(\frac{{a}}{{N}}\)</span> represents the rate at which the disease spreads in the population, where <span class="math inline">\(a\)</span> is a constant that reflects how easily the disease spreads, and <span class="math inline">\(N\)</span> is the size of the population.</li>
<li>The minus sign indicates that the number of people in this compartment will decrease as they become infected or are removed.</li>
</ul>
</div></div>
</section>
<section id="classic-sir-2" class="slide level2">
<h2>Classic SIR</h2>
<div class="columns">
<div class="column" style="width:45%;">
<p>How do diseases spread through a population?</p>
<ul>
<li>Divide the population into three “compartments”<br><strong><span class="kn-pink">S</span>usceptible</strong>, <strong><span class="kn-pink">I</span>nfected</strong>, <strong><span class="kn-pink">R</span>ecovered/Removed</strong></li>
<li>Model the movement of people in and out of the compartments in continuous time</li>
<li>Traditionally done with differential equations</li>
</ul>
<p><br></p>
<p><span class="math display">\[
\begin{align}
\frac{{dS}}{{dt}} &= - \left( \frac{{a}}{{N}}\right) I S \\
\frac{{dI}}{{dt}} &= \left( \frac{{a}}{{N}}\right) I S - b I \\
\frac{{dR}}{{dt}} &= bI
\end{align}
\]</span></p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:45%;">
<h4 id="the-infected-compartment">The Infected Compartment</h4>
<p><span class="math display">\[
\frac{{dI}}{{dt}} = \left( \frac{{a}}{{N}}\right) I S - b I
\]</span></p>
<ul>
<li><span class="math inline">\(\left( \frac{{a}}{{N}}\right) I S\)</span> represents the number of people getting infected (i.e., moving from <span class="math inline">\(S\)</span> to <span class="math inline">\(I\)</span>).</li>
<li><span class="math inline">\(b\)</span> is a constant that reflects how quickly people recover.<a href="#/footnotes" class="footnote-ref" id="fnref1" role="doc-noteref" data-footnote-href="#/fn1" onclick=""><sup>1</sup></a></li>
<li><span class="math inline">\(- b I\)</span> represents the number of people recovering (moving from <span class="math inline">\(I\)</span> to <span class="math inline">\(R\)</span>).</li>
</ul>
</div></div>
<aside></aside></section>
<section id="classic-sir-3" class="slide level2">
<h2>Classic SIR</h2>
<div class="columns">
<div class="column" style="width:45%;">
<p>How do diseases spread through a population?</p>
<ul>
<li>Divide the population into three “compartments”<br><strong><span class="kn-pink">S</span>usceptible</strong>, <strong><span class="kn-pink">I</span>nfected</strong>, <strong><span class="kn-pink">R</span>ecovered/Removed</strong></li>
<li>Model the movement of people in and out of the compartments in continuous time</li>
<li>Traditionally done with differential equations</li>
</ul>
<p><br></p>
<p><span class="math display">\[
\begin{align}
\frac{{dS}}{{dt}} &= - \left( \frac{{a}}{{N}}\right) I S \\
\frac{{dI}}{{dt}} &= \left( \frac{{a}}{{N}}\right) I S - b I \\
\frac{{dR}}{{dt}} &= bI
\end{align}
\]</span></p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:45%;">
<h4 id="the-recovered-compartment">The Recovered Compartment</h4>
<p><span class="math display">\[
\frac{{dR}}{{dt}} = bI
\]</span></p>
<ul>
<li><span class="math inline">\(bI\)</span> shows that the number of recovered people increases as infected people recover.</li>
</ul>
</div></div>
</section>
<section id="classic-sir-4" class="slide level2">
<h2>Classic SIR</h2>
<p><br></p>
<div class="columns">
<div class="column" style="width:45%;">
<p><span class="math display">\[
\begin{align}
\frac{{dS}}{{dt}} &= - \left( \frac{{a}}{{N}}\right) I S \\
\frac{{dI}}{{dt}} &= \left( \frac{{a}}{{N}}\right) I S - b I \\
\frac{{dR}}{{dt}} &= bI
\end{align}
\]</span></p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:45%;">
<p>We’re just tracking the number of people in each compartment over time.</p>
<ul>
<li><span class="math inline">\(S\)</span> decreases as people get infected.</li>
<li><span class="math inline">\(I\)</span> increases as more people get infected but decreases as they recover.</li>
<li><span class="math inline">\(R\)</span> increases as people recover from the infection.</li>
</ul>
</div></div>
</section>
<section id="sir-in-discrete-time" class="slide level2">
<h2>SIR in Discrete Time</h2>
<div class="columns">
<div class="column" style="width:45%;">
<p>We can represent the same basic model of changes in the number of people in each compartment <em>in discrete time intervals</em> <span class="nord-light">(which makes it easier to simulate with agent-based models)</span></p>
<p><span class="math display">\[
\begin{align}
S(t + 1) &= S(t) - \beta S(t)I(t) \\
I(t + 1) &= I(t) + \beta S(t)I(t) - \gamma I(t) \\
R(t + 1) &= R(t) + \gamma I(t)
\end{align}
\]</span></p>
<p><br></p>
<p><strong>Some Model Assumptions</strong> <span class="math inline">\(\longrightarrow\)</span></p>
<p><a href="media/smaldino.jpg" class="lightbox" data-gallery="quarto-lightbox-gallery-2"><img data-src="media/smaldino.jpg" class="shadow-img" style="width:30.0%"></a></p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:45%;">
<blockquote>
<p>These equations define how the relative numbers of susceptible, infected, and recovered individuals change over time, and represent two propositions about disease contagion. <span class="kn-pink">First</span>, that susceptible individuals become infected via contact with infected individuals, at a rate that is proportional to the expected number of interactions between susceptible and infected individuals, tempered by the transmissibility of the infection, <span class="math inline">\(β\)</span>. <span class="kn-pink">Second</span>, that infected individuals recover at a constant rate, <span class="math inline">\(γ\)</span>.</p>
<p><br></p>
<p>An <span class="kn-pink">implicit assumption</span> is that the rate of interactions between individuals in different states is exactly proportional to the frequencies of those states in the population—that is, that the population is <span class="kn-pink">well-mixed</span>.</p>
<p><br></p>
<p><span class="citation" data-cites="smaldino2023modeling">Smaldino (<a href="#/section-16" role="doc-biblioref" onclick="">2023</a>)</span>, page 18</p>
</blockquote>
</div></div>
</section>
<section id="mixing-and-flattening-the-curve" class="slide level2">
<h2>Mixing and Flattening the Curve</h2>
<p><br></p>
<div class="columns">
<div class="column" style="width:55%;">
<p>Reducing physical contact reduces the <strong>effective transmission rate</strong> of a disease, which has a big impact on the number of sick people in a population.</p>
<div id="fig-sir_compare_models_1-2" class="quarto-float quarto-figure quarto-figure-left">
<figure class="quarto-float quarto-float-fig">
<div aria-describedby="fig-sir_compare_models_1-2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="media/sir_compare_models_1-2.png" class="lightbox" data-gallery="quarto-lightbox-gallery-3" title="Figure 1: Proportion of infected people in a population over time from two SIR simulations with different transmissability rates. We’ll develop the model this figure comes from later in the lecture."><img data-src="media/sir_compare_models_1-2.png" style="width:75.0%"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-sir_compare_models_1-2-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure 1: Proportion of infected people in a population over time from two SIR simulations with different transmissability rates. <span class="nord-light">We’ll develop the model this figure comes from later in the lecture.</span>
</figcaption>
</figure>
</div>
</div><div class="column" style="width:5%;">
</div><div class="column" style="width:40%;">
<p><br><br><br></p>
<h4 id="m-people-in-ontario-canada-as-of-2024">~14.4M people in Ontario, Canada <span class="nord-light">(as of 2024)</span></h4>
<!--
```python
#| echo: false
import yaml
with open('_variables.yml', 'r') as file:
variables = yaml.safe_load(file)
```
-->
<ul>
<li>A peak at <code>{python} variables['results_sir_model_1_max_infected']</code> in the high-transmissability model <span class="math inline">\(\approx\)</span> <code>{python} round(variables['ontario_population'] * variables['results_sir_model_1_max_infected'], 2)</code>M infected people</li>
<li>A peak at <code>{python} variables['results_sir_model_2_max_infected']</code> in the low-transmissability model <span class="math inline">\(\approx\)</span> <code>{python} round(variables['ontario_population'] * variables['results_sir_model_2_max_infected'], 2)</code>M infected people</li>
</ul>
<p>A <code>{python} round(variables['results_sir_model_1_max_infected']-variables['results_sir_model_2_max_infected'], 4)*100</code>% difference translates to <span class="math inline">\(\approx\)</span> <code>{python} round(variables['ontario_population']*variables['results_sir_model_1_max_infected'])-round(variables['ontario_population']*variables['results_sir_model_2_max_infected'])</code>M infected people <strong>at that particular moment in time</strong>.</p>
</div></div>
</section>
<section id="mixing-and-flattening-the-curve-1" class="slide level2">
<h2>Mixing and Flattening the Curve</h2>
<p><br></p>
<div class="columns">
<div class="column" style="width:45%;">
<div class="quarto-figure quarto-figure-left">
<figure>
<p><a href="media/anthony-delanoix-hzgs56Ze49s-unsplash.jpg" class="lightbox" data-gallery="quarto-lightbox-gallery-4" title="Imagine agents moving around the simulated world the way we move around the real world. Photo by Anthony DELANOIX on Unsplash"><img data-src="media/anthony-delanoix-hzgs56Ze49s-unsplash.jpg" class="shadow-img" style="width:85.0%" alt="Imagine agents moving around the simulated world the way we move around the real world. Photo by Anthony DELANOIX on Unsplash"></a></p>
<figcaption>Imagine agents moving around the simulated world the way we move around the real world. <span class="nord-light">Photo by <a href="https://unsplash.com/@anthonydelanoix?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Anthony DELANOIX</a> on <a href="https://unsplash.com/photos/person-performing-heart-hand-gesture-hzgs56Ze49s?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a></span></figcaption>
</figure>
</div>
</div><div class="column" style="width:5%;">
</div><div class="column" style="width:50%;">
<div id="fig-compare_agent_step_sizes" class="quarto-float quarto-figure quarto-figure-left">
<figure class="quarto-float quarto-float-fig">
<div aria-describedby="fig-compare_agent_step_sizes-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="media/compare_agent_step_sizes.png" class="lightbox" data-gallery="quarto-lightbox-gallery-5" title="Figure 2: The space covered by an agent who can take as many as 8 steps is much greater than the space covered by an agent who can only take 1. The grid is toroidal, which means all four edges wrap to each other."><img data-src="media/compare_agent_step_sizes.png" style="width:100.0%"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-compare_agent_step_sizes-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure 2: The space covered by an agent who can take as many as 8 steps is much greater than the space covered by an agent who can only take 1. The grid is <strong>toroidal</strong>, which means all four edges wrap to each other.
</figcaption>
</figure>
</div>
</div></div>
<!--
## Mixing and Flattening the Curve
[More movement = more mixing = more exposures = more infections.]{.kn-pink}
But there are some qualifications that will come up a bit later in the lecture.
<br>
:::: {.columns}
::: {.column width="45%"}
#### Shared Parameters
| Parameter | Value |
|-----------------------|------------------------------|
| N | 150 |
| grid_height | 40 |
| grid_width | 40 |
| infection_rate | 0.15 |
| n_initial_infections| 2 |
| n_iterations | 100 |
| recovery_time_range | (7, 14) |
:::
::: {.column width="55%"}
{width=42% #sir_compare_models_3-6} {width=36% #fig-compare_agent_networks}
[@sir_compare_models_3-6 (left) Two SIR models with identical parameters other than max agent step size. @fig-compare_agent_networks (right) edge weight ECDF.]{.small-text}
<br>
| | No. Nodes | No. Edges | Avg. Degree |
|:---|------------:|------------:|--------------:|
| M1 | 100 | 984 | 19.68 |
| M2 | 100 | 997 | 19.94 |
:::
::::
-->
</section>
<section id="equation-vs.-agent-based-models" class="slide level2">
<h2>Equation vs. Agent-based Models</h2>
<p><br><br><br></p>
<p>Unlike equation-based models of systems, ABMs</p>
<ul>
<li>do not rely on aggregated variables to represent system components</li>
<li>emphasize heterogeneity by directly representing individual agents and their iteractions</li>
<li>focuses on emergent outcomes and contextualized adaptive behaviours</li>
<li>are not contrained by mathematical tractability</li>
<li>etc.</li>
</ul>
</section>
<section id="section-2" class="slide level2 scrollable">
<h2></h2>
<p><span class="nord-footer"><span class="citation" data-cites="railsback2019agent">(<a href="#/section-16" role="doc-biblioref" onclick="">Railsback and Grimm 2019</a>)</span></span></p>
<h3 id="what-is-the-agent-based-modelling-cycle">What is the agent-based modelling cycle?</h3>
<p><br></p>
<div class="columns">
<div class="column" style="width:45%;">
<div id="fig-abm-cycle" class="quarto-float quarto-figure quarto-figure-left">
<figure class="quarto-float quarto-float-fig">
<div aria-describedby="fig-abm-cycle-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="media/abm-cycle.png" class="lightbox" data-gallery="quarto-lightbox-gallery-6" title="Figure 3: The ABM modelling cycle is a great fit with the Box and Wickham loops we’ve mentioned repeatedly throughout the course. Figure reproduced from @railsback2019agent."><img data-src="media/abm-cycle.png" style="width:100.0%"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-abm-cycle-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure 3: The ABM modelling cycle is a great fit with the Box and Wickham loops we’ve mentioned repeatedly throughout the course. <span class="nord-light">Figure reproduced from <span class="citation" data-cites="railsback2019agent">Railsback and Grimm (<a href="#/section-16" role="doc-biblioref" onclick="">2019</a>)</span>.</span>
</figcaption>
</figure>
</div>
</div><div class="column" style="width:5%;">
</div><div class="column" style="width:50%;">
<div class="fragment">
<ol type="1">
<li>Formulate the question</li>
</ol>
</div>
<div class="fragment">
<ol start="2" type="1">
<li>Assemble hypotheses for essential processes and structure</li>
</ol>
</div>
<div class="fragment">
<ol start="3" type="1">
<li>Choose model structure<br><span class="nord-footer">(scales, entities, state variables, processes, and parameters)</span></li>
</ol>
</div>
<div class="fragment">
<ol start="4" type="1">
<li>Implement the model</li>
</ol>
</div>
<div class="fragment">
<ol start="5" type="1">
<li>Analyze, test, and revise the model<br><span class="nord-footer">(recall the Box and Wickham loops!)</span></li>
</ol>
</div>
<div class="fragment">
<ol start="6" type="1">
<li>Communicate the model</li>
</ol>
</div>
</div></div>
<p>We’ll talk about <span class="kn-pink">patterns</span> and the role they play in modelling shortly.</p>
<aside class="notes">
<p>The modeling cycle is a systematic and iterative process used to develop, implement, analyze, and refine <strong>scientific</strong> agent-based models. This cycle is essential for ensuring that models are well-designed, accurately reflect the system they are meant to represent, and are useful for answering specific research questions. The cycle typically involves the following key steps:</p>
<ol type="1">
<li><strong>Formulate the Question</strong>
<ul>
<li><strong>Purpose:</strong> The first step is to clearly define the research question that the model is intended to answer. This question acts as a guiding principle for the entire modeling process, helping to determine which aspects of the real system should be included or excluded in the model.</li>
<li><strong>Importance:</strong> A well-defined question ensures that the model remains focused and relevant. It also serves as a filter, helping to decide which factors in the real system are important for the model and which can be ignored.</li>
<li><strong>Challenges:</strong> Formulating a clear question can be difficult, especially in complex systems where multiple factors are interrelated. Often, the question may need to be refined as the modeling process progresses.</li>
</ul></li>
<li><strong>Assemble Hypotheses for Essential Processes and Structures</strong>
<ul>
<li><strong>Purpose:</strong> Once the question is formulated, the next step is to hypothesize which processes and structures within the system are essential to address the research question. This involves identifying the key factors that drive the system’s behavior and determining how these factors interact.</li>
<li><strong>Top-Down and Bottom-Up Approaches:</strong> This step can be approached in two ways:
<ul>
<li><strong>Top-Down:</strong> Consider the major influences on the phenomena of interest and how they might interact.</li>
<li><strong>Bottom-Up:</strong> Start with basic components and build up to more complex interactions.</li>
</ul></li>
<li><strong>Simplification:</strong> It is crucial to start with the simplest possible model that still addresses the research question. Simplification helps in quickly implementing and testing the model, which is more productive than starting with a complex model that is difficult to manage.</li>
</ul></li>
<li><strong>Choose Scales, Entities, State Variables, Processes, and Parameters</strong>
<ul>
<li><strong>Purpose:</strong> In this step, the specific details of the model are defined. This includes determining the scale at which the model operates (e.g., temporal and spatial scales), identifying the entities involved (e.g., agents in an ABM), and selecting the state variables that describe these entities (e.g., position, health status).</li>
<li><strong>Model Structure:</strong> The model’s structure is outlined, including how different entities interact with each other and with their environment. This is often documented in a written formulation, which serves as a blueprint for the model.</li>
<li><strong>Importance:</strong> A clear and detailed model structure is essential for successful implementation and later analysis. It also aids in communicating the model to others, such as collaborators or reviewers.</li>
</ul></li>
<li><strong>Implement the Model</strong>
<ul>
<li><strong>Purpose:</strong> The verbal or written description of the model is translated into a computer program or mathematical framework. This involves using appropriate tools and platforms, such as NetLogo for agent-based models, to bring the model to life.</li>
<li><strong>Challenges:</strong> Implementation can be technically demanding, especially for beginners. However, using established software platforms can greatly simplify this task and reduce the time required to develop a functioning model.</li>
<li><strong>Rightness of Implementation:</strong> The implementation itself is always “right” in the sense that it accurately represents the assumptions encoded in the model, allowing for the rigorous exploration of these assumptions.</li>
</ul></li>
<li><strong>Analyze, Test, and Revise the Model</strong>
<ul>
<li><strong>Purpose:</strong> After implementation, the model is analyzed to see if it behaves as expected and whether it provides useful insights into the research question. This involves testing the model’s predictions against real-world data, conducting sensitivity analyses, and iterating on the model’s design to improve its accuracy and relevance.</li>
<li><strong>Iteration:</strong> This step is the most time-consuming and involves repeated cycles of testing and refining the model. As the model is analyzed, new insights may lead to revisions in the model’s structure, assumptions, or parameters.</li>
<li><strong>Importance:</strong> This step is crucial for validating the model and ensuring that it provides reliable answers to the research question. It also helps to identify and correct any oversimplifications or inaccuracies in the initial model.</li>
</ul></li>
<li><strong>Communicate the Model</strong>
<ul>
<li><strong>Purpose:</strong> The final step involves sharing the model and its findings with the scientific community, policymakers, or other stakeholders. This can include publishing the model in a scientific journal, presenting it at conferences, or providing reports to decision-makers.</li>
<li><strong>Documentation:</strong> Communication also involves thoroughly documenting the model and the results of its analysis. This documentation is vital for transparency, reproducibility, and for others to understand and build upon the work.</li>
<li><strong>Feedback:</strong> Sharing the model often leads to feedback, which can further refine the model or suggest new directions for research.</li>
</ul></li>
</ol>
<p>The modeling cycle is inherently <strong>iterative</strong> and focuses on <strong>continuous imporvement</strong>. It is rare to go through the entire cycle only once; instead, modelers often loop back to earlier steps as new insights are gained. For example, the initial research question might be refined based on what is learned during model analysis, leading to adjustments in hypotheses or model structure. This iterative nature allows for continuous improvement of the model, making it more accurate and useful over time.</p>
<p>Throughout the modeling cycle, there is an emphasis on <strong>starting simple and adding complexity only when necessary</strong>. This is based on the principle that simpler models are easier to implement, test, and understand. As the model progresses through the cycle, additional factors can be introduced gradually, allowing for a better understanding of their impact on the system.</p>
<p>In short, the modeling cycle is a structured approach to developing scientific models that involves formulating a clear question, hypothesizing essential processes, designing and implementing the model, analyzing and refining it, and finally communicating the results. This iterative process ensures that models are both scientifically rigorous and practically useful for addressing complex research questions.</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="section-3" class="slide level2">
<h2></h2>
<p><span class="nord-footer"><span class="citation" data-cites="railsback2019agent">(<a href="#/section-16" role="doc-biblioref" onclick="">Railsback and Grimm 2019</a>)</span></span></p>
<h3 id="how-do-we-design-document-and-develop-abms">How do we design, document, and develop ABMs?</h3>
<p><br></p>
<div class="columns">
<div class="column" style="width:45%;">
<p><strong>Explicit</strong> model formulations are <strong>essential</strong> for understanding and thinking clearly about the model, implementing it in code, learning from it, and communicating it to others. In ABM, especially in the social and ecological sciences, this follows the <strong>ODD protocol</strong> <span class="nord-light">(Overview, Design concepts, and Details)</span>, which provides a structured and systematic way to formulate, describe, and communicate ABMs, ensuring that the models are clear, complete, and reproducible.</p>
<p><br></p>
<p>ODD is not only a tool for final documentation; it serves as a framework for the iterative development of the model and an initial version should be developed <em>before</em> you start implementing your ideas! For many reasons, this makes implementation <strong>much</strong> easier and more efficient.</p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:45%;">
<div id="fig-odd" class="quarto-float quarto-figure quarto-figure-left">
<figure class="quarto-float quarto-float-fig">
<div aria-describedby="fig-odd-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<a href="media/odd.png" class="lightbox" data-gallery="quarto-lightbox-gallery-7" title="Figure 4: High-level structure of the ODD protocol. Figure reproduced from @railsback2019agent, which was revised from @grimm2010odd."><img data-src="media/odd.png" style="width:75.0%"></a>
</div>
<figcaption class="quarto-float-caption-bottom quarto-float-caption quarto-float-fig" id="fig-odd-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure 4: High-level structure of the ODD protocol. <span class="nord-light">Figure reproduced from <span class="citation" data-cites="railsback2019agent">Railsback and Grimm (<a href="#/section-16" role="doc-biblioref" onclick="">2019</a>)</span>, which was revised from <span class="citation" data-cites="grimm2010odd">Grimm et al. (<a href="#/section-16" role="doc-biblioref" onclick="">2010</a>)</span>.</span>
</figcaption>
</figure>
</div>
</div></div>
<aside class="notes">
<p>ODDs have the following high-level components:</p>
<ul>
<li>Purpose and Patterns: The model’s purpose is defined clearly, specifying what the model is for and what patterns it should reproduce to be considered realistic.</li>
<li>Entities, State Variables, and Scales: These outline the types of entities (e.g., agents, environment) in the model, the variables that characterize them, and the temporal and spatial scales used in the model.</li>
<li>Process Overview and Scheduling: This describes the processes that govern the dynamics of the model (e.g., agent behaviors) and how these processes are scheduled over time.</li>
<li>Design Concepts: This section covers basic principles, emergence, adaptation, and other design concepts essential for understanding how the model works. We will come back to the idea of design concepts later in the lecture.</li>
<li>Initialization: How the model is set up at the beginning of a simulation, including the initial state of agents and environment.</li>
<li>Input Data: Describes external data inputs that change over time and are used in the model.</li>
<li>Submodels: Detailed descriptions of the submodels that represent specific processes within the ABM.</li>
</ul>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="what-are-model-design-concepts" class="slide level2">
<h2>What are <span class="kn-pink">model design concepts</span>?</h2>
<p>Model design concepts are an important part of the ODD protocol. What are they, exactly?</p>
<p><br></p>
<!-- design-concepts-questions.png -->
<div class="columns">
<div class="column" style="width:25%;">
<p><br></p>
<ul>
<li>Emergence</li>
<li>Observation</li>
<li>Sensing</li>
<li>Adaptive Behaviour and Objectives</li>
<li>Prediction</li>
<li>Interaction</li>
<li>Scheduling</li>
<li>Stochasticity</li>
<li>Collectives</li>
</ul>
</div><div class="column" style="width:5%;">
</div><div class="column" style="width:70%;">
<blockquote>
<p>Each time you build an ABM, you need to think about how each of these concepts is addressed, if it is, in the model. Why? The first reason is to make sure that you think about all the important model design issues and decide explicitly how to handle each. Otherwise, important parts of the model’s design could be determined accidentally or only by programming convenience, and your model will seem ad hoc and unscientific. The second reason is to make it easier to describe your model to others. When modelers use the ODD protocol and these design concepts to describe ABMs, it is much easier for others to understand the model’s most important characteristics. Not all of the concepts will be important to each ABM, but thinking about each of the concepts helps you convince yourself and others that all the important model design decisions were made explicitly and carefully. (For this reason, the design concepts are also very useful when you review someone else’s ABM.)</p>
<p><span class="citation" data-cites="railsback2019agent">Railsback and Grimm (<a href="#/section-16" role="doc-biblioref" onclick="">2019</a>)</span>, pp. 99-100</p>
</blockquote>
</div></div>
<aside class="notes">
<ul>
<li><strong>Emergence</strong> refers to the patterns, behaviors, or outcomes that arise from the interactions of individual agents within the model. These emergent properties are not directly programmed into the model but instead result from the collective dynamics of the agents. Understanding and analyzing these emergent phenomena are often the primary goals of using ABMs.
<ul>
<li><em>In the SIR model, the emergent behavior is the epidemic curve that shows how the disease spreads through the population over time, leading to waves of infection, recovery, and potential stabilization.</em></li>
</ul></li>
<li><strong>Observation</strong> involves how the model’s outcomes are recorded and analyzed. This concept includes specifying what data will be collected from the model during its execution, such as the number of agents in different states, spatial distributions, or interaction networks. The way observations are made can significantly influence the interpretation of the model’s results.
<ul>
<li><em>In the SIR model, observation is carried out by collecting data on the number of infected, susceptible, and recovered agents at each time step, as well as the duration of infections and the interactions between agents.</em></li>
</ul></li>
<li><strong>Sensing</strong> describes the information that agents can perceive about their environment and other agents. It includes what variables the agents are aware of, such as the state of nearby agents or environmental conditions, and how accurately they sense this information. The sensing capability of agents influences their decision-making and behavior. In some cases, agents may not really be “aware,” such as in a model of infectious disease diffusion.