Reputation: 339
Is it possible to use a to-report function that reports multiple variables and updates with ticks in Netlogo behavior-space (measure runs using these reporters), so that as ticks update, the reported value is updated accordingly into spreadsheet?
`to setup
clear-all
create-turtles 100 [ setxy random-xcor random-ycor ]
reset-ticks
end`
to go
move-turtles
tick
if ticks = 100 [
stop
]
end
to move-turtles
ask turtles [
right random (90 + c)
forward g + h
]
end
to-report pack
ifelse (z? = true) [
let a random-float 1.0
let b random-float 2.0
let c random-float 3.0
if c > 1.5 [
let g = a - b
report g
]
report a
report b
]
[
let d random-float 1.0
let e random-float 2.0
let f random-float 3.0
if f > 1.5 [
let h = d - e
report h
]
report d
report e
]
]
end
z?
is a switch on the interface. When z?
is switched on either g or a and b are reported, but when the switch is off, either h or d and e are reported (given the conditions that c and f are greater than 1.5 respectively).
If I call the report function pack
in behavior space, within the measure runs using these reporters
, field, the resulting spreadsheet does not show the tick-by-tick result updates for the values that are supposed to be reported (g or a and b, h or d and e, depending on whether the switch z?
is on or off). The spreadsheet only contains the initializations associated with the setup procedure.
Also, I get a runtime error that says: reached end of reporter procedure without report being called netlogo
How can I get the pack
reporter to output results of values as they update with ticks in the resulting spreadsheet from a batch simulation run in behaviorspace? (I want to it to act the the same way a count turtles
entry into the Measure runs using these reporters
field in behaviorspace would behave, except instead of turtle counts, it should show g or a and b at each tick, otherwise h, d and e at each tick in the spreadsheet ).
Upvotes: 0
Views: 1571
Reputation: 10301
Following up from comments:
I wasn't sure what you wanted to do with your double reports (a
and b
and d
and e
, so I used two different options. Since c
, g
, and h
are referenced in several procedures, I assumed they are globals
. The code I used:
globals [ c g h ]
to setup
clear-all
create-turtles 100 [ setxy random-xcor random-ycor ]
reset-ticks
set c 10
set g 2
set h 3
end
to go
move-turtles
tick
end
to move-turtles
ask turtles [
right random (90 + c)
forward g + h
]
end
to-report pack
ifelse (z? = true) [
let a random-float 1.0
let b random-float 2.0
set c random-float 3.0
if c > 1.5 [
set g a - b
report g
]
report ( word a " " b )
]
[
let d random-float 1.0
let ee random-float 2.0
let f random-float 3.0
if f > 1.5 [
set h d - ee
report h
]
report d + ee
]
end
Then, I set up the Behaviorspace experiment like this:
And I get Table output like this:
run z1. step pack
1 2 FALSE 0 0.18138234
2 2 FALSE 1 1.676066247
3 2 FALSE 2 0.403470969
4 1 TRUE 0 -0.10139442
5 2 FALSE 3 1.399234345
6 2 FALSE 4 -0.887992861
7 1 TRUE 1 0.0671613060827172 1.5362438146989783
8 2 FALSE 5 -0.864156125
9 2 FALSE 6 1.626410602
10 1 TRUE 2 0.5789346091777932 1.1071709255628879
11 2 FALSE 7 0.446313014
12 1 TRUE 3 0.7216825225835118 0.22072137498998523
Edits:example 2
Try this pack-2
reporter:
to-report pack-2
let x random 5
let y random 7
set g g + 1
if z? [
set c c * 1.2
]
set h x + y
report ( word x " " y )
end
Then, try setting up the BehaviorSpace experiment like this:
When I run that experiment I get updating values for pack-2
, c
, g
, and h
on a per-tick basis, which looks as below in Spreadsheet output:
pack.2 c g h pack.2.1 c.1 g.1 h.1
1 0 0 12.00000 3 0 2 2 10 3 4
2 0 3 14.40000 4 3 2 1 10 4 3
3 3 5 17.28000 5 8 4 4 10 5 8
4 1 2 20.73600 6 3 4 0 10 6 4
5 4 6 24.88320 7 10 3 6 10 7 9
And like this in Table output (easier to process with R or whatever):
X.run.number. z. X.step. pack.2 c g h
1 1 true 0 3 0 12.0000 3 3
2 2 false 0 2 0 10.0000 3 2
3 1 true 1 4 4 14.4000 4 8
4 2 false 1 1 0 10.0000 4 1
5 1 true 2 4 1 17.2800 5 5
If I am still missing what you're trying to output, please let me know!
Upvotes: 1