AtsushiSakai / AtsushiSakai/PythonRobotics
[Optimization] Enhancing D* Lite performance using heapq and lazy deletion
- 主要言語
- Python
- スター
- 30.5k
- フォーク
- 7.4k
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 3
説明
Hi,
The current implementation of the D* Lite algorithm in `PathPlanning/DStarLite` uses a standard Python list for the priority queue `U`, which is sorted using `.sort()` during every `update_vertex` and `compute_shortest_path` call. This leads to a time complexity of approximately $O(n \log n)$ for queue operations in each iteration.
I have developed an optimized version that utilizes a **Min-Heap** (`heapq`) and an **Entry Finder** dictionary to implement **Lazy Deletion**. This reduces the complexity of priority queue updates to $O(\log n)$ and lookups to $O(1)$.
### Reason for Change
1. **Scalability:** The current sorting-based approach becomes significantly slow as the grid size increases or when the map has high-frequency obstacle updates.
2. **Efficiency:** Using `heapq` with a dictionary for node tracking is the standard, high-performance way to implement incremental search algorithms.
### Proposed Changes
* Replace the `list.sort()` mechanism with `heapq`.
* Introduce an `entry_finder` to handle node priority updates efficiently.
* Maintain consistency in the animation logic with the existing implementation.
I have already implemented and tested these changes locally and would like to submit a Pull Request.
コントリビューションガイド
調査の方向性
PathPlanning/DStarLite から始め、update_vertex と compute_shortest_path の実行中にリスト U がどのようにソートされるかを調べる。既存のキューの動作を Python の heapq および提案されている entry_finder による遅延削除アプローチと、アニメーションロジックを含めて比較する。完了の条件は、既存の D* Lite の動作とアニメーションを維持しながら、キューの更新でリストの繰り返しソートを避けることである。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- robotics
- issue の種類
- リファクタリング
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100