Skip to content

Commit

Permalink
fixed rebase errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maxzuo committed Sep 1, 2024
1 parent f9bb582 commit 1323b5a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 11 deletions.
37 changes: 37 additions & 0 deletions planetarium/ASSUMPTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Assumptions

For each domain, the following assumptions are made regarding the types of problems evaluated.
We also assume that problems are solvable via the domain's actions.

## Blocksworld

Generally, since Blocks World has reversible actions, essentially all problems are evaluable.

`:init` conditions:
- No two blocks are on top of a single block
- No block is initialized on top of two blocks
- No loops of blocks are made
- Arm can only hold one block

## Grippers

Generally, since Grippers has reversible actions, essentially all problems are evaluable.

`:init` conditions:
- No double "typing" of objects (we don't using `:typing`, we use certain immutable predicates)
- All balls have only one location
- All grippers have only one location
- All grippers hold up to 1 ball

## Rover
Rover has the capability of being a much more complex domain, but for the purposes of this benchmark, we assume all problems will have symmetry of traversal.
This changes our `fullySpecify` function from essentially a multi-agent traveling salesman problem into simple pathfinding between two points.
Our goal is not to be *complete*, but to be *correct* for the problems we do support evaluating.

`:init` conditions:
- All objects have 1 type
- All rovers only have one location
- All landers only have one location
- If `can_traverse ?rover ?x ?y`, then `can_traverse ?rover ?y ?x`

**Note**: For the special case of up to 1 rover and up to 1 sample per analysis (rock, soil, imaging), we do not require symmmetry.
3 changes: 3 additions & 0 deletions planetarium/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def evaluate(
domain_str (str): The domain PDDL string.
is_placeholder (bool, optional): Whether or not to treat the ground truth
as a "placeholder" description. Defaults to False.
check_solveable (bool, optional): Whether or not to check if the problem
is solveable. Defaults to True. If False, the function will return
False for the solveable element.
Returns:
tuple: A tuple containing the following boolean elements:
Expand Down
7 changes: 5 additions & 2 deletions planetarium/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(
node: str,
name: str,
label: Label,
typing: str | None = None,
typing: set | str | None = None,
scene: Scene | None = None,
):
self.node = node
Expand Down Expand Up @@ -202,7 +202,10 @@ def _add_predicate(
predicate (dict): A dictionary representing the predicate.
scene (Scene, optional): The scene in which the predicate occurs.
"""
predicate.update({"scene": scene})
if scene:
predicate.update({"scene": scene})
if predicate in self.predicates:
return
predicate_name = self._build_unique_predicate_name(
predicate_name=predicate["typing"],
argument_names=predicate["parameters"],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import planetarium

from .test_oracle import (
from .problem_fixtures import (
blocksworld_underspecified,
blocksworld_missing_clears,
blocksworld_missing_ontables,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
wrong_initial_problem_string,
)

from .test_oracle import (
from .problem_fixtures import (
blocksworld_underspecified,
blocksworld_missing_clears,
blocksworld_missing_ontables,
Expand Down Expand Up @@ -287,4 +287,3 @@ def test_blocksworld_equivalence(
assert not metric.equals(p1, p2, is_placeholder=False)
assert not metric.equals(p2, p1, is_placeholder=True)
assert not metric.equals(p2, p1, is_placeholder=False)

17 changes: 11 additions & 6 deletions tests/test_planner.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import os
import pytest

VALIDATE = os.getenv("VALIDATE", "Validate")

from planetarium import builder, downward, oracle

from .test_oracle import (
from .problem_fixtures import (
blocksworld_fully_specified,
blocksworld_holding,
blocksworld_missing_clears,
Expand Down Expand Up @@ -153,9 +154,7 @@ def test_plan(
def test_invalid_plan(
self,
subtests,
blocksworld_invalid_1,
blocksworld_invalid_2,
blocksworld_invalid_3,
):
"""
Test if the oracle can plan for an invalid blocksworld problem.
Expand All @@ -165,7 +164,10 @@ def test_invalid_plan(
"blocksworld_invalid_2": blocksworld_invalid_2,
}.items():
with subtests.test(name):
plan = oracle.plan(builder.build(desc))
try:
plan = oracle.plan(builder.build(desc))
except Exception as e:
plan = []
assert plan == [], f"{name}: {plan}"

plan_str = oracle.plan_to_string(plan)
Expand Down Expand Up @@ -228,8 +230,11 @@ class TestUnsupportedDomain:
Test suite for unsupported domain.
"""

def test_plan(self, blocksworld_fully_specified):
def test_plan(self, mocker, blocksworld_fully_specified):
"""
Test if the oracle can plan for an unsupported domain.
"""
oracle.plan(builder.build(blocksworld_fully_specified), domain="unsupported")
problem = builder.build(blocksworld_fully_specified)
mocker.patch("planetarium.oracle.fully_specify", return_value=problem)
with pytest.raises(oracle.DomainNotSupportedError):
oracle.plan(problem, domain="unsupported_domain")

0 comments on commit 1323b5a

Please sign in to comment.