netlogo - 如何报告链接之间的距离并将报告的值用于代码中的其他计算?
问题描述
我正在尝试计算和报告 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
解决方案
不完全确定您在这里尝试使用 etc 做什么,但您可以使用- 例如connection
将任何链接变量放入列表中: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
我不知道这实际上回答了您的问题,因此您可能想提供更多详细信息,说明您要通过这些链接完成的工作。
推荐阅读
- jquery - 使用 deferred 获取列表项
- colors - 颤振十六进制代码
- html - 如何在spring-boot应用程序中显示下载的html文件
- jmeter - Jmeter启动问题
- bash - 根据电池状态、时间、百分比在 shell 提示中动态使用颜色
- postgresql - 计算两个日期之间每个月的天数 - postgresql
- typescript - Typescript:如何基于数据结构生成和打印 AST
- c# - 替换子类类型的 switch 语句
- python - 将索引从时间字符串转换为毫秒 - Pandas 时间序列
- function - Azure Function App Url 自行更改