我是netlogo的新手,在绘制与补丁相关的属性平均值时遇到以下错误:
没有这样的情节:“补丁0 0” 补丁0 0运行SET-CURRENT-PLOT时出错 通过过程GO调用 由Button'go'调用
但是补丁0 0显然存在,并且在代码中预定义如下:
'globals [ k ] ; interaction constant
patches-own [ a b c d' e' ] ; state variables of properties
; a is the Proportion and variety of Blend of land use
; b is the Land uses with supportiveness for complimentary activities
; c is the Vehicular and Pedestrian Intensity
; d is the Intensity of Nodes in urban web
; e' is the Frequency of Enforced Vigilance
to setup
clear-all
set k initial-k
setup-patches
reset-ticks
end
to setup-patches
ask patches [ set pcolor yellow ] ; defines the patches as built up in an area
; to define road patches (horizontal)
ask patches [ if pycor = 0 [ set pcolor grey ] ]
ask patches [ if pxcor = 0 [ set pcolor grey ] ]
ask patches [if pycor = 9 [ set pcolor grey ] ]
ask patches [ if (pycor = 6) and (pxcor < -4 )[ set pcolor grey ] ]
ask patches [ if (pycor = 3) and (pxcor < -4 ) [ set pcolor grey ] ]
ask patches [ if (pycor = 4) and (pxcor > 3 ) [ set pcolor grey ] ]
ask patches [ if (pycor = -6) and (pxcor > 7 ) [ set pcolor grey ] ]
; to define road patches (vertical)
ask patches [ if (pycor > 0) and (pxcor = -10 ) [ set pcolor grey ] ]
ask patches [ if (pycor > 0) and (pxcor = -5 ) [ set pcolor grey ] ]
ask patches [ if (pycor < 0) and (pxcor = -7 ) [ set pcolor grey ] ]
ask patches [ if (pycor < 0) and (pxcor = -3 ) [ set pcolor grey ] ]
ask patches [ if (pycor < -3) and (pxcor = 4 ) [ set pcolor grey ] ]
ask patches [ if (pycor > 3) and (pxcor = 4 ) [ set pcolor grey ] ]
ask patches [ if (pycor > 0) and (pxcor = 7 ) [ set pcolor grey ] ]
; to define nodes as patches
ask patches [ if pxcor = 0 and pycor = 0 [ set pcolor red ] ]
ask patches [ if pxcor = 7 and pycor = 0 [ set pcolor red ] ]
ask patches [ if pxcor = -3 and pycor = 0 [ set pcolor red ] ]
ask patches [ if pxcor = -5 and pycor = 0 [ set pcolor red ] ]
ask patches [ if pxcor = -7 and pycor = 0 [ set pcolor red ] ]
ask patches [ if pxcor = -10 and pycor = 0 [ set pcolor red ] ]
ask patches [ if pxcor = 4 and pycor = 4 [ set pcolor red ] ]
ask patches [ if pxcor = 7 and pycor = 4 [ set pcolor red ] ]
ask patches [ if pxcor = 7 and pycor = 9 [ set pcolor red ] ]
ask patches [ if pxcor = 4 and pycor = 9 [ set pcolor red ] ]
ask patches [ if pxcor = 0 and pycor = 9 [ set pcolor red ] ]
ask patches [ if pxcor = -5 and pycor = 9 [ set pcolor red ] ]
ask patches [ if pxcor = -10 and pycor = 9 [ set pcolor red ] ]
ask patches [ if pxcor = -10 and pycor = 6 [ set pcolor red ] ]
ask patches [ if pxcor = -10 and pycor = 3 [ set pcolor red ] ]
ask patches [ if pxcor = -5 and pycor = 6 [ set pcolor red ] ]
ask patches [ if pxcor = -5 and pycor = 3 [ set pcolor red ] ]
; to set intial values of properties for patches
ask patches with [pcolor = yellow] [ set a random-float 0.9] ; initial a
ask patches with [pcolor = yellow] [ set b random-float 0.9] ; initial b
ask patches with [pcolor = grey] [ set c random-float 0.9] ; initial c
ask patches with [pcolor = red] [ set d' random-float 0.9] ; initial d'
ask patches with [pcolor = grey] [ set e' random-float 0.9] ; initial e'
end
to go
tick
if ticks >= 52 [ stop ]
ask patches with [pcolor = yellow]
[
let fc [c] of one-of patches with [pcolor = grey] ; reports c of any one
grey patch of neighbours
let fe' [e'] of one-of patches with [pcolor = grey] ; reports e' of any one grey patch of neighbours
let fd' [d'] of one-of patches with [pcolor = red] ; reports d' of any one red patch of neighbours
if a < 0.1 [ set a 0.1
if a > 0.9 [ set a 0.9 ] ]
if b < 0.9 [ set b b + (k * a) + (k * fc) + (k * fd')
if b > 0.9 [ set b 0.9 ] ]
if b > 0.1 [ set b b - (k * fe')
if b < 0.1 [ set b 0.1 ] ]
]
ask patch 0 0
[ let fa [a] of one-of patches with [pcolor = yellow]
let fb [b] of one-of patches with [pcolor = yellow]
let fc [c] of one-of patches with [pcolor = grey]
let fe' [e'] of one-of patches with [pcolor = grey]
let eeep (fa + fb + fc + d' + 1 / fe') / 5
let deep (1 / fa + 1 / fb + 1 / fc + 1 / d' + fe') / 5
output-print eeep
output-print deep
set-current-plot " patch 0 0"
set-current-plot-pen "eeep"
plot eeep
set-current-plot-pen "deep"
plot deep
]
end'
一段时间以来,我一直在尝试解决此问题,感谢您的帮助。 谢谢!
答案 0 :(得分:1)
存在名为patch 0 0
的补丁。但是,这并不意味着存在名为“ patch 0 0”的图。您只是简单地输入了绘图的名称(也许您输入的空格数不正确)。
我建议您将图重命名为看起来不像补丁标识符的名称,以减少混乱。尝试使用“ plot-0-0”之类的方法,在绘图对话框的界面和代码中都重命名。