Covid19
Model was written in NetLogo 6.1.1
•
Viewed 184 times
•
Downloaded 16 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
;turtles-own [age withmask withglass status Susceptibility Treatmenttime Departure Destination movesize infecteddays treatmentdays infectedpros lockdown] breed [airplanes airplane] breed [peoples people] breed [halos halo] peoples-own[age withmask withglass status Susceptibility Departure Destination movesize infecteddays treatmentdays infectedpros lockdown inplane inairport lockdownday] ;movesize: the turtles move distance in every step ;infecteddays: how long have be infected infected people can be health ;treatmentdays: after treatmentdays ;infectedpros: the possibility of infection ;lockdown:0 not lockdown,1 lockdown ;inplane: 0 one the plane, 1 not on the plane ;inairport:"0" not, "A" Acountry airport,"B" Bcountry airport ;status: 0 healthy(green); 2 infected(red); 4 lurking(yellow) airplanes-own[flying Departure Destination speed] ;flying:1 flying; 0 at the airport ;Departure:country ;Destination:country ;speed: how many steps can more per tick globals[x Apolicy Bpolicy Amaskrate Bmaskrate Apopulation Bpopulation Acenterx Bcenterx Acolor Bcolor infectdis ALurkingrate findingdays recoverdays withglassrate enableflight lockdowndays filename] ;Apopulation: the population of country A ;Bpopulation: the population of country B ;Acolor: the background color of country A ;Bcolor: the background color of country B ;infectdis: the maximum distance can be infected by others. ;ALurkingrate: at the beginning the lurking people rate of country A. ;findingdays: after findingdays people's status turns from lurking to infected status. ;recoverdays: after recoverdays, the infected people can be recovered ;withglassrate: the rate of people woth glass ;Acenterx Bcenterx: the x of country A and country B ;enableflight: 1, use airplane; 0 ,don't use airplane ;Apolicy,Bpolicy:0 no lockdown when fly to other country;1 lockdown when fly to other country ;lockdowndays: how many days people have to be lockdowned when take the airplain or infected to make-halo ;; runner procedure ;; when you use HATCH, the new turtle inherits the ;; characteristics of the parent. so the halo will ;; be the same color as the turtle it encircles (unless ;; you add code to change it hatch-halos 1 [ set size infectdis ;; Use an RGB color to make halo three fourths transparent set color lput 64 extract-rgb color ;; set thickness of halo to half a patch __set-line-thickness 0.5 ;; We create an invisible directed link from the runner ;; to the halo. Using tie means that whenever the ;; runner moves, the halo moves with it. create-link-from myself [ tie hide-link ] ] end to makelockdown ;make people lockdown set lockdown 1 set lockdownday 0 end to addlockdownday set lockdownday lockdownday + 1 end to makefree;make people unlockdown set lockdown 0 set lockdownday 0 end to del-halos if count link-neighbors > 0 [ ask one-of link-neighbors [ die ] ] end to setup clear-all set-default-shape halos "circle 2" set Acolor black set Bcolor black set Apopulation $Apopulation set Bpopulation $Bpopulation set infectdis $infectdis set ALurkingrate $ALurkingrate / 100 ;initial infected rate set findingdays $findingdays set recoverdays $recoverdays set Apolicy $Apolicy set Bpolicy $Bpolicy set Amaskrate $Amaskrate set Bmaskrate $Bmaskrate set withglassrate $withglassrate set Acenterx min-pxcor / 2 set Bcenterx max-pxcor / 2 set lockdowndays $lockdowndays enablefly setup-patches draw-walls setup-airplanes setup-turtles reset-ticks end to setup-airplanes create-airplanes 1 ask airplanes [ ask airplane 0 [ setxy Acenterx 0 set Departure "A" set Destination "B" set color yellow ] ; ask airplane 1 [ ; setxy Bcenterx 0 ; set Departure "B" ; set Destination "A" ; set color white ; ] set shape "airplane" set flying 0 set size 3 ; set label who set speed 8 facexy 0 0 ] end to enablefly ifelse $enableflight = True [set enableflight 1] [set enableflight 0 ] end to fly ;the airplanes fly to the other airport ask airplanes [ ifelse Departure = "A" [ if enableflight = 1 [ flyAB ] ][ if enableflight = 1 [ flyBA ] ] ] end to checkifinairport ask peoples [ ; if (pcolor = "red") and (xcor < 0)[; in A country airport set inairport "0" if (xcor > -19) and (xcor < -13) and (ycor > -3) and (ycor < 3)[ set inairport "A" ] if (xcor > 13) and (xcor < 19) and (ycor > -3) and (ycor < 3)[; in B country airport set inairport "B" ] ; if (pcolor != "red") [; not in the airports ; set inairport "0" ; ] ] end to flyAB ; checkifinairport ask airplanes [ ifelse flying = 0 [ ; if not flying, start to flay if Departure = "A" [ if (count peoples with [(inairport = "A") and (status != "2") and (lockdown = 0)]) > 0 [ ask peoples with [(inairport = "A") and (status != "2")] [ set inplane "1" ] set label count peoples with [(inairport = "A") and (status != "2") and (lockdown = 0)] ] facexy Bcenterx 0 fd speed set flying 1 ask peoples with [(inplane = "1") and (Departure = "A") and (lockdown = 0)][ setxy [xcor] of airplane 0 [ycor] of airplane 0 ] ] ][ ; ifelse xcor >= Bcenterx [ ; arrived ; set flying 0 ; set Departure "B" ; set Destination "A" ; facexy Acenterx 0 ; setxy Bcenterx 0 ; ][ ;not arrived ifelse xcor + speed < Bcenterx [;flying fd speed ask peoples with [(inplane = "1") and (Departure = "A") and (lockdown = 0)][ setxy [xcor] of airplane 0 [ycor] of airplane 0 ] ][ ; arrived ; fd Bcenterx - speed set flying 0 set Departure "B" set Destination "A" facexy Acenterx 0 setxy Bcenterx 0 ask peoples with [(inplane = "1") and (Departure = "A") and (lockdown = 0)][ set inplane "0" set Departure "B" set Destination "A" ;setxy random movesize + [xcor] of airplane 0 random movesize + [ycor] of airplane 0 setxy 4 + [xcor] of airplane 0 4 + [ycor] of airplane 0 if Bpolicy = 1 [ makelockdown ] ] set label 0 setwithmask calinfectedpros ] ] ] end to flyBA ask airplanes [ ifelse flying = 0 [ ; if not flying, start to flay if Departure = "B" [ if (count peoples with [(inairport = "B") and (status != "2") and (lockdown = 0)]) > 0 [ ask peoples with [(inairport = "B") and (status != "2") and (lockdown = 0)] [ set inplane "1" ] set label count peoples with [(inairport = "B") and (status != "2") and (lockdown = 0)] ] facexy Acenterx 0 fd speed set flying 1 ask peoples with [(inplane = "1") and (Departure = "B") and (lockdown = 0)][ setxy [xcor] of airplane 0 [ycor] of airplane 0 ] ] ][ ; ifelse xcor <= Acenterx [ ; arrived ; set flying 0 ; set Departure "A" ; set Destination "B" ; setxy Acenterx 0 ; facexy Bcenterx 0 ; ][ ;not arrived ifelse xcor - Acenterx > speed [;flying fd speed ask peoples with [(inplane = "1") and (Departure = "B") and (lockdown = 0)][ setxy [xcor] of airplane 0 [ycor] of airplane 0 ] ][ ; arrived ;fd Acenterx + speed set flying 0 set Departure "A" set Destination "B" setxy Acenterx 0 facexy Bcenterx 0 ask peoples with [(inplane = "1") and (Departure = "B")][ set inplane "0" set Departure "A" set Destination "B" ; setxy random movesize + [xcor] of airplane 0 random movesize + [ycor] of airplane 0 setxy 4 + [xcor] of airplane 0 4 + [ycor] of airplane 0 if Apolicy = 1 [ makelockdown ] ] set label 0 setwithmask calinfectedpros ] ; ] ] ] end to exportreport set x "gr" set x word x withglassrate set x word x "am" set x word x Amaskrate set x word x "bm" set x word x Bmaskrate set x word x "bm" set x word x Bmaskrate set x word x "ms" set x word x $movesize set x word x "ef" set x word x enableflight set x word x "ld" set x word x lockdowndays set x word x "rd" set x word x recoverdays set x word x "lr" set x word x (ALurkingrate * 100) set x word x "ind" set x word x infectdis set x word x "bo" set x word x $bounce set x word x "Ap" set x word x Apolicy set x word x "Bp" set x word x Bpolicy set x word x "fd" set x word x findingdays set filename word user-directory x set filename word filename random 100 set filename word filename ".csv" print filename export-all-plots(filename) end to setup-patches ask patches [ ifelse pxcor > 0 [ set pcolor Bcolor ;in country B ][ set pcolor Acolor ;in country A ] draw-center ;drawn the airport ] end to setup-turtles setup-turtlesinA ;create turtles in country A setup-turtlesinB ;create turtles in country B ask peoples [ randomize ; checkifinairport ] End to setup-turtlesinA create-peoples Apopulation ask peoples [ if ( Departure != "A" ) and ( Departure != "B" ) [ setxy random-xcor random-ycor set age random 90 + 1 set withmask 0 set status random 4 set Susceptibility 0 ; set Treatmenttime 14 set Departure "A" set Destination "B" set infecteddays 0 set treatmentdays 0 set lockdown 0 set inplane 0 ifelse ALurkingrate * Apopulation > who [ set status 4 set color yellow make-halo ][ set status 0 set color green ] ;set energy 1 set shape "person" setwithglass setwithmask calinfectedpros ; set the infectedpros changeshape set size 1 set label who ;set color white ;randomize ] ] end to setwithmask ask peoples [ ifelse xcor < 0 [; in country A ifelse (random 100 > Amaskrate)[ set withmask 0 ][ set withmask 1 ] ][;in country B ifelse (random 100 > Bmaskrate)[ set withmask 0 ][ set withmask 1 ] ] ] end to changeshape ;make people's shape change ask peoples [ if (withmask = 0) and (withglass = 0) [ ; set shape "person" ] if (withmask = 1) and (withglass = 1) [ ; set shape "glassmask" ] if (withmask = 0) and (withglass = 1) [ ; set shape "glass" ] if (withmask = 1) and (withglass = 0) [ ; set shape "mask" ] ] end to setwithglass ask peoples [ ifelse (random 100 >= withglassrate)[ set withglass 0 ][ set withglass 1 ] ] end to calinfectedpros ask peoples [ set infectedpros age *( (1 - withmask ) * 0.5 + (1 - withglass ) * 0.3 + 0.2) / 100 ] end to setup-turtlesinB create-peoples Bpopulation ask peoples [ if ( Departure != "A" ) and ( Departure != "B" ) [ setxy random-xcor random-ycor set age random 90 + 1 set withmask 0 set status random 4 set Susceptibility 0 ; set Treatmenttime 14 set Departure "B" set Destination "A" set treatmentdays 0 set infecteddays 0 set status 0 set lockdown 0 set inplane 0 ;set energy 1 set shape "person" setwithglass setwithmask calinfectedpros ; set the infectedpros changeshape set size 1 set color green ; set label who ;randomize ] ] end to randomize if Departure = "A" [ setxy random min-pxcor random-ycor if pcolor = blue or pcolor = red ; if it's on the wall or airport... [ randomize ] ; ...try again ] if Departure = "B" [ setxy random max-pxcor random-ycor if pcolor = blue or pcolor = red ; if it's on the wall or airport... [ randomize ] ; ...try again ] end ; draws the boundaries (walls) of the "billiard table" to draw-walls ; draw left and right walls ask patches with [abs pxcor = 0 ] [ set pcolor blue ] ask patches with [abs pxcor = max-pxcor] [ set pcolor blue ] ; draw top and bottom walls ask patches with [abs pycor = max-pycor] [ set pcolor blue ] end to draw-center ask patches with [ ( abs pxcor > max-pxcor / 2 - 3 and abs pxcor < max-pxcor / 2 + 3 ) and ( pycor < 3 and pycor > -3 ) ] [ set pcolor red ] end to go move-peoples checkifinairport fly tick end to remove-peoples ask peoples [ ifelse status = 7 [ die ][ forward random size ] ] end to bounce ;; for people not across the border ; check: hitting the wall? if ($bounce = True)[; when next step can be across the border, change dirction if ((abs xcor ) - movesize < infectdis / 2 ) [ ;people can't move across the borader if ((Departure = "B") and (heading > 180) and (heading < 360 ) ) or ((Departure = "A") and (heading < 180) and (heading > 0)) [ set heading (- heading ) ] ] ] forward movesize end to infecteachothers ; infect others or be infected by others if count other peoples-here in-radius infectdis > 0 [ ;if there is any one near ask other peoples-here in-radius infectdis [ ifelse ([status] of myself = 0)[;self is healthy and can be infected if ((status = 4) and (lockdown = 0))[ if (100 * infectedpros * [infectedpros] of myself / age >= (random 9 + 1 ) / 10 )[ ; only if the infectedpros is not good,being infected if ( [status] of myself = 0 ) and ([inplane] of myself = inplane) [ ask myself [ turnlurking ] ] ] ] ][ if ([status] of myself = 4)[ ;self is a lurking people and can infect others if ((status = 0) and (lockdown = 0))[ if (100 * infectedpros * [infectedpros] of myself / [age] of myself >= (random 9 + 1 ) / 10 )[ ; only if the infectedpros is not good,infect the other people if ( status = 0 ) and ([inplane] of myself = inplane) [ turnlurking ] ] ] ] ] ] ] end to move-peoples ask peoples [ checkinfected; fisrtly if lurking people can change to infected poeple ifelse ( lockdown != 1 ) [ ;unlockdown people left random 360 set movesize random $movesize + 1 bounce infecteachothers ][ ;For lockdown people, cannot infect others addlockdownday if (lockdownday > lockdowndays) [ makefree ] ] if (status = 2 )[; for infected people set treatmentdays treatmentdays + 1 if ( treatmentdays > recoverdays ) [;the treatment process of infected people is over turnhealthy ] ] ] end to checkinfected; to check if lurking people can change to infected poeple, if yes, change their status if ( status = 4 ) and (infecteddays >= 0) [ set infecteddays infecteddays + 1]; for lurking people caculate the infected days if (status = 2) and (lockdown = 0)[ turnlurking ] ;if infected people not lockdown, he becomes a lurking one if ( infecteddays > findingdays ) ; from lurking to infected and lockdown them [ turninfected ] end to turnlurking ;healthy people becomes lurking people set status 4 set color yellow make-halo end to turninfected; lurking people becomes infected people set status 2 makelockdown set color red set infecteddays 0 del-halos end to turnhealthy ;the infected people become a healthy one set status 0 set treatmentdays 0 set infecteddays 0 set color green end to color-change ask turtles[ set color red ] end
There are 3 versions of this model.
This model does not have any ancestors.
This model does not have any descendants.