forked from tkuerschner/SwiFColBM_Evolution2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SwiFCoIBM_Evo.nlogo
7044 lines (6423 loc) · 209 KB
/
SwiFCoIBM_Evo.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
;============================================================================================================================================
; SwiFCoIBM_evo - Individual-Based Swine Fever Community Model with explicit movement, trait evolution and dynamic landscape processes
; (based on model versions published in Kramer-Schadt et al. 2009, Lange et al. 2012 and Scherer et al. 2020, Kürschner et al. 2021)
;
;
; The model is composed of two major components:
; (1) a wild boar demography model considering seasonal reproduction, herd splitting (dispersal) and mortality and
; (2) a Classical Swine Fever (CSF) virus model operating on the emerging wild boar population.
;============================================================================================================================================
;============================================================================================================================================
; STATE VARIABLES
;============================================================================================================================================
globals
[
Habitat ;habitat cells (cells with Quality > 0)
Matrix ;matrix cells (cells with Quality = 0)
WeekRelease ;random week in YearRelease of virus release following an exponential distribution with lambda = 1.5
MaxAge ;maximum age in weeks
SurvivalProb ;annual survival rate of adults and subadults (mean = 0.65, min = 0.4)
SurvivalProbPig ;annual survival rate of piglets (mean = 0.5, min = 0.1)
currHerdID ;current maximum herd ID
ProbRepro ;monthly reproduction probability
week ;current week of the year
NewLeth ;number of individuals which got lethally infected during this timestep
NewTrans ;number of individuals which got transient infected during this timestep
Tag ;random chosen roaming male
TrackCol ;pen color of tracked roaming individuals
MNR ;mean of log-normal distribution for normal-distance roaming males
NmaxList ;input data: sums of the number of patches adjacent to each patch in a circle of the same area as the infected/infectious area (see Report_fragmentation)
ReproList ;input data: cumulative reproduction probabilities for each month
MeanLethPeriod ;mean infectious period of lethal infected individuals in weeks (equals mue)
MaxLethPeriod ;maximum infectious period of lethal infected individuals in weeks (equals mue)
rep ;number of repetitions in case of running BehaviourSpace experiments
DONE ;1 if stop conditions are TRUE
week_overlap ;overlap
max_id ;id helper
rednoise_list ;external input of red noise values
Time ;counting minutes since starting setup
InfDist ;maximum spatial distance of disease transmission
InfX ;coordinate x of the pathogen-introduced cell
InfY ;coordinate y of the pathogen-introduced cell
MaxDist ;week when infection reached other side of the tubus
WeekLast ;week in which the last infected individual was noted
MeanMoveDist ;mean weekly movement distance
outbreak_group ;number of individuals in release cell
outbreak_roaming ;number of adult males in release cell
outbreak_dens5 ;number of individuals in the release cell and its 5 neighbors
outbreak_dens12 ;number of individuals in a radius of 12 cells from the release cell
F_infected ;fragmentation index for infectious cells (patches which contain shedding individuals)
F_infectious ;fragmentation index for infected cells (patches which were infected at least one week during the simulation)
PopStructList ;current age class distribution of all individuals in years
InfStructList ;current age class distribution of infected individuals (EpiStat = esLeth or esTrans) in years
InfTransStructList ;current age class distribution of transient infected individuals (EpiStat = esTrans) in years
InfLethStructList ;current age class distribution of lethally infected individuals (EpiStat = esLeth) in years
CurrInfPeriodList ;current infectious periods of lethally infected individuals (EpiStat = esLeth) in weeks
LethPeriodList ;all infectious periods of lethally infected individuals (EpiStat = esLeth) in weeks
InfPeriodList ;all infectious periods of lethally and transient infected individuals (EpiStat = esLeth and esTrans) in weeks
controll ;controls helper variable
qual ;controls helper variable
o_list ;output for infected per landscape cell
cells_in_order ;all landscape cells ordered by coordinates
meanStrain ;mean strain of all infected individuals
testCounterAlltime ;helper / counter
sumOfInfectionEvents ;helper / counter
sumOfEvolutionEvents ;helper / counter
BetaW_Middle ;transmission factors
BetaB_Middle ;transmission factors
survivalTimeList ;listed survival times per strain
transmissionFailures ;virulence / strain variable
warningCounter ;virulence / strain variable
fixedExtTimesList ;list of survival times (fixed)
meanStrainOutput ;virulence / strain variable
transList ;transmission factor list
strainList ;list of stains
;--------------------------------------------------
;UI-defined global variables (e.g. inputs)
;--------------------------------------------------
;MeanQuality ;maximum value for habitat quality to define range of habitat quality (quality between 0 and MeanQuality)
;YearRelease ;year in which an randomly individual becomes infected (range of WeekRelease)
;FemDispEvent ;counting natal dispersal events of females
;MaleDispEvent ;counting natal dispersal events of males
;seed ;seed used if seed-setup = "ON"
;q ;probability to move straight to target cells
;SimulatedYears ;number of simulated years during one run
;ProbFem ;sex ratio (0: only males; 1: only females)
;CaseFatality ;general risk for getting lethally infected by a disease transmission
;BetaWithin ;transmission coefficient within the herd
;BetaBetween ;transmission coefficient between herds
;BetaMove ;transmission coefficient during roaming movements
;PreNatInf ;probability of pre-natal infection
;FertRedInf ;reduction in fertility of infected females
;mue ;mean of exponential survival time distribution for lethally infected individuals
;T_trans ;infectious period of transiently infected individuals
;T_immu ;maximum duration of immunity by maternal antibodies (Depner et al. 2000)
;T_anti ;maximum persistence of maternal antibodies (Depner et al. 2000)
;T_latent ;duration of latent transmission
;Longevity ;maximum age in years (MaxAge / 52)
;AgeBlur ;stochastic deviation from age class thresholds in weeks (in both directions (age class threshold +/- AgeBlur) following a normal distribution
;Herd% ;proportion of habitat patches occupied by herds
;ReleaseFactor ;multiplies breeding capacity of each occupied patch to determine number of boars
;Landscape ;way of landscape generation or import
]
turtles-own
[
Age ;individual age in weeks
is_female ;individual sex: female or male
HerdID ;herd membership
IndCaseFatality ;individual mortality rate (CaseFatality ^ 2 for adults, sqrt CaseFatality for Juveniles)
AgeGroup ;age group turtle belongs to: piglet, subadult, adult; differs between sexes
DemStat ;demographic status: dsResident, dsOffspring, dsDispF, dsDispM_adult, dsDispM_subadult
EpiStat ;epidemiological status: esSusc, esTrans, esLeth, esImm, esImmMat
is_shedding ;1 if the individual is infected (EpiStat = esTrans or esLeth
TickInf ;week of infection
TickLeth ;week of death after infection (for esLeth)
IndBetaMove ;individual transmission probabilities for roaming individuals based on movement steps of current week (~time spent per cell)
Family ;contains state variable [who] of the mother
ChanceBreeding ;random number for stochastic effects in monthly reproduction for the given year
TickBirth ;week of birth
is_matAB ;1 if mother had anti bodies (= was immune)
is_mother ;1 if female had offspring in current year
is_breeder ;1 if female is allowed to breed in current year
MoveDist ;individual weekly movement distance
NoGroup ;group number
float_counter ;number of boars without valid home cells
quality_memory ;habitat quality of cells
strain ;strain
hasActiveStrain ;infected
initialOutbreak ;initial outbreak
transientCheck ;transient / lethal infection
strainToGet ;low, med, high virulence
markedForInfection ;determines infection
strainVirToGet ;determines which strain it got its infection from 1 low 2 mid 3 high
counterGotInfected ;count variable
moveBetaList ;list of beta for moving individuals
]
patches-own
[
is_occupied ;1 if a patch contains a herd of wild boars
Quality ;habitat quality in terms of breeding capacity = number of females allowed to breed
is_habitat ;true if Quality > 0
Qual_around ;summed habitat quality of surrounding cells (to decide if movement is possible)
Capacity ;overall capacity = Quality * (mean number of 20 boars per cell / mean Quality) = Quality * (20 / 4.5) = 4.4445 boars per quality unit
NoInfected ;number of infectious individuals of this habitat patch
NoInfectedMove ;number of infectious moving individuals of this habitat patch
InfPress ;infection pressure based on infected individuals in and around this patch
is_infectious ;1 if patch is infected at the current step
is_infected ;1 if patch has been infected during simulation
inf_count ;keeps track of how many times a patch contained one or more infected individuals
NoBoars ;number of individuals per cell
NoRepro ;number of reproductive females (subadult + adult) per cell
NoMale ;number of adult males per cell
NoDispF ;number of female dispersers per cell
DispCells ;cells in dispersal distance of the focal cell
W_M ;density component
dynamic ;1 for dynamic landscape, 0 for static landscape
counter_d ;habitat quality / breeding capacity
qmw ;mean habitat quality
dec ;dynamic helper variable
inc ;dynamic helper variable
qmax ;maximum habitat quality
qmin ;minimum habitat quality
sq ;dynamic helper variable
controll_mean ;buffer helper variable
counter_mean ;buffer helper variable
id ;id
infection_output_counter ;output helper variable
InfPressLowVir ;grouped infection pressure low
InfPressHighVir ;grouped infection pressure high
NoInfectedM ;counters
NoInfectedLowVir ;counters
NoInfectedHighVir ;counters
NoInfectedAdj ;counters
AllSus ;counters
tmpToInfectHere ;counters
NoInfectedMoveH ;counters
NoInfectedMoveL ;counters
toInfect ;counters
ip1 ;strain infection pressure
ip2 ;strain infection pressure
ip3 ;strain infection pressure
ip4 ;strain infection pressure
ip5 ;strain infection pressure
ip6 ;strain infection pressure
ip7 ;strain infection pressure
ip8 ;strain infection pressure
ip9 ;strain infection pressure
ip10 ;strain infection pressure
ip11 ;strain infection pressure
ip12 ;strain infection pressure
ip13 ;strain infection pressure
ip14 ;strain infection pressure
ip15 ;strain infection pressure
ip16 ;strain infection pressure
ip17 ;strain infection pressure
ip18 ;strain infection pressure
ip19 ;strain infection pressure
ip20 ;strain infection pressure
ipMin ;strain infection pressure
ipMax ;strain infection pressure
in1 ;number of infected per strain
in2 ;number of infected per strain
in3 ;number of infected per strain
in4 ;number of infected per strain
in5 ;number of infected per strain
in6 ;number of infected per strain
in7 ;number of infected per strain
in8 ;number of infected per strain
in9 ;number of infected per strain
in10 ;number of infected per strain
in11 ;number of infected per strain
in12 ;number of infected per strain
in13 ;number of infected per strain
in14 ;number of infected per strain
in15 ;number of infected per strain
in16 ;number of infected per strain
in17 ;number of infected per strain
in18 ;number of infected per strain
in19 ;number of infected per strain
in20 ;number of infected per strain
inMin ;number of infected per strain
inMax ;number of infected per strain
infPressList ;list of infection pressures
virToGetList ;list of transmissible strains
infectionList ;list of infections
initialOutbreakCell ;starting cell for infection
]
extensions
[
profiler
palette
]
;============================================================================================================================================ ;;
; SETUP + GO PROCEDURES
;============================================================================================================================================
to Setup
ca
reset-ticks
reset-timer
set rep 150
set week_overlap 0
Init_Parameters
Init_Landscape
Init_Population
set o_list []
end
to debug
Setup ;; set up the model
profiler:start ;; start profiling
repeat 200 [ Go ] ;; run something you want to measure
profiler:stop ;; stop profiling
print profiler:report ;; view the results
profiler:reset ;; clear the data
end
to Go
ifelse ticks mod 52 = 0 [ set week 1 ] [ set week week + 1 ]
if ticks = WeekRelease - 1 [ Disease_Release ] ;; - 1 to be synchronous*
if ticks >= WeekRelease - 1 [
Disease_Transmission
infectIndividuals
] ;; - 1 to be synchronous*
Movement_Roaming
if week = 17 [ Movement_Dispersal-Males ]
if week = 29 [ Movement_Dispersal-Females ]
Host_Reproduction
Host_Death
Host_Ageing
if ticks >= WeekRelease - 1 [ Disease_Transition ]
dyn
Update
check_floaters
r_move
resetdyn
testcounter
infectionCheck
tick
end
;============================================================================================================================================
;; INITIALIZATION PROCEDURES
;============================================================================================================================================
to Init_Parameters
set testCounterAlltime 0
if seed-setup = "ON" [ random-seed seed ]
if seed-setup = "BS" [ random-seed behaviorspace-run-number mod rep ]
set transmissionFailures 0
set warningCounter 0
set MaxAge Longevity * 52
set week 0
set WeekRelease ((YearRelease - 1) * 52) + release_week + 1 ; YearRelase = 6 -> "during the sixth year" -> reduce number to year 5; + 1 to be between week 1 and 52
set InfDist 0
set MaxDist 0
set sumOfInfectionEvents 0
set sumOfEvolutionEvents 0
if uniform_breeding = FALSE
[
set ReproList [ 0.06 ;; January
0.16 ;; February
0.39 ;; March
0.73 ;; April
0.8 ;; May
0.88 ;; June
0.94 ;; July
0.97 ;; August
1.0 ;; September
0.0 ;; October
0.0 ;; November
0.0 ] ;; December
]
if uniform_breeding = TRUE
[
set ReproList [0.08333333 ;; January
0.1666667 ;; February
0.25 ;; March
0.3333333 ;; April
0.4166667 ;; May
0.5 ;; June
0.5833333 ;; July
0.6666667 ;; August
0.75 ;; September
0.8333333 ;; October
0.9166667 ;; November
1 ] ;; December
]
;; INPUT DATA
file-open "RadiusAll.txt"
set NmaxList []
while [ not file-at-end? ] [ set NmaxList lput file-read NmaxList ]
file-close
;; OUTPUT
set InfStructList []
set InfTransStructList []
set InfLethStructList []
set CurrInfPeriodList []
set LethPeriodList []
set InfPeriodList []
set strainList []
if experimental_rednoise = true
[
file-open "ered_noise.txt"
set rednoise_list []
while [ not file-at-end? ] [ set rednoise_list lput file-read rednoise_list ]
file-close
]
set BetaW_Middle BetaWithin
set BetaB_Middle BetaWithin / 10
set survivalTimeList ;;for non fixed survival times
[
16
16
8
4
2
1
0
-1
-2
-4
-8
-16
-32
]
;;; Fixed survival times selection
set fixedExtTimesList
[
1 ;strain > 10
2 ;strain >8 <10
2 ;strain +5 >6 <8
3;strain +3 >4 <6
3;strain +1 >2 <4
6 ;strain -1 >0 <2
8 ;strain 0
9 ;strain <0 <-2
10 ;strain -5 <-2 <-4
11;strain -7 <-4 <-6
11 ;strain -9 <-6 <-8
13 ;strain -10 <-8 <-10
14 ;strain -10 <= -10
]
if transListSelect = true
[
set transList
[
0.04
0.05
0.06
0.07
0.08
0.09
0.12
0.14
0.18
0.20
0.20
0.20
0.20
]
]
if transListSelect = false
[
set transList
[
0
]
]
set meanStrainOutput 0
end
to Init_Landscape
;; LANDSCAPE ALGORITHM 1 (homogeneous habitat)
if Landscape = "Generator-Homogeneous" [ ask patches [ set Quality MeanQuality ] ]
;; LANDSCAPE ALGORITHM 2 (random heterogeneous habitat)
if Landscape = "Generator-Random"
[
ask patches with [pycor = min-pycor] [ set Quality MeanQuality ]
ask patches with [pycor = max-pycor] [ set Quality MeanQuality ]
ask patches with [pycor != min-pycor OR pycor != max-pycor]
[
ifelse Style = "discrete" [ set Quality random (MeanQuality * 2 + 1) ]
[ set Quality random-float MeanQuality * 2 ]
set qmw MeanQuality
]
]
;; LANDSCAPE ALGORITHM 3 (import file)
if Landscape = "File-Import-Path"
[
let x 0
let y 0
;; file import
ifelse seed-setup = "BS"
[
file-open (word "nlms/" Filename "_" (behaviorspace-run-number mod rep + 1) ".txt")
][
file-open (word "nlms/" Filename ".txt")
]
while [ not file-at-end? ]
[
while [ y < max-pycor + 1 ]
[
set x 0
while [ x < max-pxcor + 1 ]
[
let next-value file-read ;; iterate over file entries seperated by white-space
ask patch x y [ set Quality next-value ]
set x x + 1
]
set y y + 1
] ]
file-close
]
if Landscape = "File-Import-User"
[
let x 0
let y 0
;; file import
file-open user-file
while [ not file-at-end? ]
[
while [ y < max-pycor + 1 ]
[
set x 0
while [ x < max-pxcor + 1 ]
[
let next-value file-read ;; iterate over file entries seperated by white-space
ask patch x y [ set Quality next-value ]
set x x + 1
]
set y y + 1
] ]
file-close
]
ask patches with [pycor = min-pycor] [ set Quality MeanQuality ]
ask patches with [pycor = max-pycor] [ set Quality MeanQuality ]
if Landscape = "File-Import-Path" OR Landscape = "File-Import-User"
[
let QualityFactor (MeanQuality) / mean [Quality] of patches with [pycor != min-pycor AND pycor != max-pycor]
ask patches with [pycor != min-pycor AND pycor != max-pycor]
[
set Quality Quality * QualityFactor
if Style = "discrete" [ set Quality floor Quality ]
] ]
let x 0
let y 0
let patch_id 0
while [ y < max-pycor + 1 ]
[
set x 0
while [ x < max-pxcor + 1 ]
[
ask patch x y
[
if patch_id = 0
[
set id patch_id
set patch_id patch_id + 1
]
ifelse any? neighbors with [precision quality 2 = [precision quality 2] of myself AND id > 0]
[
let min_id min [id] of neighbors with [precision quality 2 = [precision quality 2] of myself AND id > 0]
set id min_id
ask neighbors with [precision quality 2 = [precision quality 2] of myself AND id > min_id] [ set id min_id ]
]
[
set id patch_id set patch_id patch_id + 1
] ]
set x x + 1
]
set y y + 1
]
ask max-one-of patches [id][set max_id id]
set Habitat patches with [Quality > 0]
set Matrix patches with [Quality <= 0]
ask Matrix [ set Quality 0 ]
let Qual-MW mean [Quality] of patches
ask Habitat
[
set Capacity (Quality * (20 / Qual-MW)) ; Quality * (mean number of 20 boars per cell / mean Quality) = 4.4445 boars per quality unit
set NoBoars count turtles-here
set NoRepro (count turtles-here with [is_female = 1 AND is_mother = 0 AND (AgeGroup = "Adult" OR AgeGroup = "Subdult")])
set DispCells Habitat in-radius DispDist
set Qual_around sum [Quality] of neighbors
set is_habitat 1
set qmw Qual-MW
set tmpToInfectHere 0
set InfPress 0
set InfPressLowVir 0
set InfPressHighVir 0
set NoInfectedLowVir 0
set NoInfectedHighVir 0
set NoInfectedAdj 0
]
ask Matrix [ set Capacity 0 ]
ask patches [
set infection_output_counter 0
set infPressList []
set virToGetList []
set infectionList []
set initialOutbreakCell false
set pcolor scale-color grey Quality 0 12
]
end
to Init_Population
crt (Herd% / 100 * count Habitat)
[
set Age 0
set DemStat "dsStart"
set EpiStat "esSusc"
set is_shedding 0
set is_breeder 0
set is_mother 0
set float_counter 0
set hasActiveStrain false
set initialOutbreak false
set transientCheck false
set markedForInfection false
set strainVirToGet 0
set counterGotInfected false
set strain 999
]
ask turtles [ ht ]
while [any? turtles with [DemStat = "dsStart"]]
[
ask turtles with [HerdID = 0]
[
move-to one-of Habitat with [is_occupied = 0]
set currHerdID currHerdID + 1
set HerdID currHerdID
set DemStat "dsResident"
let offspring (ReleaseFactor * Quality - 1)
hatch offspring
if random-float 1 < (offspring - floor(offspring)) [ hatch 1 ]
set is_occupied 1 ;patches-own
] ]
while [any? turtles with [Age = 0]]
[
ask turtles with [Age = 0]
[
ifelse random-float 1 <= ProbFem [ set is_female 1 ] [ set is_female 0 ]
let RandomNo random-float 1
; generate variation in age of start population
let Var round random-normal 0 (AgeBlur / 2)
if Var <= AgeBlur AND Var >= (- AgeBlur)
[
;; intial age distribution based on Kramer-Schadt et al. 2009
if RandomNo <= 0.38 [set Age 52 + Var]
if RandomNo > 0.38 AND RandomNo <= 0.62 [set Age 104 + Var]
if RandomNo > 0.62 AND RandomNo <= 0.77 [set Age 156 + Var]
if RandomNo > 0.77 AND RandomNo <= 0.86 [set Age 208 + Var]
if RandomNo > 0.86 AND RandomNo <= 0.92 [set Age 260 + Var]
if RandomNo > 0.92 AND RandomNo <= 0.95 [set Age 312 + Var]
if RandomNo > 0.95 AND RandomNo <= 0.97 [set Age 364 + Var]
if RandomNo > 0.97 AND RandomNo <= 0.98 [set Age 416 + Var]
if RandomNo > 0.98 AND RandomNo <= 0.99 [set Age 468 + Var]
if RandomNo > 0.99 AND RandomNo <= 1 [set Age 520 + Var]
]
;; age classes males
if Age <= 21 AND is_female = 0 [ set AgeGroup "Piglet" ]
if Age > 21 AND Age <= 104 AND is_female = 0 [ set AgeGroup "Subadult" ]
if Age > 104 AND is_female = 0
[
set AgeGroup "Adult"
set DemStat "dsDispM_adult"
]
;; age classes females
if Age <= 34 AND is_female = 1 [ set AgeGroup "Piglet" ]
if Age > 34 AND Age <= 52 AND is_female = 1 [ set AgeGroup "Subadult" ]
if Age > 52 AND is_female = 1 [ set AgeGroup "Adult" ]
] ]
;; OUTPUT
set PopStructList []
ask turtles
[
set PopStructList fput Age PopStructList
set NoGroup count turtles-here
]
set PopStructList map [ ?1 -> ?1 / 52 ] PopStructList
end
to Disease_Release
infectionCheck
ask patch 12 25
[
set initialOutbreakCell true
ask n-of 3 neighbors [set initialOutbreakCell true]
]
ask patches with [initialOutbreakCell = true]
[
set InfX pxcor
set InfY pycor
set is_infectious 1
set is_infected 1
set outbreak_group count turtles-here
set outbreak_roaming count turtles-here with [ DemStat = "dsDispM_adult" ]
set outbreak_dens5 count turtles in-radius 1.5
set outbreak_dens12 count turtles in-radius 12
;;equal outbreak of all strains
let susHere count turtles-here
let thrd susHere ;/ 3
if Roaming != "OFF"
[
let tmpMoThrd outbreak_roaming / 3
ask at-most-n-of thrd turtles-here with [hasActiveStrain = false AND DemStat = "dsDispM_adult"]
[
set initialOutbreak true
set strainVirToGet ((random 5) + 1) + 7
Disease_Infection
]
ask at-most-n-of thrd turtles-here with [hasActiveStrain = false AND DemStat = "dsDispM_adult"]
[
set initialOutbreak true
set strainVirToGet ((random 2) + 1) + 5
Disease_Infection
]
ask at-most-n-of thrd turtles-here with [hasActiveStrain = false AND DemStat = "dsDispM_adult"]
[
set initialOutbreak true
set strainVirToGet ((random 5) + 1)
Disease_Infection
]
]
ask at-most-n-of thrd turtles-here with [hasActiveStrain = false]
[
set initialOutbreak true
set strainVirToGet 5
Disease_Infection
]
testcounter
]
end
to Disease_Transmission
set NewLeth 0
set NewTrans 0
;; update infection status of cells
ask Habitat [ set is_infectious 0 ]
ask Habitat with [any? turtles-here with [is_shedding = 1]]
[
set is_infectious 1
set is_infected 1
]
ask Habitat
[
ifelse Roaming = "OFF"
[
set AllSus count turtles-here with [EpiStat = "esSusc"]
set inMin count turtles-here with [is_shedding = 1 AND strain <= -10 AND hasActiveStrain = true]
set in5 count turtles-here with [is_shedding = 1 AND strain <= -8 AND strain > -10 AND hasActiveStrain = true]
set in6 count turtles-here with [is_shedding = 1 AND strain <= -6 AND strain > -8 AND hasActiveStrain = true]
set in7 count turtles-here with [is_shedding = 1 AND strain <= -4 AND strain > -6 AND hasActiveStrain = true]
set in8 count turtles-here with [is_shedding = 1 AND strain <= -2 AND strain > -4 AND hasActiveStrain = true]
set in9 count turtles-here with [is_shedding = 1 AND strain < 0 AND strain > -2 AND hasActiveStrain = true]
set in10 count turtles-here with [is_shedding = 1 AND strain = 0 AND hasActiveStrain = true]
set in11 count turtles-here with [is_shedding = 1 AND strain > 0 AND strain <= 2 AND hasActiveStrain = true]
set in12 count turtles-here with [is_shedding = 1 AND strain > 2 AND strain <= 4 AND hasActiveStrain = true]
set in13 count turtles-here with [is_shedding = 1 AND strain > 4 AND strain <= 6 AND hasActiveStrain = true]
set in14 count turtles-here with [is_shedding = 1 AND strain > 6 AND strain <= 8 AND hasActiveStrain = true]
set in15 count turtles-here with [is_shedding = 1 AND strain > 8 AND strain <= 10 AND hasActiveStrain = true]
set inMax count turtles-here with [is_shedding = 1 AND strain > 10 AND hasActiveStrain = true]
]
[;; roaming ON
set AllSus count turtles-here with [EpiStat = "esSusc"]
set inMin count turtles-here with [is_shedding = 1 AND strain <= -10 AND hasActiveStrain = true]
set in5 count turtles-here with [is_shedding = 1 AND strain <= -8 AND strain > -10 AND hasActiveStrain = true]
set in6 count turtles-here with [is_shedding = 1 AND strain <= -6 AND strain > -8 AND hasActiveStrain = true]
set in7 count turtles-here with [is_shedding = 1 AND strain <= -4 AND strain > -6 AND hasActiveStrain = true]
set in8 count turtles-here with [is_shedding = 1 AND strain <= -2 AND strain > -4 AND hasActiveStrain = true]
set in9 count turtles-here with [is_shedding = 1 AND strain < 0 AND strain > -2 AND hasActiveStrain = true]
set in10 count turtles-here with [is_shedding = 1 AND strain = 0 AND hasActiveStrain = true]
set in11 count turtles-here with [is_shedding = 1 AND strain > 0 AND strain <= 2 AND hasActiveStrain = true]
set in12 count turtles-here with [is_shedding = 1 AND strain > 2 AND strain <= 4 AND hasActiveStrain = true]
set in13 count turtles-here with [is_shedding = 1 AND strain > 4 AND strain <= 6 AND hasActiveStrain = true]
set in14 count turtles-here with [is_shedding = 1 AND strain > 6 AND strain <= 8 AND hasActiveStrain = true]
set in15 count turtles-here with [is_shedding = 1 AND strain > 8 AND strain <= 10 AND hasActiveStrain = true]
set inMax count turtles-here with [is_shedding = 1 AND strain > 10 AND hasActiveStrain = true]
]
]
ask Habitat
[
ifelse Roaming = "OFF"
[
set infectionList []
set infPressList []
set virToGetList []
set ip10 (1 - (1 - BetaW_Middle) ^ in10 * (1 - ( BetaB_Middle)) ^ sum [in10] of neighbors)
set ip9 (1 - (1 - (BetaW_Middle - ( 0))) ^ in9 * (1 - (BetaB_Middle - (0 ) )) ^ sum [in9] of neighbors) ;;; 5% difference between each "brackets" beta
set ip8 (1 - (1 - (BetaW_Middle - (0 ))) ^ in8 * (1 - (BetaB_Middle - (0 ) )) ^ sum [in8] of neighbors)
set ip7 (1 - (1 - (BetaW_Middle - ( 0))) ^ in7 * (1 - (BetaB_Middle - (0 ) )) ^ sum [in7] of neighbors)
set ip6 (1 - (1 - (BetaW_Middle - ( 0))) ^ in6 * (1 - (BetaB_Middle - (0 ) )) ^ sum [in6] of neighbors)
set ip5 (1 - (1 - (BetaW_Middle - ( 0))) ^ in5 * (1 - (BetaB_Middle - ( 0) )) ^ sum [in5] of neighbors)
set ipMin (1 - (1 - (BetaW_Middle - ( 0))) ^ inMin * (1 - (BetaB_Middle - ( 0) )) ^ sum [inMin] of neighbors)
set ip11 (1 - (1 - (BetaW_Middle + ( 0))) ^ in11 * (1 - (BetaB_Middle + (0 ) )) ^ sum [in11] of neighbors)
set ip12 (1 - (1 - (BetaW_Middle + ( 0))) ^ in12 * (1 - (BetaB_Middle + (0 ) )) ^ sum [in12] of neighbors)
set ip13 (1 - (1 - (BetaW_Middle + ( 0))) ^ in13 * (1 - (BetaB_Middle + ( 0) )) ^ sum [in13] of neighbors)
set ip14 (1 - (1 - (BetaW_Middle + ( 0))) ^ in14 * (1 - (BetaB_Middle + ( 0) )) ^ sum [in14] of neighbors)
set ip15 (1 - (1 - (BetaW_Middle + ( 0))) ^ in15 * (1 - (BetaB_Middle + ( 0) )) ^ sum [in15] of neighbors)
set ipMax (1 - (1 - (BetaW_Middle + ( 0))) ^ inMax * (1 - (BetaB_Middle + ( 0) )) ^ sum [inMax] of neighbors)
if ipMin != 0
[
set ipMin ipMin + item 0 transList
]
if ip5 != 0
[
set ip5 ip5 + item 1 transList
]
if ip6 != 0
[
set ip6 ip6 + item 2 transList
]
if ip7 != 0
[
set ip7 ip7 + item 3 transList
]
if ip8 != 0
[
set ip8 ip8 + item 4 transList
]
if ip9 != 0
[
set ip9 ip9 + item 5 transList
]
if ip10 != 0
[
set ip10 ip10 + item 6 transList
]
if ip11 != 0
[
set ip11 ip11 + item 7 transList
]
if ip11 <= 0 [set ip11 0.0001]
if ip12 != 0
[
set ip12 ip12 + item 8 transList
]
if ip13 != 0
[
set ip13 ip13 + item 9 transList
]
if ip14 != 0
[
set ip14 ip14 + item 10 transList
]
if ip15 != 0
[
set ip15 ip15 + item 11 transList
]
if ipMax != 0
[
set ipMax ipMax + item 12 transList
]
set infPressList fput ipMin infPressList
set virToGetList fput 1 virToGetList
set infPressList fput ip5 infPressList
set virToGetList fput 2 virToGetList
set infPressList fput ip6 infPressList
set virToGetList fput 3 virToGetList
set infPressList fput ip7 infPressList
set virToGetList fput 4 virToGetList
set infPressList fput ip8 infPressList
set virToGetList fput 5 virToGetList
set infPressList fput ip9 infPressList
set virToGetList fput 6 virToGetList
set infPressList fput ip10 infPressList
set virToGetList fput 7 virToGetList
set infPressList fput ip11 infPressList
set virToGetList fput 8 virToGetList
set infPressList fput ip12 infPressList
set virToGetList fput 9 virToGetList
set infPressList fput ip13 infPressList
set virToGetList fput 10 virToGetList
set infPressList fput ip14 infPressList
set virToGetList fput 11 virToGetList
set infPressList fput ip15 infPressList
set virToGetList fput 12 virToGetList
set infPressList fput ipMax infPressList
set virToGetList fput 13 virToGetList
set infectionList lput (list infPressList virToGetList) infectionList
] ;c: all individuals are equal -> group's cell and neighbors
[ ;Roaming ON
set infectionList []
set infPressList []
set virToGetList []
set ip10 (1 - (1 - BetaW_Middle) ^ in10 )
set ip9 (1 - (1 - (BetaW_Middle - (BetaW_Middle ))) ^ in9) ;;; 5% difference between each "brackets" beta
set ip8 (1 - (1 - (BetaW_Middle - (BetaW_Middle ))) ^ in8)
set ip7 (1 - (1 - (BetaW_Middle - (BetaW_Middle ))) ^ in7)
set ip6 (1 - (1 - (BetaW_Middle - (BetaW_Middle ))) ^ in6)
set ip5 (1 - (1 - (BetaW_Middle - (BetaW_Middle ))) ^ in5)
set ipMin (1 - (1 - (BetaW_Middle - (BetaW_Middle ))) ^ inMin)
set ip11 (1 - (1 - (BetaW_Middle + (BetaW_Middle ))) ^ in11)
set ip12 (1 - (1 - (BetaW_Middle + (BetaW_Middle ))) ^ in12)
set ip13 (1 - (1 - (BetaW_Middle + (BetaW_Middle ))) ^ in13)
set ip14 (1 - (1 - (BetaW_Middle + (BetaW_Middle ))) ^ in14)
set ip15 (1 - (1 - (BetaW_Middle + (BetaW_Middle ))) ^ in15)
set ipMax (1 - (1 - (BetaW_Middle + (BetaW_Middle ))) ^ inMax)
if ipMin != 0
[
set ipMin ipMin - (transmission_factor + 0.066)
if ipMin <= 0 [set ipMin 0.0001]
]
set ip10 ip10
if ip9 != 0
[
set ip9 ip9 - (transmission_factor + 0.011)
if ip9 <= 0 [set ip9 0.0001]
]
if ip8 != 0
[
set ip8 ip8 - (transmission_factor + 0.022)
if ip8 <= 0 [set ip8 0.0001]
]
if ip7 != 0