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

setup basic no-op model with globals

parent 38b863c0
No related branches found
No related tags found
1 merge request!3Building the Rabies model from ODD
Pipeline #15926 passed with stage
in 13 seconds
# Literate NetLogo
This is an example project to demonstrate Literate Programming to create [NetLogo](https://ccl.northwestern.edu/netlogo/) models from ODD+C protocols.
This is an example project to demonstrate Literate Programming to create [NetLogo](https://ccl.northwestern.edu/netlogo/) models from ODD+C protocols.
## Rabies model - ODD protocol
### Purpose
### Entities, state variables, and scales
Each patch has a disease state.
### Entities, state variables, and scales
```netlogo
;- State variables
patches-own [
state
]
```
### Process overview and scheduling
```netlogo
;- Disease states
globals [
EMPTY
S
I
R
]
```
```netlogo
;- file:Code.nls
; ==> Setup.
; ==> Go.
;- Setup disease states
set EMPTY 0
set S 1
set I 2
set R 3
```
### Process overview and scheduling
```netlogo
;- Go
to go
update-patches
tick
end
; ==> Update patches.
```
### Design concepts
......@@ -32,6 +55,9 @@ end
```netlogo
;- Setup
to setup
clear-all
; ==> Setup disease states.
update-patches
reset-ticks
end
```
......@@ -40,8 +66,35 @@ end
### Submodels
#### Visualization
```netlogo
;- Update patches
to update-patches
ask patches [
ifelse state = EMPTY [ set pcolor white ]
[ ifelse state = S [ set pcolor blue ]
[ ifelse state = I [ set pcolor red ]
[ set pcolor green ] ] ]
]
end
```
## Appendix
### Code
```netlogo
;- file:Code.nls
; ==> Disease states.
; ==> State variables.
; ==> Setup.
; ==> Go.
```
### NetLogo file
In the main `nlogo` file, we only "include" an `nls` file to allow for the reverse mode.
......
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