Netlogo:当全局对于 X 个刻度保持不变时停止模型
Netlogo: stopping model when global is constant for X amount of ticks
目前我正在构建一个关于意见动态的模型,并希望当某个全局变量 global-participation-rate
在 X 个滴答数内保持不变时模型自动停止。我可能应该包括
之类的内容
if stop-ticking? [stop]
在我的程序中。报告看起来像这样:
to-report stop-ticking?
ifelse (??) = ?? [report true] [report false]
end
我应该使用什么代码来检查全局是否在一定数量的滴答中保持不变?
您需要一个全局变量来表示参与率或总转化率等等。然后在你的传播过程之后,你做一些像 let new-adopters <calculation>
和 if-else new-adopters = total-adopters [stop] [set total-adopters new-adopters]
如果需要比较多个时间点,则需要创建一个列表而不是一个简单的值并将新值添加到列表的末尾并检查列表的末尾是否都是相同的数字.
最简单的方法是添加一个新的全局变量来保持计数。例如,(将 global-participation-rate
缩写为 gpr
):
globals [gpr ct-gpr]
to update-gpr
let old-gpr gpr ;store old value
set gpr get-gpr ;compute new value
;increment or reset the counter:
set ct-gpr ifelse-value (gpr != old-gpr) [1] [1 + ct-gpr]
end
目前我正在构建一个关于意见动态的模型,并希望当某个全局变量 global-participation-rate
在 X 个滴答数内保持不变时模型自动停止。我可能应该包括
if stop-ticking? [stop]
在我的程序中。报告看起来像这样:
to-report stop-ticking?
ifelse (??) = ?? [report true] [report false]
end
我应该使用什么代码来检查全局是否在一定数量的滴答中保持不变?
您需要一个全局变量来表示参与率或总转化率等等。然后在你的传播过程之后,你做一些像 let new-adopters <calculation>
和 if-else new-adopters = total-adopters [stop] [set total-adopters new-adopters]
如果需要比较多个时间点,则需要创建一个列表而不是一个简单的值并将新值添加到列表的末尾并检查列表的末尾是否都是相同的数字.
最简单的方法是添加一个新的全局变量来保持计数。例如,(将 global-participation-rate
缩写为 gpr
):
globals [gpr ct-gpr]
to update-gpr
let old-gpr gpr ;store old value
set gpr get-gpr ;compute new value
;increment or reset the counter:
set ct-gpr ifelse-value (gpr != old-gpr) [1] [1 + ct-gpr]
end