Skip to content
Snippets Groups Projects
Commit 4e8c2b29 authored by Martin Lange's avatar Martin Lange
Browse files

simple infection model, slider for beta

parent 31642fc0
No related branches found
No related tags found
1 merge request!3Building the Rabies model from ODD
Pipeline #15927 passed with stage
in 13 seconds
...@@ -14,6 +14,7 @@ Each patch has a disease state. ...@@ -14,6 +14,7 @@ Each patch has a disease state.
;- State variables ;- State variables
patches-own [ patches-own [
state state
infected-neighbours
] ]
``` ```
...@@ -41,10 +42,12 @@ set R 3 ...@@ -41,10 +42,12 @@ set R 3
```netlogo ```netlogo
;- Go ;- Go
to go to go
infect-patches
update-patches update-patches
tick tick
end end
; ==> Infection.
; ==> Update patches. ; ==> Update patches.
``` ```
...@@ -57,6 +60,14 @@ end ...@@ -57,6 +60,14 @@ end
to setup to setup
clear-all clear-all
; ==> Setup disease states. ; ==> Setup disease states.
ask patches [
set state S
]
ask one-of patches [
set state I
]
update-patches update-patches
reset-ticks reset-ticks
end end
...@@ -66,6 +77,37 @@ end ...@@ -66,6 +77,37 @@ end
### Submodels ### Submodels
#### Infection
```netlogo
;- Infection
to infect-patches
ask patches [
set infected-neighbours 0
]
ask patches with [ state = I ] [
ask neighbors [
set infected-neighbours infected-neighbours + 1
]
]
ask patches with [ state = S ] [
if random-float 1 < calc-infection-prob [
set state I
]
]
end
; ==> Infection probability.
```
```netlogo
;- Infection probability
to-report calc-infection-prob
report 1 - (1 - beta) ^ infected-neighbours
end
```
#### Visualization #### Visualization
```netlogo ```netlogo
......
__includes["Code.nls"] __includes["Code.nls"]
@#$#@#$#@ @#$#@#$#@
GRAPHICS-WINDOW GRAPHICS-WINDOW
220 230
10 10
733 743
524 524
-1 -1
-1 -1
...@@ -30,7 +30,7 @@ ticks ...@@ -30,7 +30,7 @@ ticks
BUTTON BUTTON
10 10
10 10
80 110
50 50
NIL NIL
setup setup
...@@ -45,9 +45,9 @@ NIL ...@@ -45,9 +45,9 @@ NIL
1 1
BUTTON BUTTON
90 115
10 10
160 215
50 50
NIL NIL
go go
...@@ -59,7 +59,22 @@ NIL ...@@ -59,7 +59,22 @@ NIL
NIL NIL
NIL NIL
NIL NIL
0
SLIDER
10
62
215
95
beta
beta
0
1 1
0.2
0.01
1
NIL
HORIZONTAL
@#$#@#$#@ @#$#@#$#@
## WHAT IS IT? ## WHAT IS IT?
...@@ -90,5 +105,5 @@ true ...@@ -90,5 +105,5 @@ true
Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 90 180
Line -7500403 true 150 150 210 180 Line -7500403 true 150 150 210 180
@#$#@#$#@ @#$#@#$#@
0 1
@#$#@#$#@ @#$#@#$#@
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment