Skip to content

Commit

Permalink
Single rovers domain first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
maxzuo committed Sep 1, 2024
1 parent 5415446 commit d12a6c9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 42 deletions.
9 changes: 0 additions & 9 deletions planetarium/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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 _:
Expand All @@ -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 _:
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion planetarium/oracles/rover_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
63 changes: 63 additions & 0 deletions tests/problem_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
)
)"""
19 changes: 0 additions & 19 deletions tests/test_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
blocksworld_missing_ontables,
blocksworld_fully_specified,
blocksworld_invalid_1,
rover_line_fully_specified_1,
rover_line_fully_specified_2,
)


Expand Down Expand Up @@ -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:
"""
Expand Down
13 changes: 0 additions & 13 deletions tests/test_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
blocksworld_fully_specified,
gripper_fully_specified,
gripper_no_robby,
rover_line_fully_specified,
rover_line_fully_specified_1,
)


Expand Down Expand Up @@ -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)

0 comments on commit d12a6c9

Please sign in to comment.