我下载了修改后的随机聚类代码,以使用NetLogo建模公用程序中的Millington版本的修改后的随机聚类方法生成中性景观模型。当我单击“生成横向”按钮时,代码中的“填充横向”过程导致“未定义名称为?的错误”错误。
当我创建附加的接口图像并尝试运行下面的附加代码时。该问题似乎与“出现次数”报告功能中的问号有关。减少功能无法正常工作。有没有解决的办法?请参见界面,然后查看以下代码:
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)开发的改进的随机聚类方法生成中性景观模型。但是,错误“未定义名称为No”已使代码无法正常运行。期待有想法...
答案 0 :(得分:2)
NetLogo 5.x中的旧TOKEN
语法在NetLogo 6中被新的?
语法替换。请参见https://ccl.northwestern.edu/netlogo/docs/programming.html#anonymous-procedures
例如,在NetLogo 5中,您将编写:
->
在NetLogo 6中,您输入:
foreach [0 1 2 3] [
print ?
]
答案 1 :(得分:2)
结合布莱恩的答案(第一个步骤)和NetLogo词典(第二个步骤),可以得到以下内容。注释指示新位。未经测试。
mvn org.apache.maven.plugins:maven-deploy-plugin:2.4:deploy-file -DgroupId=org.directwebremoting -DartifactId=dwr -Dversion=3.0.0-rc2 -Dpackaging=jar -Dfile=/Users/davea/.m2/repository//org/directwebremoting/dwr/3.0.0-rc2/dwr-3.0.0-rc2.jar -Durl=dav:https://repository-myco.forge.cloudbees.com/private -DrepositoryId=cloudbees-private
对于某些情况,您可以直接从NetLogo词典ifelse ( any? neighbours with [ cluster != nobody ] )
[ let covers []
ask neighbours with [ cluster != nobody ]
[ set covers fput cover covers
]
let unique-covers remove-duplicates covers
let max-cover-count - 1 ; added a space around subtraction
let max-cover - 1 ; more spacing
ifelse(length unique-covers > 1)
[ foreach unique-covers
[ this-cover -> ; here's the new bit, calling ? 'this-cover'
let occ occurrences this-cover covers ; passes to the occurrences procedure
ifelse(occ > max-cover-count)
[ set max-cover this-cover ; using the name this-cover again
set max-cover-count occ
示例中进行操作
reduce