如何在大空間尺度上加速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[ set color red]不幸的是,我不知道如何加快這段代碼。是否有解決方案在大空間尺度上快速計算最低成本路徑?
添加回答
舉報
0/150
提交
取消