在 Netlogo BehaviorSpace 中使用报告程序:"Measure runs using these reporters:"
Using a to-report procedure in Netlogo BehaviorSpace: "Measure runs using these reporters:"
是否可以使用一个 to-report 函数来报告多个变量并更新 Netlogo 行为中的 ticks-space(使用这些报告器测量 运行s),以便随着 ticks 更新, 报告的值相应地更新到电子表格中?
`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?
是界面上的开关。当 z?
打开时,报告 g 或 a 和 b,但当开关关闭时,报告 h 或 d 和 e(假设 c 和 f 分别大于 1.5 的条件)。
如果我在行为 space 中调用报告函数 pack
,在 measure runs using these reporters
字段中,生成的电子表格不会显示应该报告的值(g 或 a 和 b,h 或 d 和 e,取决于开关 z?
是打开还是关闭)。电子表格仅包含与设置过程相关的初始化。
此外,我收到一个 运行时间错误,上面写着:reached end of reporter procedure without report being called netlogo
如何让 pack
报告器在行为 space 中的批量模拟 运行 生成的电子表格中随刻度更新值时输出值结果? (我希望它的行为方式与行为 space 中 Measure runs using these reporters
字段的 count turtles
条目的行为方式相同,除了海龟计数,它应该显示 g 或 a 和 b在每个刻度处,否则在电子表格中的每个刻度处为 h、d 和 e)。
跟进评论:
我不确定你想用你的双重报告做什么(a
和 b
和 d
和 e
,所以我使用了两个不同的选项.由于c
,g
,h
在几个程序中被引用,所以我假设它们是globals
.我使用的代码:
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
然后,我像这样设置行为空间实验:
我得到 Table 这样的输出:
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
编辑:示例 2
试试这个 pack-2
记者:
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
然后,尝试像这样设置 BehaviorSpace 实验:
当我 运行 那个实验时,我得到了 pack-2
、c
、g
和 h
的更新值,在每个 tick 的基础上,在电子表格输出中如下所示:
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
在 Table 输出中像这样(更容易用 R 或其他方式处理):
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
如果我仍然缺少您要输出的内容,请告诉我!
是否可以使用一个 to-report 函数来报告多个变量并更新 Netlogo 行为中的 ticks-space(使用这些报告器测量 运行s),以便随着 ticks 更新, 报告的值相应地更新到电子表格中?
`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?
是界面上的开关。当 z?
打开时,报告 g 或 a 和 b,但当开关关闭时,报告 h 或 d 和 e(假设 c 和 f 分别大于 1.5 的条件)。
如果我在行为 space 中调用报告函数 pack
,在 measure runs using these reporters
字段中,生成的电子表格不会显示应该报告的值(g 或 a 和 b,h 或 d 和 e,取决于开关 z?
是打开还是关闭)。电子表格仅包含与设置过程相关的初始化。
此外,我收到一个 运行时间错误,上面写着:reached end of reporter procedure without report being called netlogo
如何让 pack
报告器在行为 space 中的批量模拟 运行 生成的电子表格中随刻度更新值时输出值结果? (我希望它的行为方式与行为 space 中 Measure runs using these reporters
字段的 count turtles
条目的行为方式相同,除了海龟计数,它应该显示 g 或 a 和 b在每个刻度处,否则在电子表格中的每个刻度处为 h、d 和 e)。
跟进评论:
我不确定你想用你的双重报告做什么(a
和 b
和 d
和 e
,所以我使用了两个不同的选项.由于c
,g
,h
在几个程序中被引用,所以我假设它们是globals
.我使用的代码:
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
然后,我像这样设置行为空间实验:
我得到 Table 这样的输出:
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
编辑:示例 2
试试这个 pack-2
记者:
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
然后,尝试像这样设置 BehaviorSpace 实验:
当我 运行 那个实验时,我得到了 pack-2
、c
、g
和 h
的更新值,在每个 tick 的基础上,在电子表格输出中如下所示:
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
在 Table 输出中像这样(更容易用 R 或其他方式处理):
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
如果我仍然缺少您要输出的内容,请告诉我!