【问题标题】:ASK expected input to be an agent or agentset but got NOBODY insteadASK 期望输入是代理或代理集,但得到 NOBODY
【发布时间】:2016-11-24 10:16:59
【问题描述】:

在我的研究中,我试图建立一个模拟真实工作环境的模拟,目的是创造有关如何让人们在工作中感觉更好的知识。 特别是,我正在模拟一个人们为多个团队工作的场景(您一次只从事一个项目吗?很多人不...)。为此,我正在使用 NetLogo。

我在向自定义链接海龟集的特定代理询问时遇到问题。关键是它有时会报告一个错误,说“ASK 期望输入是一个代理或代理集,但没有得到 NOBODY”,但它不应该在没有代理存在的情况下到达那个“ASK”!我做错了什么?

函数如下:

to TeamRecruiting
  ;; I ask non-complete teams to...
  ask teams with [ teamsize != (count membership-neighbors) ]
  [
    ;; ... count how many individuals they have...
    let actualteammembers count membership-neighbors
    ;; ... to save locally how many individuals they can share...
    let teamoverlap overlap
    ;; ... their target size...
    let neededsize teamsize
    ;; ... and their identity.
    let teamwho who
    ;; then I ask those individuals that have not yet more things than they can handle...
    ask individuals with [ indMTM != (count membership-neighbors) ]
      [
      ;; ... to save locally who they are...
      let indwho who
      let createdalink 0
      ;; ... then if some conditions have been met ...
      if(some conditions)
        [
        ;; I create a link (of my specific type) with the team...
        create-membership-with team teamwho
        ;; I do the following because more than one individual could join the team teamwho in the same run of the function
        ask team teamwho [ set actualteammembers (actualteammembers + 1) ]
        set createdalink 1
        ]
      ;; if the association occurred, ...
      if(createdalink = 1)
        [
        ;; we ask all other teams to evaluate if the new connection violates their maximum overlap constraint between the team I am considering from the beginning of the function, and all other teams, in other words...
        ask teams with [ who != teamwho ]
        [
        let numpaths 0
        let team2who who
        ;; I count how many individuals say that they are shared by the two teams
        ask individuals
          [
          if((membership-neighbor? team teamwho) and (membership-neighbor? team team2who)) [ set numpaths (numpaths + 1) ]
          ]
        ;; ... and if the number of paths is more than the maximum allowed overlap...
        if(numpaths > teamoverlap)
          [
          ;; I take the connection away...
          ask membership teamwho indwho [ die ]
          ;; and I reduce the actual number of team members
          set actualteammembers (actualteammembers - 1)
          ]
        ]
      ]
    ]
  ]
end

感谢您的宝贵帮助!

【问题讨论】:

  • 注意:问题发生在:询问会员团队谁 indwho [ die ]

标签: netlogo


【解决方案1】:

我认为问题很可能出在你引用你要求死的链接的方式上。 membership 是一个无向链接,因此哪个代理是end1 哪个是end2 取决于创建代理的顺序。谁编号较小的一个是end1,另一个是end2。因此,如果团队代理是在单个代理之后创建的,则该特定链接将是 membership indwho teamwho。一般来说,使用 who numbers 是不好的做法,但如果您使用团队和个人代理本身而不是他们的 who 编号,也会出现同样的问题。

在使用无向链接方面比我有更多经验的人可能会在您不知道哪个代理更旧时如何轻松引用无向链接有更好的建议,但类似

ifelse (indwho < teamwho) [
ask membership indwho teamwho [ die ]
]
[
ask membership teamwho indwho [ die ]
]

应该可以。使用定向链接可以避免这个问题,因为创建者代理始终是 end1 而目标代理始终是 end2。因此,如果会员链接始终由个人创建,您将始终知道个人位于 end1。

希望这会有所帮助。 查尔斯

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-23
    • 2022-01-10
    • 1970-01-01
    • 1970-01-01
    • 2020-07-09
    • 1970-01-01
    • 2021-05-22
    相关资源
    最近更新 更多