-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFrom_Cyber_to_PhysicalSpace_UpdatedModel_NetLogo6_1.nlogo
1448 lines (1173 loc) · 28 KB
/
From_Cyber_to_PhysicalSpace_UpdatedModel_NetLogo6_1.nlogo
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
;Paper Title: From Cyber Space Opinion Leaders and the Spread of Anti-Vaccine Extremism to Physical Space Disease Vulnerable Clusters
;By Xiaoyi Yuan
extensions [
CSV
]
globals [
recover-rate ;the rate of recovery when people get infected; After recovery, they are permanently immuned
extremists ;list of people who are extremists
]
turtles-own [
ID ;each turtle gets an ID
location ;record the turtle's patch location so that after network visualization, he/she knows where to go back
local-neighbors ;the physical space neighbors (8 neighbors for each one of them)
anti-vaccine-sentiment ;range from -1 to 1, higher the value, more likely to be an anti-vaccine extremist. if -1, it means that the person is very pro-vaccination
extremist? ;True or False
vaccinated? ;True means vacinnated, False means not vaccinated
susceptible?;True means susceptible (those who don't get the vaccine will be susceptible) , False means not susceptible
infected? ;True means that the person is infectious
recovered? ;True means that the person is recovered from the infection and once recovered, he/she will be permanently immnued
]
links-own [
rewired?
]
to setup
ca
ask patches [
sprout 1 ;Total number of patches is 2601.
;In this model, for the sake of simplicity, I don't consider the density of physical space, so the world is always "full of people" (one person on each patch)
]
ask turtles [
set shape "person"
set color brown
set anti-vaccine-sentiment 0
set extremist? False
set extremists []
set location patch-here
set local-neighbors turtles-on neighbors
set vaccinated? False
set susceptible? False
set infected? False
set recovered? False
]
reset-ticks
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; information network;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;two types of connection between people in this model:
;1. physical connection: each person has 8 neighbors around them, symbolizing real-world physical spatial connections
;(This connection facilitates disease transmission, and in this model, I assume that people don't communicate their opinion within spatial connections)
;2. cyber connection: the network.
;(This connection symbolize the online opinion communication, and of course, disease won't transmit through online connections)
to generate-network
;Scale-free network, characterized by a power law degree distribution
ask links [die]
;randomly select two person and connect them first
let node1 one-of turtles
ask one-of turtles [
if node1 != self [
create-link-with node1
[set color cyan]
]
]
;then the one with higher degree would have a higher probability of attracting new links
while [count turtles with [count link-neighbors > 1] <= num-nodes-connected]
[
let old-node [one-of both-ends] of one-of links
ask one-of turtles [
if old-node != nobody and old-node != self
[
create-link-with old-node
[set color cyan]
]
]
]
end
to hide-network
ask links [
hide-link
]
end
to show-network
ask links [
show-link
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; opinion diffusion ;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup-opinions
set extremists []
ask turtles [
set extremist? false
set color brown
set anti-vaccine-sentiment 0
]
end
to spread-extremism
setup-opinions
assign-sentiment
assign-leaders-extremists
cyber-spread-extremism
local-spread-extremism
end
;1. Assign anti-vaccine-sentiment (uniform distribution)
to assign-sentiment
ask turtles [
set anti-vaccine-sentiment median (list -1 (random-normal 0 1) 1)
]
end
;2. Assign certain percent (a parameter) of opinion leaders as extremists (reassign their anti-vaccine-sentiment as 1)
to assign-leaders-extremists
;first find out who are the most highly connected people
let lst (reverse (sort-on [count link-neighbors] turtles))
set extremists sublist lst 0 n-extremists-leaders
foreach extremists [ ?1 ->
ask ?1 [
set anti-vaccine-sentiment 1
set extremist? True
set color cyan
]
]
end
;3. social influence on the cyber-network (the less stubborn a person is, the higher probability that person would be influenced)
to cyber-spread-extremism
;those who are connected with extremist opinion leaders are potential targets
let potential-targets []
foreach extremists [ ?1 ->
ask ?1 [
set potential-targets lput link-neighbors potential-targets
]
]
;If their anti-vaccination-sentiments are higher than a certain level, they will be turned into extremists under the influence
foreach potential-targets [ ?1 ->
ask ?1 [
if anti-vaccine-sentiment >= threshold-sentiment [
set extremist? True
]
]
]
ask turtles [
if extremist? and not member? self extremists [
set extremists lput self extremists
set color cyan
]
]
end
;4. social influence on the physical space (the less stubborn a person is, the higher probability that person would be influenced)
to local-spread-extremism
let potential-targets []
foreach extremists [ ?1 ->
ask ?1 [
set potential-targets lput local-neighbors potential-targets
]
]
foreach potential-targets [ ?1 ->
ask ?1 [
if anti-vaccine-sentiment >= threshold-sentiment [
set extremist? True
]
]
]
ask turtles [
if extremist? and not member? self extremists [
set extremists lput self extremists
set color cyan
]
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; disease transmission process;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup-disease
clear-plot
reset-ticks
ask turtles [
set infected? False
set recovered? false
set susceptible? False
set vaccinated? False
]
end
to vaccinate-non-extremists
setup-disease
ask turtles with [extremist? = False][
set vaccinated? True
]
ask turtles with [extremist? = True] [
set vaccinated? False
set color cyan
]
end
to vaccinate-random-people
setup-disease
ask turtles [
set vaccinated? True
set color brown
]
ask n-of length extremists turtles [
set vaccinated? False
set color cyan
]
end
to transmit-disease
spread-disease
recover
end
to infect
ask turtles with [vaccinated? = False][
set susceptible? True
]
ask n-of 10 turtles with [susceptible? = True] [
set infected? True
set color red
]
end
to spread-disease
ask turtles with [susceptible? = True and recovered? = False] [
let n-infected-neighbors 0
ask turtles-on neighbors [
if infected? = True [
set n-infected-neighbors n-infected-neighbors + 1
]
]
if random-float 1 <= (1 - e ^ (- 0.05 * n-infected-neighbors)) [
set infected? True
set color red
]
]
tick
end
to recover
ask turtles with [infected? = True] [
if random-float 1 <= 0.001 [
set recovered? True
set infected? False
set susceptible? False
set color green
]
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; visualizations ;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Since agents are connected in two ways, the physical (patches) and the information network
;Therefore there are two ways of visualization that shows their connections
to visualize-cyber-network
ask turtles [
set size (sqrt count my-links) / 3
]
;; layout-spring makes all the links act like springs.
;; 0.2 - spring constant; how hard the spring pushes or pulls to get to its ideal length
;; 2 - ideal spring length
;; 0.5 - repulsion; how hard all turtles push against each other to space things out
layout-spring turtles links 0.2 2 0.5
;; the layout doesn't look good if nodes get squeezed up against edges of the world
ask turtles [
;; stay away from the edges of the world; the closer I get to the edge, the more I try
;; to get away from it.
facexy 0 0
fd (distancexy 0 0) / 100
]
end
to visualize-physical-space
ask turtles [
move-to location
]
end
to uniform-size
ask turtles [
set size 1
]
end
to degree-size
ask turtles [
set size (sqrt count my-links) / 3
]
end
to make-report
let parameter_lst []
let lst1 [1 2 3 4 5 10 15 20 30]
let i 0
while [i <= 8] [
set n-extremists-leaders item i lst1
set threshold-sentiment 0.5
while [threshold-sentiment <= 1] [
set parameter_lst lput list n-extremists-leaders precision threshold-sentiment 2 parameter_lst
set threshold-sentiment threshold-sentiment + 0.05
]
set i i + 1
]
let n 0
while [n <= 90] [
set n-extremists-leaders item 0 (item n parameter_lst)
set threshold-sentiment item 1 (item n parameter_lst)
let nextremists []
let infected_e []
let infected_r []
let lst []
repeat 20 [
;spread extremism
setup-opinions
spread-extremism
set nextremists lput length extremists nextremists
;vaccinate extremists
setup-disease
vaccinate-non-extremists
infect
let ninfected []
while [count turtles with [infected? = True] > 0] [
transmit-disease
set ninfected lput count turtles with [infected? = true] ninfected]
set infected_e lput max ninfected infected_e
;vaccinate random people
setup-disease
vaccinate-random-people
infect
let ninfected2 []
while [count turtles with [infected? = true] > 0] [
transmit-disease
set ninfected2 lput count turtles with [infected? = true] ninfected2]
set infected_r lput max ninfected2 infected_r
]
let mean_extremists mean nextremists
let sd_extremists standard-deviation nextremists
let mean_infected_e mean infected_e
let sd_infected_e standard-deviation infected_e
let mean_infected_r mean infected_r
let sd_infected_r standard-deviation infected_r
set lst lput (list mean_extremists sd_extremists mean_infected_e sd_infected_e) lst
set lst lput (list mean_extremists sd_extremists mean_infected_r sd_infected_r) lst
csv:to-file (word n-extremists-leaders "-" threshold-sentiment ".csv") lst
file-close
set n n + 1
]
end
@#$#@#$#@
GRAPHICS-WINDOW
224
10
742
529
-1
-1
10.0
1
10
1
1
1
0
1
1
1
-25
25
-25
25
0
0
1
ticks
30.0
BUTTON
72
31
135
64
NIL
setup
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
SLIDER
20
120
193
153
num-nodes-connected
num-nodes-connected
0
2601
2500.0
1
1
NIL
HORIZONTAL
BUTTON
20
153
193
186
NIL
generate-network
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
19
222
107
255
NIL
hide-network
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
106
222
193
255
NIL
show-network
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
MONITOR
752
459
832
504
links
count links
17
1
11
BUTTON
19
255
193
288
NIL
visualize-cyber-network
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
19
288
193
321
NIL
visualize-physical-space
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
19
321
111
354
NIL
uniform-size
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
110
321
193
354
NIL
degree-size
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
SLIDER
21
421
213
454
n-extremists-leaders
n-extremists-leaders
0
30
30.0
1
1
NIL
HORIZONTAL
SLIDER
21
454
213
487
threshold-sentiment
threshold-sentiment
0
1
1.0000000000000004
0.01
1
NIL
HORIZONTAL
MONITOR
919
459
1004
504
extremists
length extremists
17
1
11
BUTTON
21
486
213
519
NIL
spread-extremism
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
752
70
902
103
NIL
vaccinate-non-extremists\n
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
752
103
902
136
NIL
infect
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
PLOT
751
201
1109
438
disease transmission
NIL
NIL
0.0
10.0
0.0
100.0
true
true
"" ""
PENS
"infected" 1.0 0 -5298144 true "" "plot count turtles with [infected? = True]"
"recovered" 1.0 0 -13210332 true "" "plot count turtles with [recovered? = True]"
"susceptible" 1.0 0 -4079321 true "" "plot count turtles with [susceptible? = True]"
BUTTON
752
136
902
169
NIL
transmit-disease
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
MONITOR
832
504
919
549
susceptibles
count turtles with [susceptible? = True]
17
1
11
MONITOR
752
504
832
549
vaccinated
count turtles with [vaccinated? = True]
17
1
11
MONITOR
919
504
1004
549
infected
count turtles with [infected? = True]
17
1
11
MONITOR
1003
504
1104
549
recovered
count turtles with [recovered? = True]
17
1
11
BUTTON
956
71
1109
104
NIL
vaccinate-random-people
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
MONITOR
1003
459
1104
504
vaccine coverage
precision (count turtles with [vaccinated? = True] / count turtles) 2
17
1
11
TEXTBOX
49
93
199
111
1. Create Cyber Network
11
0.0
1
TEXTBOX
22
204
172
222
Network Visualization
11
0.0
1
TEXTBOX
58
395
208
430
2. Spread of Extremism
11
0.0
1
TEXTBOX
772
30
901
58
3. Vaccination and \nDisease Transmission
11
0.0
1
TEXTBOX
970
33
1120
51
4. Comparison Group
11
0.0
1
TEXTBOX
919
57
1195
79
(Vaccinate same number of random chosen population)
9
0.0
1
BUTTON
956
104
1109
137
NIL
infect
NIL
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
BUTTON
956
137
1109
170
NIL
Transmit-disease
T
1
T
OBSERVER
NIL
NIL
NIL
NIL
1
MONITOR
832
459
919
504