为什么我的 netlogo 模型中的刻度如此之快?

问题描述 投票:0回答:1

我不明白为什么我的 netlogo 模型中的刻度如此之快。以下是 to go 函数的代码片段:

to go
  every 1[
    create-food feed-rate [
      set shape "circle"
      set color rgb 255 0 0
      set size 1
      setxy (random-float (max-x - min-x) + min-x) (random-float (max-y - min-y) + min-y)
    ]
    ask patches with [  (pxcor >= min-x) and (pxcor <= max-x) and
      (pycor >= min-y) and (pycor <= max-y)] [
      set pcolor palette:scale-gradient [[78 155 178] [102 126 44]] total-ammonia 0 60
    ]

    if total-ammonia >= 30 [
      if random 10 < 5 [
        let fish-list sort fish
        let fish-pop-size length fish-list - 1
        let random-fish item random fish-pop-size  fish-list
        ask random-fish [
          die
        ]
      ]
    ]

    if total-ammonia > 5 [
      set total-ammonia total-ammonia - clean-rate
    ]

  ]

  ask fish[
    if any? other food in-radius (size)[
      set food-eaten food-eaten + 1
    ]
    ask other food in-radius (size) [
      set food-consumed food-consumed + 1
      set total-ammonia total-ammonia + 1
      die
    ]
  ]
  move-fish
  tick
end

当我运行模型时,它每秒会加速约 5k 到 10k 次。

我尝试将其设置为每 30 秒才滴答一次,但这不是我喜欢的解决方案。如果我能让滴答声减慢很多那就太好了。

simulation netlogo agent-based-modeling
1个回答
0
投票

当您调用

tick
时,刻度会增加。在您的情况下,这是在
go
的末尾,因此当您的
go
的所有命令都已执行时。因此,刻度增加的速度取决于
go
过程的计算复杂性。

如果您想增加一次执行所需的时间,您可以使用

wait
(请参阅此处)。如果您想更改所有程序的显示速度,请使用 NetLogo 界面顶部的速度滑块。

您可以在编程指南的“查看更新”部分找到更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.