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.
;- State variables
patches-own [
state
infected-neighbours
]
```
......@@ -41,10 +42,12 @@ set R 3
```netlogo
;- Go
to go
infect-patches
update-patches
tick
end
; ==> Infection.
; ==> Update patches.
```
......@@ -57,6 +60,14 @@ end
to setup
clear-all
; ==> Setup disease states.
ask patches [
set state S
]
ask one-of patches [
set state I
]
update-patches
reset-ticks
end
......@@ -66,6 +77,37 @@ end
### 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
```netlogo
......
__includes["Code.nls"]
@#$#@#$#@
GRAPHICS-WINDOW
220
230
10
733
743
524
-1
-1
......@@ -30,7 +30,7 @@ ticks
BUTTON
10
10
80
110
50
NIL
setup
......@@ -45,9 +45,9 @@ NIL
1
BUTTON
90
115
10
160
215
50
NIL
go
......@@ -59,7 +59,22 @@ NIL
NIL
NIL
NIL
0
SLIDER
10
62
215
95
beta
beta
0
1
0.2
0.01
1
NIL
HORIZONTAL
@#$#@#$#@
## WHAT IS IT?
......@@ -90,5 +105,5 @@ true
Line -7500403 true 150 150 90 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