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 # 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 ## Rabies model - ODD protocol
### Purpose ### 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 ```netlogo
;- file:Code.nls ;- Setup disease states
; ==> Setup. set EMPTY 0
; ==> Go. set S 1
set I 2
set R 3
``` ```
### Process overview and scheduling
```netlogo ```netlogo
;- Go ;- Go
to go to go
update-patches
tick tick
end end
; ==> Update patches.
``` ```
### Design concepts ### Design concepts
...@@ -32,6 +55,9 @@ end ...@@ -32,6 +55,9 @@ end
```netlogo ```netlogo
;- Setup ;- Setup
to setup to setup
clear-all
; ==> Setup disease states.
update-patches
reset-ticks reset-ticks
end end
``` ```
...@@ -40,8 +66,35 @@ end ...@@ -40,8 +66,35 @@ end
### Submodels ### 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 ## Appendix
### Code
```netlogo
;- file:Code.nls
; ==> Disease states.
; ==> State variables.
; ==> Setup.
; ==> Go.
```
### NetLogo file ### NetLogo file
In the main `nlogo` file, we only "include" an `nls` file to allow for the reverse mode. 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