|
| 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