Skip to content

Commit 49e2088

Browse files
authored
Merge pull request #62 from APLA-Toolbox/improve-coverage
Improve coverage on search algorithms #20
2 parents bf01626 + 17afd1e commit 49e2088

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

tests/test_dfs.py

Whitespace-only changes.

tests/test_main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import os

tests/test_search.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from jupyddl.heuristics import goal_count_heuristic, zero_heuristic
2+
from jupyddl.automated_planner import AutomatedPlanner
3+
from jupyddl.dijkstra import DijkstraBestFirstSearch
4+
from jupyddl.a_star import AStarBestFirstSearch
5+
from jupyddl.bfs import BreadthFirstSearch
6+
from jupyddl.dfs import DepthFirstSearch
7+
from os import path
8+
import coloredlogs
9+
import sys
10+
11+
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
12+
13+
14+
def test_searchDFS():
15+
dfs = DepthFirstSearch(apla)
16+
res = dfs.search()
17+
assert res[1] != 0 # Path, computation time, opened nodes
18+
19+
20+
def test_searchBFS():
21+
bfs = BreadthFirstSearch(apla)
22+
res = bfs.search() # Path, computation time, opened nodes
23+
assert res[1] != 0
24+
25+
26+
def test_searchDijkstra():
27+
dijk = DijkstraBestFirstSearch(apla)
28+
res = dijk.search() # Goal, computation_time, opened_nodes(in this order)
29+
assert res[1] != 0 # Assert that it took some time to compute
30+
assert res[-1] > 0 # Assert that it visited some nodes
31+
32+
33+
def test_searchAStar():
34+
astar = AStarBestFirstSearch(apla, apla.available_heuristics["goal_count"])
35+
res = astar.search() # Goal, computation_time, opened_nodes(in this order)
36+
assert res[1] != 0 # Assert that it took time to compute
37+
assert res[-1] > 0 # Assert that it visited at least one node

0 commit comments

Comments
 (0)