The observation design concept is about what you (the scientist) want to observe about your model in order to learn something relevant to your research question.
Some ways to observe your model include:
set label elevationor
set plabel count turtles-here)
set color blueor
set pcolor green)
set shape "butterfly",
set size 4)
Download butterfly model
and elevation file
save them in the same folder, and open the butterfly model in NetLogo.
Go to the code tab and look at
move and change
ifelse random-float 1 < q [ move-to max-one-of neighbors [elevation] ; Move uphill ] [ move-to one-of neighbors ; Otherwise move randomly ]
ifelse random-float 1 < q [ move-to max-one-of neighbors [elevation] ; Move uphill set color red ] [ move-to one-of neighbors ; Otherwise move randomly set color blue ]
to update-display color-patches ifelse show-butterflies? [ ask turtles [show-turtle]] [ ask turtles [hide-turtle]] ifelse show-labels? [ ask turtles [set label elevation]] [ ask turtles [set label ""]] end
num-butterfliesto 0 or 5, press
setup, and run the model
labelto a variable:
update-display, and call
to color-patches ifelse patch-coloring = "elevation" [ let max-elevation max [elevation] of patches let min-elevation min [elevation] of patches ask patches [ set pcolor scale-color green elevation min-elevation max-elevation] ] [ let max-turtles max [count turtles-here] of patches let min-turtles 0 ask patches [ set pcolor scale-color cyan (count turtles-here) min-turtles max-turtles] ] end
show-labels? and set
num-butterflies to 50
Setup and run the model
Clear the paths, turn
show-butterflies? off, and press
Write a new reporter:
to-report fraction-crowded let crowd-count sum [count turtles-here] of patches with [count turtles-here >= 4] report crowd-count / num-butterflies end
Add 3 monitors to the interface:
Mean elevation gets reporter
mean [elevation] of turtles
Mean turtles gets reporter
mean [count turtles-here] of patches with [any? turtles-here]
Fraction crowded gets reporter
num-butterfliesto 10 and setup.
inspect turtle 5at the observer line.
watch turtle 3at the observer line.
histogram [count turtles-here] of patches
plot 100 * fraction-crowded
plot mean [elevation] of turtles
to goor in a submodel called from
See Shapes Editor in the NetLogo manual for details
ask turtles [set shape "butterfly"]
First open file (generally, check whether a file exists, and delete it). It’s also a good idea to write a header with the names of the columns.
if (file-exists? "my_test_output.csv") [ carefully [ file-delete "my_test_output.csv" ] [ print error-message ] ] file-open "my_test_output.csv" file-type "id," file-type "tick," file-print "elevation"
Then at each tick, you could write data:
file-open "my_test_output.csv" ask turtles [ file-type word who "," file-type word ticks "," file-print elevation ]
When the model stops, you need to close the file.
to go ... if ticks > 500 [ file-close-all stop ]
You can have multiple files open at once. Switch between them using
file-open "turtle_output.csv" ask turtles [ file-type word who "," file-type word ticks "," file-print elevation ] file-open "summary_output.csv" file-type word ticks "," file-type word (mean [elevation] of turtles) "," file-print 100 * fraction-crowded
If you have plots, you can output the data from the plot to a file using
export-plot "Fraction crowded" "frac_crowded.csv"
You can export the current state of your entire model (all turtles, patches, their turtles-own, patches-own variables, etc.) using
You can also export plots, world, etc. from the “File/Export” menu.
You can download the full model with different observations
we have been discussing at