NETLOGO:最近3个刻度中存储和使用变量的值 [英] NETLOGO: Storing and using the value of a variable in the last 3 ticks
问题描述
我正在尝试为股票市场建模.我正在尝试给代理商一种特定的行为,以他们对价格的预测为基础. 因此,基本上,每个代理商都可以预测股票的价格.在设置过程中,将随机的预测价格分配给每个代理商.随着时间的流逝,预计价格应按以下方式计算: 最近3个周期的预测价格总计/3
I am trying to model a stock market. I am trying to give agents a certain kind of behaviour to base their prediction of the prices on. So basically, every agent predicts the price of the share. In the Setup procedure, a random predicted price is assigned to each agent. As the time passes, the predicted price is supposed to be calculated as follows: total of predicted price of the last 3 periods / 3
我不知道该如何解决这个问题.我尝试使用最后一个命令,但是它不起作用.我当时正在考虑制作一种矢量,但我做不到.有线索吗?
I don't know how to approach this issue. I tried using the last command but it does not work. I was thinking about making a sort of vector but I couldn't do so. Any leads?
这是我到目前为止尝试过的:
This is what I have tried so far:
ask turtles [
set pre-price (pre-price + last [pre-price] of turtles + last [last [pre-price] of turtles] of turtles) / 3 ]
end
最后一条命令无法正常运行,因为我试图手动计算结果,并且它们与该命令不一致.有什么想法吗?
The last command does not work as I want it to work because I have tried to manually calculate the results and they don't reconcile with this command. Any idea on how to go about it?
谢谢!
推荐答案
这实际上是一个非常有趣的错误.
This is actually a very interesting bug.
问题在于,在您的海龟看涨期权中,您假设所有海龟的预价"都是静态的.但是,对于每个代理,他们都在分配变量.
The issue is that inside your turtle call, you assume all the turtles "pre-price" is static; however, with each agent, they are assigning the variable.
我建议引入另一个变量,该变量显式存储每个刻度的价格(使用矩阵/嵌套列表)
I'd suggest to introduce another variable which explicitly stores the pre-prices for each tick (using a matrix/nested list)
这篇关于NETLOGO:最近3个刻度中存储和使用变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!