Я использую примеры из книги Railsback и Grimm (основанное на агентах и индивидуальное моделирование). Я закодировал бизнес-модель с использованием инструкций из главы 10.4. Я могу успешно настроить модель, однако, когда я нажимаю на кнопку ходу, я получаю сообщение об ошибкеКод бизнес-модели Netlogo в главе 10. 4 моделей Railsback и Grimm, на основе агентов и отдельных моделей
"this code can't be run by a patch
error while turtle 3 running UTILITY-FOR
called by procedure REPOSITION
called by procedure GO
called by Button 'go'"
Это мой код
patches-own
[
annual-profit
business-risk
]
turtles-own
[
wealth
]
to setup
clear-all
;initializing the profit
ask patches
[
set annual-profit random 1000
set business-risk 1 - risk-probability
set pcolor scale-color green annual-profit 0 1000
]
crt 5 ; created five business spots for test
[
setxy random-xcor random-ycor
set shape "house"
set color red
set wealth random 10000]
reset-ticks
end
to go
ask turtles [reposition]
tick
end
to reposition
let potential-destinations neighbors with
[not any? turtles-here]
;adding the current patch to the potential-destinations
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 turtle "a-turtle" in this patch
; first get the turtle's wealth
let turtles-wealth [wealth] of a-turtle
let profit [annual-profit] of patch-here
let risk [business-risk] of patch-here
; then calculate turtles's utility given its wealth and
; relevant variables
let utility (turtles-wealth + profit * 5) * (risk^ticks)
report utility
end
Я сегодня посмотрю на книгу. Но мой первый комментарий заключается в том, что вы передаете конкретную черепаху процедуре «служебная программа», но вы не говорите ей, какие патчи искать (потенциальные направления). И черепаха не делает «спросить», поэтому «патч-здесь» на самом деле не имеет смысла в утилите. – JenB