【发布时间】:2019-02-04 07:27:35
【问题描述】:
我下载了修改后的随机集群代码,用于在 NetLogo 建模共享中使用 Millington 版本的修改后的随机集群方法生成中性景观模型。当我单击“generate-landscape”按钮时,代码中的“fill-landscape”过程会导致“Nothing named ? has been defined”错误。
当我创建附加的界面图像并尝试运行下面的相邻代码时。该问题似乎与“发生”报告功能中的问号有关。 reduce 功能未按预期工作。有解决办法吗?查看界面,然后代码如下:
ifelse ( any? neighbours with [ cluster != nobody ] ) ;; check if there are any assigned patches in neighbourhood
[
let covers []
ask neighbours with [ cluster != nobody ]
[
set covers fput cover covers ;;ask neighbours to add their covers to the list
]
let unique-covers remove-duplicates covers ;;create a list of unique covers
let max-cover-count -1 ;the number of neighbours with the maximum cover
let max-cover -1 ;the maximum cover
ifelse(length unique-covers > 1)
[
;if there is more than one unique-cover
foreach unique-covers ;for each of the unique covers
[
let occ occurrences ? covers ;count how many neighbours had this cover
ifelse(occ > max-cover-count) ;if the count is greater than the current maximum count
[
set max-cover ? ;set this as the dominant cover
set max-cover-count occ ;update the current maximum count
;---------------
to-report occurrences [x the-list]
report reduce
[ifelse-value (?2 = x) [?1 + 1] [?1]] (fput 0 the-list)
end
;---------------
假设代码使用 Saura 和 Martinez-Millan (2000) 开发的改进的随机聚类方法生成中性景观模型。但是,错误“Nothing named ? has been defined”会导致代码无法顺利运行。期待想法...
【问题讨论】:
标签: netlogo