Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Netlogo-标识代理集的子集_Netlogo - Fatal编程技术网

Netlogo-标识代理集的子集

Netlogo-标识代理集的子集,netlogo,Netlogo,我花了整个下午的时间试图用我的一部分代码来解决这个问题,但我似乎没有取得任何进展。基本上,我正在尝试在模型设置上创建一个社交网络。模型中的每个人都从他们附近的一组人开始附近的人。人们正是从这个集合中选择与谁联系: create-people population-size [ set people-nearby turtle-set other people in-radius neighborhood-radius ] to create-network let num-links

我花了整个下午的时间试图用我的一部分代码来解决这个问题,但我似乎没有取得任何进展。基本上,我正在尝试在模型设置上创建一个社交网络。模型中的每个人都从他们附近的一组人开始
附近的人
。人们正是从这个集合中选择与谁联系:

create-people population-size
[
  set people-nearby turtle-set other people in-radius neighborhood-radius
]

to create-network
  let num-links round (average-node-degree * population-size) / 2  

  while [ count links < num-links and count people with [length sort people-nearby > 0] > 0 ]

  [ ask one-of people
    [ *... initiate probabilistic link creation process...*
     create-unlink-with chosen-friend
出于某种原因,此错误不断出现: “预期输入为代理集,但得到了列表[(人员0)(人员1)(人员3)(人员4)]。”无论何时
与我的[not member?self][turtle set unlink neights]相邻的人
被调用

我查阅了这么多帖子,但似乎无法正确理解论点的形式,从而使其不再显示此错误


有人能帮我解决这个问题吗?(哦,这是我的第一篇帖子,如果我没有正确设置这个问题,请道歉)

当您提交代码时,请尝试提交重新创建问题所需的内容-查看,特别是帮助他人重现您的问题的部分。按原样,我认为您的问题来自使用
turtle set
。该原语主要用于组合代理集,而不是查询代理集。因此,在您的行中:

( turtle-set people-nearby with [ not member? self [ turtle-set unlink-neighbors ] of myself ] )
有一个与turtle set相关的语法问题。错误本身表明您没有返回agentset,而是返回了一个代理列表,这些代理的行为不同

如果我理解正确,您希望所有人都有一个变量,该变量包含半径范围内的所有人:“附近的人”。然后,您希望这些人与他们的“邻居”海龟建立链接。最后,您希望这些人更新他们的“附近的人”变量,以排除他们刚刚建立链接的人。下面是一些代码,其中包含注释,我尝试按照这些步骤操作-显然,您的变量会有所不同,但它可能会帮助您开始。如果需要澄清任何内容或我遗漏了某个步骤,请告诉我

breed [ people person ]
turtles-own [ people-nearby ]


to setup 
  ca
  reset-ticks
  create-people 70  [
    setxy (random 30 - 15) (random 30 - 15)
  ]

  ; do this after all turtles have spawned
  ask people [
    set people-nearby other people in-radius 3
  ]

end


to create-links

  let num-links 10

  ;; Create a temporary agentset out of turtles that have people nearby
  let turtles-with-neighbors turtles with [ any? people-nearby ]

  ; ask some number of the temporary agentset:
  ask n-of num-links turtles-with-neighbors [

    ;; This just makes it easy to identify the turtle that causes the link
    ask patches in-radius 3 [
      set pcolor white
    ]

    ; create a link to one of the nearby people
    create-link-to one-of people-nearby
    ; newly set people-nearby to only include turtles in radius
    ; that are not linked-to from the currently acting turtle
    set people-nearby other people in-radius 3 with [ not member? self [ out-link-neighbors ] of myself  ]
    ask people-nearby [ set size 0.5 ]
  ]

end

是的,我查看了这个线程,似乎无法解决如何阻止错误消息被我的代码调用。对此表示抱歉。非常感谢,Luke,很抱歉没有正确设置问题。我猜,鉴于我将
附近的人定义为
在前面设置radius 3中其他人附近的人,我想我可以调用该代理组重新定义新的
附近的人
,它排除了任何与代理人物有关联的人,即,
将附近的人与我的[非成员?自我[链接外邻居]设置在一起]
为什么这样做是错误的?无论如何,你的评论帮助解决了这个错误,所以谢谢你。现在,出于某种原因,人们正在连接到他们半径之外的其他人。不用担心!你的问题仍然有道理-这只意味着你的确切错误可能不是其他人得到的错误。至于“为什么是错误的,”我认为你的评论代码一点也没有错-你原来使用的
海龟集
的行有语法错误。最好说
把身边的人和我自己的[not member?self[out link neights]放在一起]
(我太简单了,对不起!)。您的连接错误可能是由于海龟移动、创建“附近的人”和创建链接的顺序造成的。请确保所有海龟在移动到下一个任务之前完成每个任务。
breed [ people person ]
turtles-own [ people-nearby ]


to setup 
  ca
  reset-ticks
  create-people 70  [
    setxy (random 30 - 15) (random 30 - 15)
  ]

  ; do this after all turtles have spawned
  ask people [
    set people-nearby other people in-radius 3
  ]

end


to create-links

  let num-links 10

  ;; Create a temporary agentset out of turtles that have people nearby
  let turtles-with-neighbors turtles with [ any? people-nearby ]

  ; ask some number of the temporary agentset:
  ask n-of num-links turtles-with-neighbors [

    ;; This just makes it easy to identify the turtle that causes the link
    ask patches in-radius 3 [
      set pcolor white
    ]

    ; create a link to one of the nearby people
    create-link-to one-of people-nearby
    ; newly set people-nearby to only include turtles in radius
    ; that are not linked-to from the currently acting turtle
    set people-nearby other people in-radius 3 with [ not member? self [ out-link-neighbors ] of myself  ]
    ask people-nearby [ set size 0.5 ]
  ]

end