我试图在杀死一只乌龟后恢复一个初始状态(回到它的第一个状态)的龟和链接。 我一直在尝试从http://ccl.northwestern.edu/netlogo/docs/nw.html的解决方案,但它不起作用。 下面是我的代码如何存储要在netlogo中恢复的网络环境?
to cycle
if Measure = "Efficiency of network"
[ ;store node and link
nw:set-context turtles with [ shape = "circle" ] links with [ color = blue ]
show map sort nw:get-context
set old-turtles item 0 nw:get-context
show old-turtles
set old-links item 1 nw:get-context
show old-links
;start process
process-performance
]
end
to process-performance
if NumberOfNodes = 1
[file-open "1node.txt"
while [not file-at-end?]
[
;calculate initial performance value
set initial nw:mean-path-length
show initial
let nodeseq read-from-string (word "[" file-read-line "]")
show item 0 nodeseq
ask turtle (item 0 nodeseq) [ die ]
update-plots
;calculate new performance value
set final nw:mean-path-length
show final
set result (1 - (final/initial)) * 100
show result
nw:set-context old-turtles old-links
show map sort nw:get-context
]
file-close
]
end
我一直在使用“NW:设置情境老乌龟老链接”从的NetLogo文档中,但似乎原来的乌龟和链接方面,我存储在“OLD-无论我如何储存它们,乌龟旧链接“都将被有目的地改变。我在想如果[死]功能改变存储的代理集?当我杀死节点时,旧海龟和旧链接的大小逐渐变小。我没有将新的环境存储回老龟和旧链接。
或者没有人有其他方式来存储旧的代理集和链接并恢复到其原始网络结构?
感谢您阅读。
感谢您的回答,以及您对杀死龟的验证,这也会将其从所有代理商中移除。非常有趣的属性。稍后我会尝试使用“隐藏”功能。目前,我正在使用一种非常暴力的方法来恢复我的所有节点和链接。 – user1142930 2015-02-23 19:00:33