Skip to content

Commit

Permalink
first draft for rovers fully specify. more tests needed
Browse files Browse the repository at this point in the history
  • Loading branch information
maxzuo committed Aug 29, 2024
1 parent 6d50076 commit 656fcac
Show file tree
Hide file tree
Showing 13 changed files with 2,903 additions and 1,769 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.
23 changes: 14 additions & 9 deletions planetarium/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def evaluate(
target_pddl_str: str,
domain_str: str | None = None,
is_placeholder: bool = False,
check_solveable: bool = True,
) -> tuple[bool, bool, bool]:
"""Evaluate two PDDL problem descriptions for equivalence.
Expand All @@ -95,6 +96,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 All @@ -117,15 +121,16 @@ def evaluate(
clean_pddl_str = problem_to_string(LenientProblemParser()(target_pddl_str))
domain_str = domain_str or DOMAINS.get(target_graph.domain)

try:
solveable = downward.validate(
domain_str,
clean_pddl_str,
oracle.plan_to_string(oracle.plan(target_graph)),
VALIDATE,
)
except:
return parseable, solveable, equivalent
if check_solveable:
try:
solveable = downward.validate(
domain_str,
clean_pddl_str,
oracle.plan_to_string(oracle.plan(target_graph)),
VALIDATE,
)
except:
return parseable, solveable, equivalent

if source_graph == target_graph:
equivalent = True
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 | 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
Loading

0 comments on commit 656fcac

Please sign in to comment.