我在netlogo 6.0.1中使用dbscan(基于密度的聚类)扩展来测量世界界面中海龟之间的聚类效果和聚类分布属性。
extensions [ dbscan ]
to setup
clear-all
ask patches [ set pcolor white ]
create-turtles 1000 [
set color black
set label-color blue
setxy random-xcor random-ycor
]
ask n-of 5 turtles [
ask turtles in-radius 3 [
set color one-of [red grey]
]
]
end
to-report radial-extent [ cluster ]
report max map [
a -> max map [
b -> [
distance a ] of b
]
cluster
]
cluster
end
to find-clusters
let red-grey-turtles turtles with [ member? color [red grey] ]
let clusters dbscan:cluster-by-location red-grey-turtles 3 3
(foreach clusters range length clusters [ [c i] ->
foreach c [
t -> ask t [
set label i
]
]
])
let num-clust length clusters
let max-clust-count max map length clusters
let mean-clust-count mean map length clusters
let var-clust-count variance map length clusters
let stdev-clust-count standard-deviation map length clusters
let max-clust-size mean map radial-extent clusters
let mean-clust-size mean map radial-extent clusters
let var-clust-size variance map radial-extent clusters
let stdev-clust-size standard-deviation radial-extent clusters
end
但是,当我运行代码时,我不断收到以下错误:
OF expected input to be an agent or agentset but got the list [(turtle 3) (turtle 19) (turtle 93) (turtle 186) (turtle 239) (turtle 243) (turtle 322) (turtle 326) (turtle 528) (turtle 587) (turtle 610) (turtle 712) (turtle 719) (turtle 736) (turtle 754) (turtle 799) (turtle 873) (turtle 874) (turtle 887) (turtle 889) (turtle 963) (turtle 18) (turtle 140) (turtle 156) (turtle 530) (turtle 557) (turtle 605) (turtle 687) (turtle 693) (turtle 919) (turtle 979) (turtle 252) (turtle 506) (turtle 978) (turtle 989) (turtle 14) (turtle 534) (turtle 586) (turtle 658) (turtle 133) (turtle 606) (turtle 702) (turtle 995) (turtle 597) (turtle 949) (turtle 160) (turtle 244) (turtle 703) (turtle 742) (turtle 902)] instead.
显然,由于使用of
运算符来确定群集半径,径向范围功能将龟群视为列表而不是代理集。
有关如何解决此问题的任何想法?
答案 0 :(得分:3)
...只需更正最后一行
let stdev-clust-size standard-deviation radial-extent clusters
map
报告人clusters
:
let stdev-clust-size standard-deviation map radial-extent clusters