我正在從文件讀取的值中設置修補程序。該值在列表的列表:Netlogo在通過列表〜6K列表時丟失了不一致的結果
[[10001 53 1 2 160 4 4 4 1] [10004 69 1 2 143 4 4 4 2] [10005 70 2 2 135 3 3 4 2] [10006 51 2 2 132 4 4 3 3] ... ]
每個「內部」名單有補丁的屬性值。
位置2的值(我從第一個值的0開始計數)表示性別:
1
=男性,2
=女性。
我的方法:
to setup-patches-as-agents [ patches-data ]
set male-count 0
set female-count 0
set total-rows 0
foreach patches-data [
[ one-row ] ->
ask patches with [ pxcor = random-pxcor and pycor = random-pycor]
[ set total-rows total-rows + 1
;; add values to patch properties
;; **** id ****
set p-midus_id item 0 one-row
;; **** age *****
set p-age item 1 one-row
;; gender 1= MALE; 2= FEMALE; 7= DON'T KNOW; 8= REFUSE
set p-gender item 2 one-row
if item 2 one-row = 1 ;; male
[ set pcolor blue
set male-count male-count + 1 ] ;; male
if item 2 one-row = 2 ;; female
[ set pcolor orange
set female-count female-count + 1 ] ;; female
;; **** lose10lb ****
set p-lose10lb item 3 one-row
;; **** weightYrAgo ****
set p-weightYrAgo item 4 one-row
;; **** limitLiftCarryGroceries ****
set p-limitLiftCarryGroceries item 5 one-row
;; **** limitClimbingStairs ****
set p-limitClimbingStairs item 6 one-row
;; **** limitWalkingSeveralBlocks ****
set p-limitWalkingSeveralBlocks item 7 one-row
;; **** limitWalkingSeveralBlocks ****
set p-limitWalkingSeveralBlocks item 8 one-row
]
]
type "male-count: "
print male-count
type "female-count: "
print female-count
type "total-count: "
print total-rows
end
行的總讀取數量爲:6325(輸出讀取文件,該文件中的行
男性的總數應該是匹配的數目後:3004女性爲:3321計數我這些變量的變化,包括「行」的總數得到
任何想法,爲什麼?