AnimDens NetLogo
Model was written in NetLogo
6.0
•
Viewed 845 times
•
Downloaded 100 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
;AnimDens Model ;Original model implemented in R by Christine Ward-Paige et al. ;Adapted and implemented in NetLogo by Miguel Pessanha Pais ;FOR MORE INFORMATION, LOOK IN THE INFO TAB ;Global variables not represented in the main screen globals[ actual.area trans.viewangle stat.viewangle rov.viewangle transect.mean.speed roving.mean.speed transect.area stationary.area ] ;Agent types breed [animals animal] breed [transsurveyors transsurveyor] ;belt transect surveyor breed [statsurveyors statsurveyor] ;stationary point count surveyor breed [rovsurveyors rovsurveyor] ;roving surveyor ; roving surveyors can't calculate densities accurately, yet they can estimate speceis richness and frequency of occurence. ;Agent variables animals-own [ speed species ] transsurveyors-own [ counted.animals speed memory t.bias ] statsurveyors-own [ counted.animals memory s.bias ] rovsurveyors-own [ counted.animals speed memory ] ;Setup and go procedures to setup ca stop-inspecting-dead-agents ; clears surveyor detail windows from previous simulation runs resize-world 0 (area.width - 1) 0 (area.length - 1) set-patch-size (100 / area.length) * 10 ask patches with [pycor mod 2 = 0 and pxcor mod 2 = 0] [set pcolor environment.color] ; create background grid ask patches with [pycor mod 2 = 1 and pxcor mod 2 = 1] [set pcolor environment.color] ask patches with [pcolor = black] [set pcolor environment.color + 1] set actual.area world-height * world-width set trans.viewangle 180 set stat.viewangle 160 set rov.viewangle 160 set transect.mean.speed (transect.speed / 60) ; these 4 lines just convert interface speeds (in m/min) to m/s set roving.mean.speed (roving.speed / 60) ; on the original model, the final part of the sampled area of the transect is assumed to be a rectangle (transect.width x visibility.length) set transect.area transect.width * (transect.mean.speed * survey.time) + transect.width * visibility.length set stationary.area pi * stationary.radius ^ 2 ; if animal density is set to some number, then use that to calculate the number of animals to deploy. Otherwise, just use the numb.animals. ifelse animal.density != 0 [set numb.animals ceiling actual.area * animal.density] [set animal.density numb.animals / actual.area] create-animals numb.animals [ setxy random-xcor random-ycor set color animal.color set shape animal.shape set size 1 set species "Sp1" ; There is only one species, but this is what surveyors register and count set speed animal.mean.speed ] if transect? [ ;transect surveyor setup create-transsurveyors 1 [ set heading 0 set shape surveyor.shape set color blue set size 2 setxy (world-width / 2) (world-height / 2) if show.paths? [pen-down] ;this shows the path of the surveyor set speed transect.mean.speed set counted.animals [] ; sets counted.animals as an empty list ] ] if stationary? [ ;stationary setup create-statsurveyors 1 [ set heading 0 set shape surveyor.shape set color red set size 2 setxy (world-width / 2) (world-height / 2) set counted.animals [] ; sets counted.animals as an empty list ] ] if roving? [ ;roving setup create-rovsurveyors 1 [ set heading 0 set shape surveyor.shape set color green set size 2 setxy (world-width / 2) (world-height / 2) if show.paths? [pen-down] ;this shows the path of the surveyor set speed roving.mean.speed set counted.animals [] ; sets counted.animals as an empty list ] ] ask transsurveyors [ ; empty the memory of all surveyors set memory [] ] ask statsurveyors [ set memory [] ] ask rovsurveyors [ set memory [] ] reset-ticks if show.surveyor.detail.windows? [ if any? transsurveyors [inspect one-of transsurveyors] ;here I had to use "if any?" because inspect will return an error if it finds nobody if any? statsurveyors [inspect one-of statsurveyors] if any? rovsurveyors [inspect one-of rovsurveyors] ] end ;of setup procedure to go tick ; time starts at 1 seconds (not 0) if ticks > survey.time [ do.outputs stop] ; end the simulation run when survey.time is reached, but include the last tick (if survey.time is 300, stop running at 301) if stationary.radius > visibility.length [ output-print "ERROR: stationary.radius is set to a value greater than visibility.length" ; if the stationary radius is higher than visibility, stop and output an error description output-print "The surveyor will not commit to sampling an area that it will not be able to see" output-print "Stopping simulation" stop ] ask transsurveyors [ ; move the surveyors do.tsurveyor.movement ] ask statsurveyors [ do.stsurveyor.movement ] ask rovsurveyors [ do.rsurveyor.movement ] ask animals [ ; move the animals do.animal.movement ] ifelse count.time.step = 1 [ ; if count.time.step is 1, ask surveyors to count animals every second ask transsurveyors [ t.count.animals ] ask statsurveyors [ s.count.animals ] ask rovsurveyors [ r.count.animals ]] [ ; if count.time.step is not 1 (meaning it is 2), only ask every 2 seconds if ticks mod 2 = 0 [ ask transsurveyors [ t.count.animals ] ask statsurveyors [ s.count.animals ] ask rovsurveyors [ r.count.animals ] ] ] end ; of go procedure ;Observer procedures to do.outputs ask transsurveyors [ let real.count length counted.animals let expected.count animal.density * transect.area set t.bias (real.count - expected.count) / expected.count output-type "Transect surveyor bias was " output-print precision t.bias 2 ; outputs bias with 2 decimal places ] ask statsurveyors [ let real.count length counted.animals let expected.count animal.density * stationary.area set s.bias (real.count - expected.count) / expected.count output-type "Stationary surveyor bias was " output-print precision s.bias 2 ] ask rovsurveyors [ let real.count length counted.animals output-type "Roving surveyor swam " output-type survey.time * roving.mean.speed output-type "m and counted " output-type real.count output-print " animals" ; the roving surveyor only tells how many animals it counted ] end to calculate.bias ifelse choose.method = "transect" [ ifelse any? transsurveyors [ output-print "The real value using the transect method is" output-print precision (observed.value / transect.factor.value) 3] [output-print "You need to re-run the model with this method enabled" stop ] ] [ ifelse any? statsurveyors [ output-print "The real value using the stationary method is" output-print precision (observed.value / stationary.factor.value) 3 ] [ output-print "You need to re-run the model with this method enabled" stop ]] end ;animal PROCEDURES ;animal movement to do.animal.movement set heading heading + random-float-between (- animal.dir.angle) animal.dir.angle fd speed ; each step is a second, so the speed is basically the distance end ;SURVEYOR PROCEDURES ;Transect surveyor procedures to do.tsurveyor.movement fd speed ; each step is a second, so the speed is basically the distance end to t.count.animals let myxcor xcor let seen.animals animals in-cone visibility.length trans.viewangle let eligible.animals seen.animals with [(xcor > myxcor - (transect.width / 2)) and (xcor < myxcor + (transect.width / 2))] ; this only works for transects heading north, of course let surveyor.memory memory let new.animals eligible.animals with [not member? who surveyor.memory] ; only animals that were not previously counted are counted if any? new.animals [ let new.records ([species] of new.animals) set counted.animals sentence counted.animals new.records set memory sentence memory [who] of new.animals ] end ;Stationary surveyor procedures to do.stsurveyor.movement set heading heading + stationary.turning.angle ; each second the surveyor rotates "stationary.turning.angle" degrees clockwise end to s.count.animals let eligible.animals animals in-cone stationary.radius stat.viewangle let surveyor.memory memory let new.animals eligible.animals with [not member? who surveyor.memory] ;only animals that were not previously counted are counted if any? new.animals [ let new.records ([species] of new.animals) set counted.animals sentence counted.animals new.records set memory sentence memory [who] of new.animals ] end ;Roving surveyor procedures to do.rsurveyor.movement if ticks mod 2 = 0 [set heading heading + random-float-between (- roving.turning.angle) roving.turning.angle] ;turn every 2 seconds fd speed ; each step is a second, so the speed is basically the distance end to r.count.animals let eligible.animals animals in-cone visibility.length stat.viewangle let surveyor.memory memory let new.animals eligible.animals with [not member? who surveyor.memory] ; only animals that were not previously counted are counted if any? new.animals [ let new.records ([species] of new.animals) set counted.animals sentence counted.animals new.records ; ask new.animals [set color red wait 1 set color gray] ;for troubleshooting set memory sentence memory [who] of new.animals ] end ;reporters to-report random-float-between [a b] report random-float (b - a + 1) + a end to-report t.bias-result ; these reporters are outputs for BehaviourSpace experiments report [t.bias] of one-of transsurveyors ; one-of makes it output a single number instead of a list with one value (a list would be [34] instead of 34) end to-report s.bias-result report [s.bias] of one-of statsurveyors end to-report stationary.factor.value report s.bias-result + 1 end to-report transect.factor.value report t.bias-result + 1 end
There are 7 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
AnimDens NetLogo.png | preview | preview | over 7 years ago, by Miguel Pais | Download |
This model does not have any ancestors.
This model does not have any descendants.