netlogo tie-mode "fixed"无法维持中等程度图中的链路长度

标签 netlogo fixed tie

我正在尝试创建一个作为“静态”单元在环境中移动的网络,即除了整体的位置和方向之外,模拟中没有任何变化,各个海龟相对于彼此的位置和方向是由他们的链接固定。海龟通过无向链接进行连接,这些链接被捆绑并设置为“固定”捆绑模式。

问题是在某些情况下链接无法保持固定并且链接长度开始改变。最初我注意到,当平均网络度相对较低或网络是完整图时,tie 原语起作用。然而,当创建链接以生成适度连接的图形时,海龟之间的链接长度开始发生变化。经过进一步的实验,我可以创建一个具有相同数量的链接和海龟但具有不同配置的网络,即网络结构不同,有时会保持位置和链接长度,但在其他情况下无法做到这一点。

无论网络的连接方式或网络配置如何,如何使网络作为一个单元移动?请参阅下面的示例代码,我在最后添加了代码,您可以在其中运行具有 6 个海龟和 6 个链接的网络的多个配置来亲自查看问题,尝试运行至少六次迭代。谢谢!

这会产生一个作为一个单元移动的网络

to setup
create-turtles 10
ask turtles [fd 2]

ask turtles [create-links-with other turtles [tie] ]

ask links [set tie-mode "fixed"]
reset-ticks 

create-turtles 10
ask turtles [fd 2]
ask turtles [create-links-with other turtles [tie] ]
ask links [set tie-mode "fixed"]
reset-ticks 
end

to go
ask turtles [lt 1 fd 1]
end

这会产生一个网络,其链路仍然绑定(bind)并设置为绑定(bind)模式“固定”,但更改其链路长度。要求终止的链接越多,链接长度变化就越大。

to setup
clear-all
create-turtles 10
ask turtles [fd 2]
ask turtles [create-links-with other turtles [tie] ]
ask links [set tie-mode "fixed"]
ask one-of links [die]
reset-ticks 
end

to go
ask turtles [lt 1 fd 1]
end

这里是显示链接长度更改的特定实例的附加代码。当“use-seed-from-user”按钮提示时,请输入种子 659269695。如果代码笨重,请道歉,第一次使用随机种子。 “打印长度”按钮用于确认长度变化。

;USE seed: 659269695

to use-new-seed
let my-seed new-seed            ;; generate a new seed
output-print word "Generated seed: " my-seed  ;; print it out
random-seed my-seed             ;; use the new seed
reset-ticks
end

;; Use a seed entered by the user
to use-seed-from-user
loop [
let my-seed user-input "Enter a random seed (an integer):"
carefully [ set my-seed read-from-string my-seed ] [ ]
ifelse is-number? my-seed and round my-seed = my-seed [
  random-seed my-seed ;; use the new seed
  output-print word "User-entered seed: " my-seed  ;; print it out
  reset-ticks
  stop
] [
  user-message "Please enter an integer."
]
]

end

to setup
clear-all
create-turtles 6 
ask turtles [
fd 5
set shape "circle"
set size 1
set color yellow
if count links < 7 [ask one-of turtles [create-link-with one-of other turtles 
[tie]]]]
reset-ticks
end

to go
ask turtles [lt 1 fd 1]
end

to print-lengths
print sort-by < [precision link-length 2] of links 
end

最佳答案

我稍微修改了您的代码,以便 go 过程包括断开链接。我还摆脱了 tie-mode 的显式设置,因为这是通过将链接设置为 tie 并添加 tick 来完成的,这样我就可以阴谋。所以代码如下所示:

to setup
  clear-all
  create-turtles 10 [fd 2]
  ask turtles [create-links-with other turtles [tie] ]
  reset-ticks 
end

to go
  ask one-of links [die]
  ask turtles [lt 1 fd 1]
  tick
end

据我所知,海龟作为一个整体移动,直到它因失去链接而 splinter 。

我添加了一个链接平均[链接长度]的监视器,我认为这是您要问的问题,也是相同计算的图。是的,平均链接长度确实会发生变化,但请记住,链接的长度并不完全相同。如果较长的一只死亡,那么平均长度就会减少,如果较短的一只死亡,那么平均长度就会增加。剧情有点跑偏,但直到支离 splinter 之前基本都是平淡的。

关于netlogo tie-mode "fixed"无法维持中等程度图中的链路长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54814174/

相关文章:

html - 如果鼠标在固定 block 上方,则滚动不起作用

c++ - 在 C++ 中解包嵌套元组

c++ - 输出没有临时的返回对

netlogo - 在 Netlogo 中设置补丁以减少彼此的值

netlogo - 如何使用 NetLogo 发送参数?

javascript - CSS/JS 仅使其中一个 div 调整大小/滚动到固定页脚

javascript - 在具有属性表布局 : fixed 的表中调整窗口大小时更改宽度

c++ - 使用 std::tie 作为循环目标的范围

algorithm - 具有离散 Action 的连续状态空间的强化学习(在 NetLogo 中)

string - 如何修剪 NetLogo 中的空格