为什么模型逐渐变慢?

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

我有这样的代码,一个代理搜索森林来摧毁它们,而另一个代理寻找空的草地,这意味着没有其他代理。该代码可以工作,但是每次滴答都会变慢。我确实相信 if 会给处理器带来负担,但是在整个运行过程中它应该同样增加负担。我的代码中有其他流程,但我得出的结论是,这个流程才是最重要的。

土地所有者代理

Objetivo = 要转换的目标补丁

森林# = 补丁的属性,它就是它所拥有的树冠

世界(地图)相当大。我仍然不明白为什么随着时间的推移它会变慢

ask landowner[ifelse patch-here = objetivo  
[ifelse any? neighbors with [Tipo-Cobertura = "Forest1"] [set objetivo min-one-of patches with [Tipo-Cobertura = "Forest1"][distance myself]]
  [ifelse any? neighbors with [Tipo-Cobertura = "Forest2"] [set objetivo min-one-of patches with [Tipo-Cobertura = "Forest2"][distance myself]]
    [ifelse any? neighbors with [Tipo-Cobertura = "Forest3" ] [set objetivo min-one-of patches with [Tipo-Cobertura = "Forest3"][distance myself]]
      [ifelse any? neighbors with [Tipo-Cobertura = "Forest4"][set objetivo min-one-of patches with [Tipo-Cobertura = "Forest4"][distance myself]]
        [if any? neighbors with [Tipo-Cobertura = "Forest5"] [set objetivo min-one-of patches with [Tipo-Cobertura = "Forest5"][distance myself]]]]]]][face objetivo fd 1]]


ask expansionist [ifelse patch-here = objetivo 
[if any? neighbors with [Tipo-Cobertura = "Grass" and (not any? neighbors with [es-bosque = 1])][set objetivo min-one-of patches with [Tipo-Cobertura = "Grass" and not any? neighbors with [es-bosque = 1] and empty = 1][distance myself]]] [face objetivo fd 1]]
netlogo patch
1个回答
4
投票

此模型中的土地覆盖是否随时间变化?在我看来,草的要求相当高,因为要测量到每个草斑的距离,而森林则细分为类别,因此距离只能测量到森林斑块的 1/5 左右。如果系统逐渐获得更多的草,它应该会减慢速度。无论如何,当您已经确定相邻补丁之一符合标准时,在具有大量补丁的系统中使用

min-one-of
并不是很好。除了 8 个相邻的补丁之外,您不需要对任何其他补丁进行采样。

尝试更换

set objetivo min-one-of patches with [Tipo-Cobertura = "Forest1"][distance myself]

set objetivo one-of neighbors with [Tipo-Cobertura = "Forest1"]

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