我正在编写水管理模型。农民应该看看他们的行为在用水方面是否合作。农民的地表水(SW)和地下水(GW)的水平不同。根据受益者的期望,合作的初期水平。现在,我想在模型中让农民从以前的行为中更新行为。首先,行为被确定为合作或不合作。在下一个刻度中,农民应该考虑先前刻度中的行为来更改行为。
globals [TW well-depth Water-Availbility ]
Breed [farmers farmer]
farmers-own [ WA sw FW WR WD Logging salinity expectations benefit-out ]
patches-own [
GW wtd DWS]
to setup
clear-all
ask patches [ ifelse random 4 = 0 [
set dws distance-from-water-source + random-float 50
set WTD DWS / depth-WT + random-float 1
set GW Ground-water + random-float 5.005 + (100 / wtd)
set pcolor blue ]
[ set dws distance-from-water-source + random-float 100 + 35
set WTD DWS / depth-WT + 5 + random-float 5
set GW Ground-water + random-float 5.005 + (100 / wtd)
set pcolor red]
]
setup-farmers
reset-ticks
end
to setup-farmers
create-farmers num-farmers [move-to one-of patches
set shape "person"
set sw surface-water / (sum [DWS] of patches in-radius 1 / count patches in-radius 1) + random 100
SET WA sw + sum [gw] of patches in-radius 1 / count patches in-radius 1 + [gw] of self
set logging 100 / dws + 50 / wtd
set salinity .005 * dws + 0.005 * wtd
set WD DWS / minwater-req + 50
Set expectations 0.2
set benefit-out 0
set color Brown
if WTD = 0 [stop]
]
end
to go
ask farmers [
check-wa
watering-decisions
update-logging
update-salinity
update-wr
update-water
update-benefits
die-end
new-farmer
to-stop
]
tick
end
to check-wa
SET WA (sw / distance-from-water-source) + sum [gw] of patches in-radius 1 + [gw] of self ;+ random 5
end
to watering-decisions
if watering-decision = "social-behavior"
[ ifelse SW > WD [use-sw
set-wtd
set logging logging + logging / wtd
Set salinity salinity + 0.045 * wtd + random-float .05
Set benefit-out benefit-out + (Adjustment-factor / (logging + salinity))
set expectations expectations + benefit-out / 1000 + random-float 0.5
decide-behavior ]
[ ifelse random 2 = 1 [use-sw
set wtd wtd - 0.030 + random-float 0.005
set logging logging + logging / wtd
set salinity salinity + (salinity * wtd)/ 100
set benefit-out benefit-out + (Adjustment-factor / (logging + salinity))
set expectations expectations + benefit-out / 1000 + random-float 0.5
decide-behavior]
[use-Gw
set wtd wtd + 0.030 + random-float 0.005
set logging logging + logging / wtd
set salinity salinity + (salinity * wtd)/ 1000
Set benefit-out benefit-out + (Adjustment-factor / (logging + salinity))
set expectations expectations + benefit-out / 1000 + random-float 0.5
decide-behavior]] ]
end
to use-GW
set gw gw - random-float .001
set-wtd ; need to reconcile with WTD in above writen options.
Update-water
end
to use-SW
set sw sw - random-float .001
Update-water
end
to Update-water
set WA SW + Sum [GW] of patches in-radius 1 + [gw] of self
;set WA WA - random-float 0.0005
end
to die-end
if salinity >= 20 [die]
if wtd <= 0.5 [die]
if logging >= 50 [die]
end
to set-wtd
set wtd wtd + ( 0.0028 + random-float 0.0015 - random-float .0028)
ask patches in-radius 1 [ set wtd [wtd] of myself]
end
to new-farmer
if ticks > 0 and ticks mod 5 = 0 and benefit-out > sum [benefit-out] of farmers in-radius 1 / count farmers in-radius 1
[hatch 1]
end
to
update-logging
ifelse random 4 = 1 [set wtd wtd + random-float 0.0042
set logging logging - 0.01]
[ set WTD WTD - random-float 0.0042
set logging logging + random-float 0.022]; linked with annual increas in rainfall every 1 out of 5 years
end
to update-salinity
ifelse random 4 = 1
[set salinity salinity + random 0.05]
[set salinity salinity - random 0.05]
end
to update-wr
set wd wd + random-float .01
end
to update-benefits
set benefit-out benefit-out + random-float 2
end
to decide-behavior
ask farmers [ ifelse expectations >= (sum [expectations] of farmers in-radius 1 / count farmers in-radius 1)
[ behave-cooperatively]
[ behave-selfishly]]
end
to behave-cooperatively
ifelse wd < sw [ ifelse random 3 <= 1 [use-gw]
[use-sw] set benefit-out benefit-out + 0.5]
[ifelse random 2 = 1 [use-gw][use-sw] ]
end
to
behave-selfishly
Ifelse sw > WD [use-sw
set benefit-out benefit-out + 0.5
]
[use-GW
set benefit-out benefit-out + 0.5]
end
to to-stop
if not any? turtles [stop]
end
预先感谢您的帮助。