【问题标题】:bathtub model sprout using decision rules使用决策规则的浴缸模型萌芽
【发布时间】:2017-03-28 17:54:47
【问题描述】:

netlogo 的新手在这里。我正在使用元胞自动机模拟洪水模型。这只是一个简单的 - 如果水 > 海拔,细胞应该被填充(改变颜色)或发芽。

对于一个虚拟代码,我正在尝试这样做:

to go
    ask patches with [pcolor != blue] ;remove ocean 
    water_rise
    tick
end

 to water_rise ; saturates cell
  if not any? turtles [
    ask patch x-breach y-breach [     ;;; This will be the breach patch, will start to fill at first tick, a specific location in my map
      set cell-storage elevation * fill-rate
    ]
  ]
  ask patches [
    ;;; This has a patch check if any neighbors have sprouted.
    ;;; If any have, that patch starts to fill.
    if any? neighbors4 with [ any? turtles-here ] [
       set cell-storage elevation * fill-rate
      let minv min [ cell-storage ] of patches
      let maxv max [ cell-storage ] of patches
      set pcolor scale-color green cell-storage 0 5 ;idea is to have a graduated color depending on fill stage
    ]
  ]
  ;;; Once all patches have had a chance this tick to fill,
  ;;; see if any are "full"
  ask patches [
    if cell-storage > elevation [
        ;; If the patch gets "full" and they have not already sprouted,     
    if not any? turtles-here [
      sprout 1 [
        set color yellow
        set size 1
        set shape "square"
      ]
  ]

]

] 结尾 提前致谢!

顺便说一句,我正在研究 DEM re:高程值。

我现在将填充率设置为 0.3 的滑块。

-南德

【问题讨论】:

  • Nandoarz - 您遇到了什么错误,或者您没有看到您希望看到的错误?
  • 嗨,卢克。似乎我无法正确设置起点,因为到处都在发芽。
  • 知道了。在这种情况下,您能否提供更多详细信息?照原样,我们看不到您在哪里定义了“x-breach”和“y-breach”。包含您的设置过程可能会有所帮助。
  • 这只是我预加载地图 308 和 -36 的随机坐标。 cell-storage 也是一个虚拟值,仅用于测试此代码。谢谢!
  • Nands- 我还是不太确定你到底想做什么。您是否试图让细胞填满然后“溢出”到相邻的细胞中?至于为什么每个细胞都发芽,这是因为在您的 water_rise 过程中,您正在使用 if any? neighbors4 ... 行查询 all 补丁。

标签: netlogo patch cellular-automata


【解决方案1】:

我对此进行了一些尝试,在我看来,您似乎希望您的起始补丁填满,并且一旦达到最大值,就开始涌入重复该过程的其他单元格。我认为主要问题是在您的water-rise 中,您要求所有海拔大于 -9999 的补丁首先调用starting-point 程序,然后如果它们有 any 具有高程的邻居小于单元存储。看来所有的补丁都满足这个条件,所以所有的补丁都会长出一只乌龟。

重新设计你的逻辑流程可能会更好,这样填充你的漏洞补丁就可以独立于其他补丁。比如:

to water_rise ; saturates cell
  if not any? turtles [
    ask patch 0 0 [     ;;; This would be your breach patch, will start to fill at first tick
      set cell-storage cell-storage + fill-rate
    ]
  ]
  ask patches [
    ;;; This has a patch check if any neighbors have sprouted.
    ;;; If any have, that patch starts to fill.
    if any? neighbors4 with [ any? turtles-here ] [    
      set cell-storage cell-storage + fill-rate        
    ]
  ]
  ;;; Once all patches have had a chance this tick to fill,
  ;;; see if any are "full"
  ask patches [
    if cell-storage > 0 [
      if cell-storage > 5 [              
        set cell-storage 5 
        ;; If the patch gets "full" and they have not already sprouted, sprout 1
        if not any? turtles-here [     
          sprout 1 [
            set color yellow
            set size 0.5
            set shape "circle"
          ]
        ]
      ]
      set pcolor cell-storage + 82
    ]
  ]
end

带有变量和设置的完整玩具模型here

显然,您需要修改起始补丁(为了方便和简单,我使用了 0 0)。此外,我还加入了fill-rate,作为一种减缓填充速度的方法,因为越来越多的补丁开始被填充。

【讨论】:

  • 感谢卢克!这很有帮助,尤其是填充率变量。我仍然很困惑为什么它没有从我想要的突破点开始。如果你介意,我可以给你整个剧本。谢谢!
  • 我很乐意看看。您的代码是否很长,或者您是否可以在上面编辑您的问题并在必要时进行编辑?
  • Nands 你能包括设置来显示你的变量定义吗?这将有助于了解为什么它没有从您的突破点开始 - 在我上面链接的模型中,您只需将 patch 0 0 编辑到您的突破点坐标,它就会从那里开始 - 这不能满足您的需求吗?此外,您的代码中存在一些错误 - 例如,我无法按原样运行它。例如。 ask patches with [pcolor != blue](你要他们做什么?)。
  • 嗨,卢克。这么晚才回复很抱歉。您的建议实际上有所帮助,我成功运行了我的模型。再次感谢!
猜你喜欢
  • 1970-01-01
  • 2019-03-04
  • 1970-01-01
  • 2012-03-28
  • 2019-02-05
  • 2016-10-27
  • 1970-01-01
  • 2017-10-13
  • 2013-12-12
相关资源
最近更新 更多