当我尝试运行NetLogo模型时出现此错误: 数学运算产生了一个非数字
此外,我注意到接口方面存在问题。即使我在设置过程中没有收到错误,但当至少其中一些补丁应为绿色时,所有补丁都是蓝色的。
我想知道这两个问题是否意味着我在导入ASCII文件时犯了错误。
这是我的每个ASCII文件的元数据。值范围为0-5。没有NA。
NCOLS 125
NROWS 82
XLLCORNER -844919.541237088
YLLCORNER 2451362.63607842
CELLSIZE 33565.7176106285
NODATA_value -9999
这是我的NetLogo代码。
breed[persons person]
breed[trails trail]
extensions [
gis
]
globals [
competition-value
land.or.sea-dataset
cost-dataset
motivation-dataset
boundary-dataset
]
patches-own [
land.or.sea
cost
motivation
boundary
difference
times.here
]
to setup-gis
set land.or.sea-dataset gis:load-dataset "environmentLSL_1.asc"
set cost-dataset gis:load-dataset "environmentLSL_2.asc"
set motivation-dataset gis:load-dataset "environmentLSL_3.asc"
set boundary-dataset gis:load-dataset "environmentLSL_4.asc"
gis:set-world-envelope (gis:envelope-union-of (gis:envelope-of land.or.sea-dataset)
(gis:envelope-of cost-dataset)
(gis:envelope-of motivation-dataset)
(gis:envelope-of boundary-dataset))
end
to set-patch-values
ask patches[
set land.or.sea gis:raster-sample land.or.sea-dataset gis:world-envelope
set cost gis:raster-sample cost-dataset gis:world-envelope
set motivation gis:raster-sample motivation-dataset gis:world-envelope
set boundary gis:raster-sample boundary-dataset gis:world-envelope
]
end
to setup
clear-all
create-persons 100
set-default-shape persons "person"
set-default-shape trails "dot"
ask patches [
setup-gis
ifelse land.or.sea = 1
[set pcolor green]
[set pcolor blue]
set competition-value persons-here
]
set-patch-values
ask persons [
setxy random-xcor random-ycor
set color red
]
reset-ticks
end
to go
if ticks >= 1000
[stop]
if ((count persons) < 100)
[replace-persons]
ifelse competition
[move-persons-with-competition]
[move-persons]
remove-persons
ask patches [
if count persons-here > 0 [set times.here (times.here + 1)]
]
tick
end
to replace-persons
create-persons (100 - (count persons))
set-default-shape persons "person"
ask persons [
setxy random-xcor random-ycor
set color red
]
end
to move-persons-with-competition
if competition-value < max-persons-per-cell [
ask patches [
set motivation (motivation * motivation.coefficient)
set cost (cost * cost.coefficient)
set difference (motivation - cost)
ask persons-here [
uphill4 difference
]
]
]
ask persons[
hatch-trails 1 [set color 16]
]
end
to move-persons
ask patches [
set motivation (motivation * motivation.coefficient)
set cost(cost * cost.coefficient)
set difference (motivation - cost)
ask persons-here [
uphill4 difference
]
]
ask persons[
hatch-trails 1 [set color 16]
]
end
to remove-persons
ask persons [
if boundary = 1
[die]
]
end
to export-results
set times.here gis:patch-dataset times.here
gis:store-dataset times.here "times.here.asc"
end