Netlogo 如何报告链接之间的距离,并使用代码中其他计算报告的值?

Netlogo 如何报告链接之间的距离,并使用代码中其他计算报告的值?,netlogo,Netlogo,我试图计算并报告NetLogo中特定代理集之间的距离(链接长度)?有没有办法将链接长度计算到列表中 代理的移动取决于距离(连接)值是否低于/高于阈值。但是,我很难将链接长度的值设置为可变连接。(最好在列表中)。我非常感谢你的帮助 globals[hourly-wage connection] breed[offices office] breed[employees employee] offices-own [ pay-high ;; 7 offices pay well pay-lo

我试图计算并报告NetLogo中特定代理集之间的距离(链接长度)?有没有办法将链接长度计算到列表中

代理的移动取决于距离(连接)值是否低于/高于阈值。但是,我很难将链接长度的值设置为可变连接。(最好在列表中)。我非常感谢你的帮助

globals[hourly-wage connection]
breed[offices office]
breed[employees employee]
offices-own [
  pay-high ;; 7 offices pay well
  pay-low  ;; 3 offices dont pay well
]
to setup 
  clear-all
    create-offices 10 [
    set size 1.0
    set color blue
    set shape "house"
    setxy random-xcor random-ycor
    ask offices [create-link-with one-of other offices] ;; undirected links
    ask links [set color red]
  ]

  create-employees 2 [
    set size 1
    set color brown
    set shape "person"
  ]
  set hourly-wage 20
end

;;;; 
 to go
  cal-dist
  ask employees [ 
    if connection > 15
   move-to one-of high-pay office
    if connection <= 15
    move-to one-of low-pay office
  ]
end

to cal-dist
  set connection [list print link-length] ;; 
  ask links [show link-length]
  set salary (hourly-wage * connection)   ;;; salary printed in a list
end
globals[小时工资连接]
办公室
品种[雇员]
办公室[
薪水高;办公室薪水高
薪水低;办公室薪水不高
]
设置
清除所有
创建办公室10[
设置大小为1.0
设置颜色为蓝色
定形“房子”
setxy随机xcor随机ycor
询问办公室[创建与其他办公室的链接];;无方向链接
询问链接[设置红色]
]
创建员工2[
1号套餐
设置颜色为棕色
设置形状“人”
]
设定时薪20元
结束
;;;; 
外带
卡尔区
询问员工[
如果连接>15
搬到一个高薪办公室

如果连接不能确切确定您在这里使用
连接
等做什么,但您可以使用
of
将任何链接变量放入列表中-例如:

to setup
  ca
  ; First create the agents
  crt 5 [
    while [ any? other turtles in-radius 5 ] [
      move-to one-of neighbors
    ]
    set color blue
    set shape "house"
  ]

  ; Once they're created, have them link with
  ; one of the other agents
  ask turtles [ 
    create-link-with one-of other turtles [
      set color red
    ]
  ]

  let link-lengths [ link-length ] of links

  print link-lengths

  reset-ticks
end

我不知道这是否真的回答了您的问题,因此您可能希望提供更多关于您试图通过这些链接实现的目标的详细信息。

因此,连接被定义为员工与所有办公室之间的关系,但是,一名员工有一个初始办公室位置。移动到特定办公室的决定将是取决于薪资和工作需求等@sly44-明白了。您可能希望编辑原始问题,以明确哪些代码不起作用-可能会给出一个员工预期行为的示例。请查看并可能查看关于的部分,以提高您的问题获得有用答案的机会。