Skip to content

Commit 3de16f8

Browse files
committed
fix: Change destination_entity_ids type from list to set in path planning algorithms
1 parent 6af1ea5 commit 3de16f8

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

adf_core_python/core/component/module/algorithm/path_planning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_path(
3838

3939
@abstractmethod
4040
def get_path_to_multiple_destinations(
41-
self, from_entity_id: EntityID, destination_entity_ids: list[EntityID]
41+
self, from_entity_id: EntityID, destination_entity_ids: set[EntityID]
4242
) -> list[EntityID]:
4343
pass
4444

adf_core_python/core/gateway/component/module/algorithm/gateway_path_planning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def get_path(
7878
return entity_ids
7979

8080
def get_path_to_multiple_destinations(
81-
self, from_entity_id: EntityID, destination_entity_ids: list[EntityID]
81+
self, from_entity_id: EntityID, destination_entity_ids: set[EntityID]
8282
) -> list[EntityID]:
8383
arguments: dict[str, str] = {
8484
"From": str(from_entity_id.get_value()),

adf_core_python/implement/module/algorithm/a_star_path_planning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_path(
7070
return []
7171

7272
def get_path_to_multiple_destinations(
73-
self, from_entity_id: EntityID, destination_entity_ids: list[EntityID]
73+
self, from_entity_id: EntityID, destination_entity_ids: set[EntityID]
7474
) -> list[EntityID]:
7575
raise NotImplementedError
7676

adf_core_python/implement/module/algorithm/dijkstra_path_planning.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from __future__ import annotations
22

33
import heapq
4-
from typing import Dict, List, Tuple
54

65
from rcrs_core.entities.area import Area
7-
from rcrs_core.entities.entity import Entity
86
from rcrs_core.worldmodel.entityID import EntityID
97

108
from adf_core_python.core.agent.develop.develop_data import DevelopData
@@ -27,7 +25,7 @@ def __init__(
2725
super().__init__(
2826
agent_info, world_info, scenario_info, module_manager, develop_data
2927
)
30-
self.graph: Dict[EntityID, List[Tuple[EntityID, float]]] = {}
28+
self.graph: dict[EntityID, list[tuple[EntityID, float]]] = {}
3129
# グラフの構築
3230
for area in self._world_info.get_entities_of_types([Area]):
3331
if not isinstance(area, Area):
@@ -49,7 +47,7 @@ def calculate(self) -> PathPlanning:
4947

5048
def get_path(
5149
self, from_entity_id: EntityID, to_entity_id: EntityID
52-
) -> List[EntityID]:
50+
) -> list[EntityID]:
5351
# ダイクストラ法で最短経路を計算
5452
queue = []
5553
heapq.heappush(queue, (0, from_entity_id))
@@ -81,8 +79,8 @@ def get_path(
8179
return path[::-1]
8280

8381
def get_path_to_multiple_destinations(
84-
self, from_entity_id: EntityID, destination_entity_ids: List[EntityID]
85-
) -> List[EntityID]:
82+
self, from_entity_id: EntityID, destination_entity_ids: set[EntityID]
83+
) -> list[EntityID]:
8684
open_list = [from_entity_id]
8785
ancestors = {from_entity_id: from_entity_id}
8886
found = False
@@ -124,7 +122,7 @@ def get_path_to_multiple_destinations(
124122

125123
return path
126124

127-
def is_goal(self, entity_id: EntityID, target_ids: List[EntityID]) -> bool:
125+
def is_goal(self, entity_id: EntityID, target_ids: set[EntityID]) -> bool:
128126
return entity_id in target_ids
129127

130128
def get_distance(self, from_entity_id: EntityID, to_entity_id: EntityID) -> float:

0 commit comments

Comments
 (0)