如何在大空间尺度上加速A *算法?

如何在大空间尺度上加速A *算法?

http://ccl.northwestern.edu/netlogo/models/community/Astardemo,我通过使用网络中的节点来定义最低成本路径来编码A *算法。代码似乎有效,但是当我在大空间尺度上使用它时它太慢了。我的景观有1000个补丁x 1000个补丁,1个补丁= 1个像素。即使我减少400补丁x 400补丁1补丁= 1像素,它仍然太慢(我不能修改我的景观低于400补丁x 400补丁)。这是代码:

to find-path [ source-node destination-node] let search-done? falselet search-path []let current-node 0set list-open []set list-closed []  let list-links-with-nodes-in-list-closed []let list-links []set list-open lput source-node list-openwhile [ search-done? != true][    ifelse length list-open != 0[
  set list-open sort-by [[f] of ?1 < [f] of ?2] list-open 
  set current-node item 0 list-open 
  set list-open remove-item 0 list-open 
  set list-closed lput current-node list-closed
  ask current-node
  [  
    if parent-node != 0[
    set list-links-with-nodes-in-list-closed lput link-with parent-node list-links-with-nodes-in-list-closed 
    ]
    ifelse any? (nodes-on neighbors4) with [ (xcor = [ xcor ] of destination-node) and (ycor = [ycor] of destination-node)]
    [
      set search-done? true 
    ]
    [        
      ask (nodes-on neighbors4) with [ (not member? self list-closed) and (self != parent-node) ]  
      [  
        if not member? self list-open and self != source-node and self != destination-node
        [
          set list-open lput self list-open
          set parent-node current-node
          set list-links sentence (list-links-with-nodes-in-list-closed) (link-with parent-node)
          set g sum (map [ [link-cost] of ? ] list-links)
          set h distance destination-node 
          set f (g + h)
        ]
      ]
    ]
  ]][
  user-message( "A path from the source to the destination does not exist." )
  report []
 ]]set search-path lput current-node search-pathlet temp first search-pathwhile [ temp != source-node ][
 ask temp[

不幸的是,我不知道如何加快这段代码。是否有解决方案在大空间尺度上快速计算最低成本路径?

非常感谢您的帮助。


慕盖茨4494581
浏览 1047回答 3
3回答
打开App,查看更多内容
随时随地看视频慕课网APP