在設置中,我將創建一個命令,用於生成具有隨機維度的隨機數集羣。每個羣集將由代理(農民)管理。每一個斑塊都代表着農民可以用不同種子種植的潛在作物。這將是值得使用的半徑功能?如果你需要更多的細節問我。NetLogo - 創建一個集羣作爲一個由烏龜管理的集羣
非常感謝您的回答,這正是我需要的!現在我還有一個問題,我按照你的建議實施了這個計劃,現在我展示了一個像你這樣的世界,但我不知道如何讓我的經紀人(農民)在他們的農場規模的每一個補丁上採取行動。在我的模擬中,農民只在一個補丁上採取行動。我嘗試了不同的方式來擴展代理的功能(功能補丁集),但每次在程序運行期間出現錯誤。 正如Marzy先前的帖子所建議的,我包含了我的模型的代碼。 主要問題是將「培養」程序(在代碼的底部)擴展到屬於農民的每個補丁。
非常感謝您
turtles-own [
profit-from-fuel
profit-from-food
expected-fuel-sell-price
expected-food-sell-price
profit
farm
farm-size
;risk-attitude-food
;risk-attitude-fuel
]
patches-own [
fuel-yeld
food-yeld
land-sustainability
water-level
belongs-to
]
globals [
fuel-sell-price
food-sell-price
governs
]
to setup
clear-all
clear-all-plots
create-farmers
setup-land
reset-ticks
ask turtles
[ set-farm-in-radius farm-size ]
set fuel-sell-price 30 ;+ random 2 + random -2
set food-sell-price 30 ;+ random 2 + random -2
end
to create-farmers
create-turtles 30
[
set shape "person farmer"
setxy random-pxcor random-pycor
set profit-from-fuel 0 ; indicizzazione del profitto iniziale a 0
set profit-from-food 0 ; indicizzazione del profitto iniziale a 0
set farm-size random 5 + 1
set label farm-size
]
end
to setup-land
ask patches [set belongs-to nobody]
ask patches
[
set pcolor 3
set food-yeld 10000
set fuel-yeld 10000
set land-sustainability random 5
set water-level random 3
]
end
to set-farm-in-radius [d]
move-to one-of patches with [not any? other patches in-radius d with [belongs-to != nobody]]
set farm patches in-radius farm-size
ask farm [set belongs-to myself]
let c random 6 + 61
ask farm [set pcolor c]
end
to set-farm-distance [d]
move-to one-of patches with [not any? other patches with [belongs-to != nobody and distance myself < d]]
set farm patches with [distance myself < d]
ask farm [set belongs-to myself]
let c random 6 + 61
ask farm [set pcolor c]
end
to go
tick
ask turtles [
set expected-fuel-sell-price fuel-sell-price + random 5 + random -5
if expected-fuel-sell-price < 0 [set expected-fuel-sell-price 1]
set expected-food-sell-price food-sell-price + random 5 + random -5
if expected-food-sell-price < 0 [set expected-food-sell-price 1]
set profit profit-from-fuel + profit-from-food
if profit = 0 [ set profit 1 ]
]
set fuel-sell-price fuel-sell-price + random 5 + random -5
if fuel-sell-price < 0 or fuel-sell-price = 0 [set fuel-sell-price 1 ]
set food-sell-price food-sell-price + random 5 + random -5
if food-sell-price < 0 or food-sell-price = 0 [set food-sell-price 1]
ask turtles [
cultivate
set profit profit-from-food + profit-from-fuel
;if water-level > 0.95 [ set profit profit - (profit * (2/profit)) ] valutare se inserire anche una failing probability
]
if ticks = Duration [ stop ]
if ticks > Duration [stop]
end
to cultivate
ifelse land-sustainability < 2.1 or water-level = 1
[ set pcolor green set profit-from-food food-sell-price * (((food-yeld)^(1 - alfa)) * (((water-level)^(1 - gamma)) * ((land-sustainability)^(gamma))^alfa))
]
[
let utility-from-food ((food-yeld * expected-food-sell-price * land-sustainability)^risk-attitude)/risk-attitude
let utility-from-fuel ((food-yeld * expected-fuel-sell-price * land-sustainability)^(1 - risk-attitude))/(1 - risk-attitude)
ifelse utility-from-food < utility-from-fuel
[
set pcolor red
set profit-from-fuel fuel-sell-price * (((fuel-yeld)^(1 - alfa)) * (((water-level)^(1 - gamma)) * ((land-sustainability)^(gamma))^alfa))
]
[
set pcolor green
set profit-from-food food-sell-price * (((food-yeld)^(1 - alfa)) * (((water-level)^(1 - gamma)) * ((land-sustainability)^(gamma))^alfa))
]
]
end
新version_ _ __ _ __ ----
to cultivate
ifelse land-sustainability < 2.1 or water-level = 1
[
set profit-from-food food-sell-price * (((food-yeld)^(1 - alfa)) * (((water-level)^(1 - gamma)) * ((land-sustainability)^(gamma))^alfa))
set food 1
]
[
let utility-from-food ((food-yeld * expected-food-sell-price * land-sustainability)^risk-attitude)/risk-attitude
let utility-from-fuel ((food-yeld * expected-fuel-sell-price * land-sustainability)^(1 - risk-attitude))/(1 - risk-attitude)
ifelse utility-from-food < utility-from-fuel
[
set profit-from-fuel fuel-sell-price * (((fuel-yeld)^(1 - alfa)) * (((water-level)^(1 - gamma)) * ((land-sustainability)^(gamma))^alfa))
set fuel 1
]
[
set profit-from-food food-sell-price * (((food-yeld)^(1 - alfa)) * (((water-level)^(1 - gamma)) * ((land-sustainability)^(gamma))^alfa))
set food 1
]
]
ask farm [
if food = 1 [set pcolor green]
if fuel = 1 [set pcolor red]
]
end
其更好地包括一些代碼,問究竟是什麼在半徑的問題可能是好的,但你需要什麼樣的集羣? – Marzy
這看起來非常類似於http://stackoverflow.com/questions/20533159/spacing-agents-in-netlogo-based-on-territory-size和http://stackoverflow.com/questions/20831832/define-home-區烏龜/和http://stackoverflow.com/questions/19326781/adding-patch-clusters-in-a-landscape和http://stackoverflow.com/questions/20336364/how-to-create-cluster-patches - 即-DO-不重疊之間,它們。我建議看看那些;他們應該幫助你解決你的問題和/或制定一個更具體的問題。請注意,在Stack Overflow上,您可以編輯自己的問題以改進它並添加更多詳細信息。 –
正如附註,你應該在'setup'結尾調用'reset-ticks',在'go'結尾調用'tick'。 –