Reputation: 19
I save data for the simulation as csv files using: File>Export>Export World which works for 1 iteration. I would like to run my model for 1000 simulations (and more) and save data at every iteration. Because at every run, the output is different. I worked through an example in BehaviourSpace but my output data is not detailed as the one I get using File>Export>Export World. I have also tried from the csv example and the output for the all the turtles-own (infected?, infected2?, infected3?, susceptible?) were the same.
In BehaviourSpace, under the option of Measure runs using these reporters, I would like to count turtles-own like infected?, infected1? but when I do that I get an error; Experiment aborted due to syntax error: You can't use INFECTED? in an observer context, because INFECTED? is turtle-only.
My question is how to track population of the infected, infected2 and infected3 as csv files for many iterations without having to do it manually (attached is my code). Any help is highly appreciated. Thank you.
globals
[
sink-patches
time1
time2
signs
timeA
prob1
prob2
]
breed [popns popn] ;;T defines the name of a single member of the breed.
breed [ppls ppl]
popns-own
[
infected?
infected2?
infected3?
susceptible?
infected-time
infection2-time
]
;; setup procedures
to setup
clear-all
setup-patches
setup-globals
setup-people
reset-ticks ; Resets the tick counter to zero, sets up all plots, then updates all plots.
end
to setup-globals
set signs 13
set timeA signs + time1
set prob1 25
set prob2 50
end
to setup-patches ; Create a patch ; Enlarge this patch to increase BU stage 1 infections.
clear-all
let sink-patch-radius 2 ;increase the size of the patch here
let sink-centre patch 0 0 ;centre of the patch
set sink-patches [patches in-radius sink-patch-radius] of sink-centre ; neighbouring patches
;set sink-patches with [abs pxcor <= 8 and abs pycor <= 8]
ask sink-patches [ set pcolor gray ] ;set the patch to color gray
end
to setup-people
create-popns start-people ;setting up people
[
setxy random-xcor random-ycor
set infected? false
set infected2? false
set infected3? false
set susceptible? true
set shape "circle"
set color brown
set infected-time 0
set infection2-time 0
]
create-ppls start-otherPeople ; other population
[
setxy random-xcor random-ycor
set shape "circle"
set color white
]
end
to assign-color ;; turtle procedure
if infected?
[ set color red ]
if infected2?
[ set color blue ]
if infected3?
[ set color yellow ]
end
;; Go procedures
to go
ask popns[ assign-color]
ask popns[ infect_start]
ask popns with [ infected? ]
[ infect_two ]
ask popns with [ infected2? ]
[ infect_three ]
ask popns [count-update] ;
ask turtles [move]
tick
end
;; People move about at random.
to move ;; turtle procedure
rt random-float 360 ;the turtle turns right by 360 degrees.
fd 1
end
to infect_start ;stage one;;
let healthy (popns-on sink-patches) with [ susceptible? ]
if (random-float 100 < Infection-Rate)
[
ask healthy
[
set infected? true
set susceptible? false
]
]
end
to infect_two ;Infect stage two = green
if infected-time > timeA
[set infected? false
set infected2? true
]
end
to infect_three ;Infect stage three= yellow
if infection2-time > time2
[
set infected2? false
set infected3? true
]
end
to count-update ; This updates the count of time in the various stages of infection or treatments
if (infected? or infected2? or infected3?) [set infected-time infected-time + 1 ]
if infected2? [set infection2-time infection2-time + 1 ]
end
Upvotes: 0
Views: 302
Reputation: 17678
It sounds like you can use BehaviorSpace for your export, you just formatted the code incorrectly. BehaviorSpace is much easier than trying to create your own export and managing it. So the first step is to create monitors on your interface that capture the measures that you want to output, maybe:
count turtles with [infected?]
Once you have them working (and showing whatever it is you want), then you know your syntax is correct and you simply copy the monitor's code into the output bit of the BehaviorSpace experiment.
Upvotes: 1