Skip to content

Commit 7c9dda6

Browse files
committed
Added tests for Dijkstra's and A*
1 parent 07e7324 commit 7c9dda6

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

tests/test_search.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from jupyddl.heuristics import goal_count_heuristic, zero_heuristic
12
from jupyddl.automated_planner import AutomatedPlanner
23
from jupyddl.dijkstra import DijkstraBestFirstSearch
34
from jupyddl.a_star import AStarBestFirstSearch
@@ -7,14 +8,26 @@
78
import coloredlogs
89
import sys
910

11+
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
12+
1013
def test_searchDFS():
11-
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
1214
dfs = DepthFirstSearch(apla)
1315
_,ct = dfs.search()
1416
assert ct != 0
1517

1618
def test_searchBFS():
17-
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
1819
bfs = BreadthFirstSearch(apla)
1920
_,ct = bfs.search()
2021
assert ct != 0
22+
23+
def test_searchDijkstra():
24+
dijk = DijkstraBestFirstSearch(apla)
25+
res = dijk.search() # None, computation_time, opened_nodes(in this order)
26+
assert(res[1] != 0)
27+
assert(res[-1] >= 1)
28+
29+
def test_searchAStar():
30+
astar = AStarBestFirstSearch(apla, goal_count_heuristic)
31+
res = astar.search() # None, computation_time, opened_nodes(in this order)
32+
assert(res[1] != 0)
33+
assert(res[-1] >= 1)

0 commit comments

Comments
 (0)