Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions fondutils/determizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
from pddl.action import Action
from pddl.core import Domain
from pddl.logic.base import OneOf, And, Not
from pddl.logic.effects import When
from pddl.logic.predicates import Predicate
from pddl.requirements import Requirements


from .normalizer import normalize_operator

DEBUG = False
DEBUG = True


def determinize(domain: Domain, dom_suffix: str = "ALLOUT", op_prefix: str = "_DETDUP_", op_suffix: str = "") -> Domain:
Expand Down Expand Up @@ -47,7 +48,7 @@ def determinize(domain: Domain, dom_suffix: str = "ALLOUT", op_prefix: str = "_D
counter = 1
for eff in new_act.effect.operands:
assert isinstance(
eff, (And, Predicate, Not)
eff, (And, Predicate, Not, When)
), f"Effect in OneOf is not an And effect: {eff}"
new_actions.append(
Action(
Expand Down
18 changes: 18 additions & 0 deletions tests/domain_07.pddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
;; multiple oneof cross product
(define (domain blocks-domain)
(:requirements :non-deterministic :equality :typing :adl)
(:predicates
(f1) (f2) (f3) (f13)
)

(:action test
:parameters ()
:precondition (and (f13))
:effect (oneof
(when
(f1)
(f2))
(f3)
)
)
)
14 changes: 14 additions & 0 deletions tests/domain_07_det.pddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(define (domain blocks-domain)
(:requirements :adl :equality :typing)
(:predicates (f1) (f13) (f2) (f3))
(:action test_DETDUP_1
:parameters ()
:precondition (f13)
:effect (when (f1) (f2))
)
(:action test_DETDUP_2
:parameters ()
:precondition (f13)
:effect (f3)
)
)
11 changes: 11 additions & 0 deletions tests/test_det.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ def test_09():

assert domain_to_string(domain_det) == domain_expected

def test_10():
"""tests if we have a basic condeff as an outcome"""
domain = parse_domain(TEST_DIRECTORY / "domain_07.pddl")
domain_det = determinize(domain, dom_suffix="")

with open(TEST_DIRECTORY / "domain_07_det.pddl", "r") as file:
domain_expected = file.read()

assert domain_to_string(domain_det) == domain_expected


if __name__ == "__main__":
test_01()
Expand All @@ -123,3 +133,4 @@ def test_09():
test_07()
test_08()
test_09()
test_10()