I am trying to learn agent-based modeling with this book, but I'm having troubles implementing the model from chapter 10. There has already been posted a question about this model, but a second edition of the book has since been released and I think the model has changed since the utility function and some values from the previously asked question don't match up.
My model does work, but when I try running the experiments in BehaviourSpace my results are widely different from those in the book. Has anyone else tried this model or can spot other mistakes?
Thanks!
My code:
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