【问题标题】:ask one agent set to get a value from another agent set要求一个代理集从另一个代理集获取值
【发布时间】:2014-12-16 13:19:19
【问题描述】:

我的卖家使用此代码设置 trade_Price:

ask buyers  [ ask sellers [if any? buyers-here [ if seller_Price <= [buyer_Price] of myself 
       [ set trade_Price  seller_Price + random ([buyer_Price] of myself - seller_Price) ]]]] 

如果我的买家在同一补丁中有卖家,我希望他们也采用相同的 trade_Price。(如果有的话?卖家在这里)。我这样编码:

ask sellers [ ask buyers [if any? sellers-here [set trade_Price ( [trade_Price] of myself )]]]

我认为它的代码错误,因为我从我的代理夫妇那里得到了不同的 trade_Price 。 你知道我该如何设置吗? 最好的问候

【问题讨论】:

    标签: netlogo agents


    【解决方案1】:

    据我所知,您正在尝试这样的事情:

    ask buyers [
      let candidate one-of sellers-here
      if candidate != nobody [
        set trade_Price [trade_Price] of candidate
      ]
    ]
    

    请注意,这里没有ask sellers。您只希望每个买家每次通过 go 运行一次。

    请注意,如果补丁上有多个卖家,one-of sellers-here 会随机挑选一个。

    【讨论】:

    • 谢谢,它运行了:) 我还有一个问题。在某些补丁中,我有没有买家的“孤独”卖家或没有卖家的孤独买家。在这种情况下,我对其进行编码,以便他们的 trade_Price 为 0。在图中我想显示 trade_Price。我这样编码: plot mean [trade_Price] of turtles 将计算 trade_Price 是 0 还是?我希望它只计算大于 0 的 trade_Price。如何在绘图中对其进行编码?
    • 如果我的回答有效,那么您可以通过接受它来感谢我(使用旁边的大复选标记)。要提出新问题,请打开一个新问题。
    • 我在 90 分钟内只能问一个问题 :(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-10
    • 1970-01-01
    • 2014-04-25
    • 1970-01-01
    相关资源
    最近更新 更多