选择 breed-neighbors 时,随机种子无法在 NetLogo 中重现 运行
random seed fails to reproduce run in NetLogo when selecting breed-neighbors
我有一个包含三个无向 link 品种的网络
undirected-link-breed [ parentals parental ]
undirected-link-breed [ diffusions diffusion ]
undirected-link-breed [ simdiffusions simdiffusion ]
我已经修复了种子,运行 我的 go 过程调用了不同的过程,这些过程总是按照给定的种子重现输出。我的 go 过程只是选择一只乌龟,然后这只乌龟执行一个可用的过程。 None 这些过程调用任何东西 link-related。一切正常,我可以在给定种子的情况下重现 运行,所以我非常有信心代码可以正常工作。
然后我有最后一个过程,当被选中时,它会破坏随机序列并且无法在不同的 运行 之间重现输出。这次在GO中选择的调用海龟调用下面的程序:
to network-mechanisms
;; THIS LINE BREAKS THE RNG
let innovator-nei parental-neighbors with [typeof = "potter"]
;; THIS LINE DOES NOT BREAK THE RNG
;let innovator-nei other turtles with [typeof = "potter"]
ask innovator-nei [
let my-nei parental-neighbors with [typeof = "potter"]
if any? my-nei [
set attribute sum [centrality] of my-nei with [adopted-now?] / count my-nei
set attribute 1 / (1 + exp (4 - 8 * attribute))
]
]
ask innovator-nei [
if random-float 1 < attribute [
adopt
create-simdiffusion-with myself [set color red]
]
]
end
如果调用的乌龟寻找它的 parental-neighbors,那么奇怪的事情就会发生,RNG 序列在每个 运行 都会改变,无论种子是什么;而如果调用的海龟调用所有其他海龟,则 RNG 序列在 运行 秒内是相同的...这是使用 link-breeds 时的已知问题吗?
没有这样的已知问题。如果您认为自己发现了错误,请在 https://github.com/NetLogo/NetLogo/issues/new and include a SSCCE 开张票。 (上面的代码不是独立的——你没有包括必要的声明,你没有包括你用来测试和重现错误的代码——而且它似乎也不是必要的最少代码演示问题。)
以下是此问题的 SSCCE 的示例:
undirected-link-breed [parentals parental]
turtles-own [typeof]
to setup
clear-all
crt 5 [ create-parentals-with other turtles ]
ask n-of 3 turtles [ set typeof "potter" ]
ask turtles [
let innovator-nei parental-neighbors with [typeof = "potter"]
]
print random-float 1.0
end
to test
random-seed 0
setup
random-seed 0
setup
end
碰巧,这段代码没有显示任何错误;当 运行 时,它打印相同的数字两次,这是正确的行为:
observer> test
0.8700121472788938
0.8700121472788938
但它显示了提交正确的错误报告所需的内容。
我有一个包含三个无向 link 品种的网络
undirected-link-breed [ parentals parental ]
undirected-link-breed [ diffusions diffusion ]
undirected-link-breed [ simdiffusions simdiffusion ]
我已经修复了种子,运行 我的 go 过程调用了不同的过程,这些过程总是按照给定的种子重现输出。我的 go 过程只是选择一只乌龟,然后这只乌龟执行一个可用的过程。 None 这些过程调用任何东西 link-related。一切正常,我可以在给定种子的情况下重现 运行,所以我非常有信心代码可以正常工作。
然后我有最后一个过程,当被选中时,它会破坏随机序列并且无法在不同的 运行 之间重现输出。这次在GO中选择的调用海龟调用下面的程序:
to network-mechanisms
;; THIS LINE BREAKS THE RNG
let innovator-nei parental-neighbors with [typeof = "potter"]
;; THIS LINE DOES NOT BREAK THE RNG
;let innovator-nei other turtles with [typeof = "potter"]
ask innovator-nei [
let my-nei parental-neighbors with [typeof = "potter"]
if any? my-nei [
set attribute sum [centrality] of my-nei with [adopted-now?] / count my-nei
set attribute 1 / (1 + exp (4 - 8 * attribute))
]
]
ask innovator-nei [
if random-float 1 < attribute [
adopt
create-simdiffusion-with myself [set color red]
]
]
end
如果调用的乌龟寻找它的 parental-neighbors,那么奇怪的事情就会发生,RNG 序列在每个 运行 都会改变,无论种子是什么;而如果调用的海龟调用所有其他海龟,则 RNG 序列在 运行 秒内是相同的...这是使用 link-breeds 时的已知问题吗?
没有这样的已知问题。如果您认为自己发现了错误,请在 https://github.com/NetLogo/NetLogo/issues/new and include a SSCCE 开张票。 (上面的代码不是独立的——你没有包括必要的声明,你没有包括你用来测试和重现错误的代码——而且它似乎也不是必要的最少代码演示问题。)
以下是此问题的 SSCCE 的示例:
undirected-link-breed [parentals parental]
turtles-own [typeof]
to setup
clear-all
crt 5 [ create-parentals-with other turtles ]
ask n-of 3 turtles [ set typeof "potter" ]
ask turtles [
let innovator-nei parental-neighbors with [typeof = "potter"]
]
print random-float 1.0
end
to test
random-seed 0
setup
random-seed 0
setup
end
碰巧,这段代码没有显示任何错误;当 运行 时,它打印相同的数字两次,这是正确的行为:
observer> test
0.8700121472788938
0.8700121472788938
但它显示了提交正确的错误报告所需的内容。