【发布时间】:2021-10-25 04:39:53
【问题描述】:
我正在尝试通过这本书来学习基于代理的建模,但是我在实现第 10 章中的模型时遇到了麻烦。已经发布了一个关于这个模型的问题,但是这本书的第二版已经发布了发布,我认为模型已经改变,因为效用函数和之前提出的问题中的一些值不匹配。
我的模型确实有效,但是当我尝试在 BehaviourSpace 中运行实验时,我的结果与书中的结果大不相同。有没有其他人尝试过这个模型或者可以发现其他错误?
谢谢!
我的代码:
globals [ decision-time-horizon ]
turtles-own [ location wealth ]
patches-own [ annual-profit annual-risk ]
to setup
clear-all
set decision-time-horizon 5
ask patches
[
set annual-profit random-exponential 5000
set annual-risk 0.01 + random-float ( 0.1 - 0.01 )
set pcolor scale-color grey annual-profit 1 5000
]
create-turtles 25
[
setxy random-xcor random-ycor
move-to one-of patches with [not any? turtles-here]
set wealth 0
set color red
set shape "house"
]
reset-ticks
end
to go
ask turtles
[
reposition
pen-down
]
tick
end
to reposition
let potential-destinations neighbors with
[ not any? turtles-here ]
set potential-destinations
( patch-set potential-destinations patch-here)
; identify the best one of the destinations
let best-patch max-one-of potential-destinations
[ utility-for myself]
; now move there
move-to best-patch
end
to-report utility-for [ a-turtle ]
; a patch-context reporter that calculates utility
; for an investor turtle in this patch
; first get the turtle's current wealth
let turtles-wealth [ wealth ] of a-turtle
; then calculate the investor's utility given by its wealth and
; relevant patch variables
let utility ( turtles-wealth + ( annual-profit * decision-time-horizon )) * (( 1 - annual-risk ) ^ decision-time-horizon)
report utility
end
【问题讨论】:
标签: netlogo agent-based-modeling