你能帮我解决下面的网络标识问题吗?以下是我的问题:

extensions [gis]
globals [
GA-dataset ;; the shape file
]
patches-own [
ID ;;patch ID is identical with polygon ID_ID
farm ;;number of farmers in each county
myneighbors ;;neighboring polygons'
AR ;; adoption ratio
]
turtles-own [
tId ; id of each farmer
AT ; adoption threshold
tneighbors ; an agentset of its neighbor turtles
positive ; if AR > AT
]
to setup
ca
reset-ticks
set GA-dataset gis:load-dataset "County.shp"
gis:set-world-envelope gis:envelope-of GA-dataset
gis:apply-coverage GA-dataset "CODE" ID
gis:apply-coverage GA-dataset "FARMNO" farm
file-close
file-open "Neighbor.txt"
while [not file-at-end?] [
let x file-read let y file-read
ask patches with [ID = x ] [
set myneighbors ( patch-set myneighbors patches with [ID = y ] )
]
]
file-close
foreach gis:feature-list-of GA-dataset [ feature ->
let target-patches ( patches gis:intersecting feature ) with [ gis:contained-by? self feature ]
; Get the number of turtles that should be in each target-patch:
let farm1 round gis:property-value feature "FarmNo"
if any? target-patches [
gis:create-turtles-inside-polygon feature turtles farm1 [
set tID who
set shape "person"
set color green
set size 2
]
]
]
ask turtles [
set AT random-normal 0.2 0.1920
set label precision AT 2
]
ask patches [
set AR 0
]
ask turtles [
set tneighbors [myneighbors] of patch-here
]
;; Draw boundary
gis:set-drawing-color white
gis:draw GA-dataset 1
end
to go
ask turtles [
set positive count tneighbors with [AT <= AR]
]
if ticks = 11 [stop]
tick
end发布于 2022-06-26 19:21:34
这个模型中似乎有四种不同的实体:
Areas
。
单位土地面积(ULA)
location
。
县
ULAs (patches)
农场
(patch)
的
粮食作物
archetype
F 275
采用作物
由农场countable
<代码>H 187农场可以采用多种H 288/code>H 189也可以被各州用来方便地管理每种作物的statistics
terrible名称,对不起,可能是“种植”或“选择”或其他什么?H 292有了这些,你就可以很容易地得到如下的答案:
考虑到本县和邻近的counties?
What作物在neighborhood?
What中的AR值最高的是每种作物的AR值是什么?
。
这些问题在代码中会被问到,比如:
;; show top neighborhood crop for each county
ask counties
[
show [ label ]
of max-one-of
crops
[ count
[ my-adopted-crop-neighbors ]
of [ neighborhood-farms ]
of myself
]
]看上去很复杂,但根据关系由简单的部分组成。
注意:由于NetLogo自己使用的补丁和链接“邻居”,以及该模型在县使用“邻居”和“邻里”,所以有很大的人为混淆的空间。考虑使用一个替代词,或者用不那么令人困惑的记者来包装网络徽标的混淆名称。就像to-report my-plantings report my-adopted-crop-neighbors end
要清楚的是:除非你想要具体的可视化一些东西,只有补丁和农场是可见的(甚至农场可能只是一个彩色的正方形,也许意味着顶部作物的采用)。
即使只有一种作物,这是一个是/否的问题,你仍然可以利用种类和采用的品种进行簿记。
下面的代码是如何设置这样一个代理系统的示例。实际上,它编译时没有错误。可以随意使用任何有帮助的东西。
extensions [gis]
globals
[
GA-dataset ;; the shape file
]
breed [ Counties County ]
breed [ Farms Farm ]
breed [ Crops Crop ]
directed-link-breed [ Adopted-Crops Adopted-Crop ]
patches-own
[
p-ID ;; ID of the patch's county from the source data
p-county ;; points to the patch's county turtle
farm-count ;; count of farms in this patch
AR ;; adoption ratio (is this a patch-level value or a county one?)
]
farms-own
[
f-ID ;; ID of the county from the source
f-County ;; points to the farm's county turtle
AT ;; adoption threshold (per crop?)
;; (is this a farm-level value or a county value?)
;; is this one value or set of values? (ie, all the crops)
;; if this is per-crop (a list), then this is eliminated
;; by the adopted crops
positive ;; if AR > AT ;; same-- this may be a per-crop value
]
Crops-Own
[ ;; label ;; use the built in label for values like "oranges" or "corn"
;; add variables as needed for things like..
;; cost
;; market-value
;; adoption-preference
;; etc.
]
Adopted-Crops-Own
[ ;; add variables for per-farm or per-county things like:
;; % of production
;; production amount?
;; label -- copy the label from the Crop,
;; this will probably be convenient to have
]
counties-own
[ county-ID ;; ID number of the county from Source
county-patches ;; patches in this county
border-patches ;; set of patches on the border of the country
;; useful to draw the map
;; and later may be useful for visualization
;; that needs to highlight a county
county-farms ;; farmers in this country
county-crops ;; unless it frequently changes membership,
;; the set of all adopted-crops links for all my farms
adjacent-counties ;; set of counties sharing a border
adjacent-farms ;; set of farms from those counties
neighborhood ;; set of this and adjacent counties
neighborhood-farms ;; farms in this and adjacent counties
neighborhood-crops ;; crops adopted in this and adjacent counties
;; any other county-level variables, like adoption rate history
]
to setup-patches-from-GIS
set GA-dataset gis:load-dataset "County.shp"
gis:set-world-envelope gis:envelope-of GA-dataset
gis:apply-coverage GA-dataset "CODE" p-ID
gis:apply-coverage GA-dataset "FARMNO" farm-count
end
to setup-counties
let list-of-county-ids remove-duplicates [ p-ID ] of patches
foreach list-of-county-ids
[ $ID ->
create-counties 1
[ set county-ID $ID
set county-patches patches with [ p-ID = $ID ]
]
]
end
to setup-county-neighbors
ask counties
[ set adjacent-counties no-turtles
]
file-close-all
file-open "Neighbors.txt"
while [ not file-at-end? ]
[
let $a file-read
let $b file-read
let $AA one-of counties with [ county-ID = $a ]
let $BB one-of counties with [ county-ID = $b ]
ask $AA [ set adjacent-counties ( patch-set $BB adjacent-counties) ]
ask $BB [ set adjacent-counties ( patch-set $AA adjacent-counties) ]
]
set neighborhood ( patch-set self adjacent-counties )
file-close
end
to setup-crops
let crop-list
[
[ "apples" ] ;; include any other per-crop values to initialize
[ "oranges" ] ;; you could also store this list is a file
[ "rice" ]
[ "beans" ]
[ "coffee" ]
]
foreach crop-list
[ crop-data-row ->
create-Crops 1
[ hide-turtle
set size 0
set color black
set heading 0
set label item 0 crop-data-row
;; set other-property item 1 crop-data-row
;; etc
]
]
end
to setup-farms
;; this is confusing... did we not already
;; load ID and farmno into the patches?
;; so.. can we just use that?
ask patches with [ farm-count > 0 ]
[ sprout-farms farm-count
[ set f-ID p-ID
set f-county p-county
set shape "person"
set color green
set heading 0
set size 0
]
]
;; setup adopted-crops
ask farms
[ create-adopted-crops-to crops
[ hide-link
]
]
;;foreach gis:feature-list-of GA-dataset
;;[ feature ->
;; let target-patches ( patches gis:intersecting feature )
;; with [ gis:contained-by? self feature ]
;; ;; Get the number of turtles that should be in each target-patch:
;; let farm1 round gis:property-value feature "FarmNo"
;; if any? target-patches
;; [
;; gis:create-turtles-inside-polygon feature turtles farm1
;; [
;; set t-ID who
;; set shape "person"
;; set color green
;; set size 2
;; set t-county one-of counties with [ county-ID =
;; ]
;; ]
;; ]
end
to setup-farm-data
ask farms
[
set AT random-normal 0.2 0.1920
set label precision AT 2
]
ask patches
[
set AR 0
]
end
to update-county-datasets
ask counties
[ let this-ID county-ID
set border-patches county-patches with
[ any? neighbors with [ p-ID != this-ID ]
]
set county-farms farms-on county-patches
set county-crops (link-set [ my-adopted-crops ] of county-farms)
]
ask counties
[
set adjacent-farms (turtle-set [ county-farms ] of adjacent-counties)
set neighborhood-farms (turtle-set [ county-farms ] of neighborhood)
set neighborhood-crops ( link-set [ my-adopted-crops ] of neighborhood-farms)
]
end
to draw-boundaries
;; Draw boundary
gis:set-drawing-color white
gis:draw GA-dataset 1
end
to setup
setup-patches-from-GIS
setup-counties
setup-county-neighbors
setup-crops
setup-farms
setup-farm-data
update-county-datasets
draw-boundaries
endhttps://stackoverflow.com/questions/72695601
复制相似问题