11from jupyddl .automated_planner import AutomatedPlanner
2- from jupyddl .dijkstra import DijkstraBestFirstSearch
2+ from jupyddl .dijkstra import DijkstraBestFirstSearch , zero_heuristic
33from jupyddl .a_star import AStarBestFirstSearch
44from jupyddl .bfs import BreadthFirstSearch
55from jupyddl .heuristics import BasicHeuristic , DeleteRelaxationHeuristic
@@ -37,6 +37,33 @@ def test_search_dijkstra():
3737 assert res [- 1 ] > 0 # Assert that it visited some nodes
3838
3939
40+ def test_search_dijkstra_no_path ():
41+ apla = AutomatedPlanner (
42+ "pddl-examples/vehicle/domain.pddl" , "pddl-examples/vehicle/problem.pddl"
43+ )
44+ dijk = DijkstraBestFirstSearch (apla )
45+ res = dijk .search () # Goal, computation_time, opened_nodes(in this order)
46+ assert not res [0 ]
47+
48+
49+ def test_search_dfs_no_path ():
50+ apla = AutomatedPlanner (
51+ "pddl-examples/vehicle/domain.pddl" , "pddl-examples/vehicle/problem.pddl"
52+ )
53+ dfs = DepthFirstSearch (apla )
54+ res = dfs .search () # Goal, computation_time, opened_nodes(in this order)
55+ assert not res [0 ]
56+
57+
58+ def test_search_bfs_no_path ():
59+ apla = AutomatedPlanner (
60+ "pddl-examples/vehicle/domain.pddl" , "pddl-examples/vehicle/problem.pddl"
61+ )
62+ bfs = BreadthFirstSearch (apla )
63+ res = bfs .search () # Goal, computation_time, opened_nodes(in this order)
64+ assert not res [0 ]
65+
66+
4067def test_search_astar_basic ():
4168 apla = AutomatedPlanner (
4269 "pddl-examples/dinner/domain.pddl" , "pddl-examples/dinner/problem.pddl"
@@ -48,12 +75,16 @@ def test_search_astar_basic():
4875 assert res [- 1 ] > 0 # Assert that it visited at least one node
4976
5077
51- def test_search_astar_delete_relaxation ():
78+ def test_search_astar_basic_no_path ():
5279 apla = AutomatedPlanner (
53- "pddl-examples/dinner /domain.pddl" , "pddl-examples/dinner /problem.pddl"
80+ "pddl-examples/vehicle /domain.pddl" , "pddl-examples/vehicle /problem.pddl"
5481 )
55- heuristic = DeleteRelaxationHeuristic (apla , "delete_relaxation/h_max " )
82+ heuristic = BasicHeuristic (apla , "basic/goal_count " )
5683 astar = AStarBestFirstSearch (apla , heuristic .compute )
5784 res = astar .search () # Goal, computation_time, opened_nodes(in this order)
58- assert res [1 ] != 0 # Assert that it took time to compute
59- assert res [- 1 ] > 0 # Assert that it visited at least one node
85+ assert not res [0 ]
86+
87+
88+ def test_zero_heuristic ():
89+ assert zero_heuristic () == 0
90+
0 commit comments