From d12a6c96a3a643de069372612dd3eed4487ee18a Mon Sep 17 00:00:00 2001 From: Max Zuo Date: Sat, 31 Aug 2024 23:33:25 -0400 Subject: [PATCH] Single rovers domain first draft --- planetarium/oracle.py | 9 ----- planetarium/oracles/rover_single.py | 2 +- tests/problem_fixtures.py | 63 +++++++++++++++++++++++++++++ tests/test_evaluate.py | 19 --------- tests/test_metric.py | 13 ------ 5 files changed, 64 insertions(+), 42 deletions(-) diff --git a/planetarium/oracle.py b/planetarium/oracle.py index 81e4489..7a08a9b 100644 --- a/planetarium/oracle.py +++ b/planetarium/oracle.py @@ -17,7 +17,6 @@ _fully_specify_gripper, _plan_gripper, ) -from .oracles.rover import _reduce_rover, _inflate_rover, _fully_specify_rover from .oracles.rover_single import _reduce_rover_single, _inflate_rover_single, _fully_specify_rover_single @@ -53,8 +52,6 @@ def reduce( return _reduce_blocksworld(graph) case "gripper": return _reduce_gripper(graph) - case "rover": - return _reduce_rover(graph) case "rover-single": return _reduce_rover_single(graph) case _: @@ -81,8 +78,6 @@ def inflate( return _inflate_blocksworld(scene) case "gripper": return _inflate_gripper(scene) - case "rover": - return _inflate_rover(scene) case "rover-single": return _inflate_rover_single(scene) case _: @@ -119,10 +114,6 @@ def fully_specify( reduced_init, reduced_goal, ) - case "rover": - reduced_init, fully_specified_goal = _fully_specify_rover( - *problem.decompose() - ) case "rover-single": reduced_init, fully_specified_goal = _fully_specify_rover_single( *problem.decompose() diff --git a/planetarium/oracles/rover_single.py b/planetarium/oracles/rover_single.py index 5e6df91..68759da 100644 --- a/planetarium/oracles/rover_single.py +++ b/planetarium/oracles/rover_single.py @@ -491,7 +491,7 @@ def _init_waypoint() -> list[int]: endpoints = {rover_map.graph.nodes()[e] for e in endpoints} - if not final_destination(): + if not final_pos: # rover doesn't need to be at a particular location, # check how many locations he can be at if len(endpoints) == 1: diff --git a/tests/problem_fixtures.py b/tests/problem_fixtures.py index 98afb6a..8c8fae3 100644 --- a/tests/problem_fixtures.py +++ b/tests/problem_fixtures.py @@ -1731,3 +1731,66 @@ def rover_single_line_fully_specified_2(): ) ) )""" + + +@pytest.fixture +def rover_single_line_fully_specified_3(): + return """ + (define (problem rover) + (:domain rover-single) + (:objects + site1 site2 site3 site4 site5 site6 - waypoint + store1 store2 - store + rgb - mode + camera1 camera2 camera3 - camera + objective1 objective2 objective3 - objective + ) + (:init + (can_traverse site1 site2) + (can_traverse site2 site3) + (can_traverse site3 site4) + (can_traverse site4 site5) + (can_traverse site5 site6) + (visible site1 site2) + (visible site2 site3) + (visible site3 site4) + (visible site4 site5) + (visible site5 site6) + (at_rover site1) + (available) + (at_lander site6) + (empty store1) + (full store2) + (supports camera1 rgb) + (supports camera2 rgb) + (supports camera3 rgb) + (visible_from objective1 site5) + (channel_free) + ) + (:goal + (and + (can_traverse site1 site2) + (can_traverse site2 site3) + (can_traverse site3 site4) + (can_traverse site4 site5) + (can_traverse site5 site6) + (visible site1 site2) + (visible site2 site3) + (visible site3 site4) + (visible site4 site5) + (visible site5 site6) + (available) + (at_rover site6) + (at_lander site6) + (empty store1) + (full store2) + (supports camera1 rgb) + (supports camera2 rgb) + (supports camera3 rgb) + (visible_from objective1 site5) + (channel_free) + (have_image objective1 rgb) + (communicated_image_data objective1 rgb) + ) + ) + )""" \ No newline at end of file diff --git a/tests/test_evaluate.py b/tests/test_evaluate.py index 11df4d9..dcdc27e 100644 --- a/tests/test_evaluate.py +++ b/tests/test_evaluate.py @@ -9,8 +9,6 @@ blocksworld_missing_ontables, blocksworld_fully_specified, blocksworld_invalid_1, - rover_line_fully_specified_1, - rover_line_fully_specified_2, ) @@ -283,23 +281,6 @@ def test_evaluate_inequivalent( False, ) - def test_unsolveable_rovers( - self, - rover_line_fully_specified_1, - rover_line_fully_specified_2, - ): - """ - Test if the evaluation of PDDL problem descriptions is correct. - """ - assert planetarium.evaluate( - rover_line_fully_specified_1, - rover_line_fully_specified_1, - ) == (True, True, True) - assert planetarium.evaluate( - rover_line_fully_specified_2, - rover_line_fully_specified_2, - ) == (True, False, False) - class TestUnsupportedDomain: """ diff --git a/tests/test_metric.py b/tests/test_metric.py index 123ff4e..cdb7203 100644 --- a/tests/test_metric.py +++ b/tests/test_metric.py @@ -22,8 +22,6 @@ blocksworld_fully_specified, gripper_fully_specified, gripper_no_robby, - rover_line_fully_specified, - rover_line_fully_specified_1, ) @@ -290,14 +288,3 @@ def test_blocksworld_equivalence( assert not metric.equals(p2, p1, is_placeholder=True) assert not metric.equals(p2, p1, is_placeholder=False) - def test_rover_equivalence(self, rover_line_fully_specified_1): - """Test the equivalence of rover problems.""" - p1 = builder.build(rover_line_fully_specified_1) - p2 = oracle.fully_specify(p1) - - assert metric.equals(p1.init(), p2.init(), is_placeholder=True) - assert metric.equals(p1.init(), p2.init(), is_placeholder=False) - assert metric.equals(p1.goal(), p2.goal(), is_placeholder=True) - assert metric.equals(p1.goal(), p2.goal(), is_placeholder=False) - assert metric.equals(p1, p2, is_placeholder=True) - assert metric.equals(p1, p2, is_placeholder=False)