-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial pass on quantified conditions. #50
Conversation
Code I've been using to test things out: def test1():
from pddl.formatter import domain_to_string, problem_to_string
from pddl.parser.domain import DomainParser
from pddl.parser.problem import ProblemParser
dom_text = """(define (domain my_domain)
(:requirements :strips :typing :quantified-preconditions)
(:types type_1)
(:constants a b c)
(:predicates (p1 ?x - type_1 ?y - type_1 ?z - type_1) (p2 ?x - type_1 ?y - type_1))
(:action action-1
:parameters (?x - type_1 ?y - type_1 )
;:precondition (and (forall (?z - type_1) (p1 ?x ?y ?x)))
;:precondition (and (forall (?z - type_1) (p1 ?x ?y ?z)))
:precondition (and (forall (?z - type_1) (p1 ?x ?y ?z)) (exists (?z - type_1) (not (p2 ?y ?z))))
:effect (p2 ?x ?y)
)
)"""
print(domain_to_string(DomainParser()(dom_text)))
def test2():
from pddl.logic import Predicate, constants, variables
from pddl.core import Domain, Problem, Action, Requirements
from pddl.formatter import domain_to_string, problem_to_string
from pddl.logic.base import ForallCondition
# set up variables and constants
x, y, z, z2 = variables("x y z z2", types=["type_1"])
a, b, c = constants("a b c", types=["type_1"])
# define predicates
p1 = Predicate("p1", x, y, z)
p2 = Predicate("p2", x, y)
# define actions
a1 = Action(
"action-1",
parameters=[x, y, z],
precondition=ForallCondition(p2(y,z2) & p1(x, y, z) & ~p2(y, z), [z2]),
effect=p2(y, z)
)
# define the domain object.
requirements = [Requirements.STRIPS, Requirements.TYPING]
domain = Domain("my_domain",
requirements=requirements,
types=["type_1"],
constants=[a, b, c],
predicates=[p1, p2],
actions=[a1])
print(domain_to_string(domain))
test1()
test2() |
Codecov Report
@@ Coverage Diff @@
## main #50 +/- ##
==========================================
- Coverage 87.34% 87.04% -0.30%
==========================================
Files 19 19
Lines 964 1027 +63
Branches 94 102 +8
==========================================
+ Hits 842 894 +52
- Misses 97 104 +7
- Partials 25 29 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super, thanks!
So this good to merge, or is there something else you'd like to see? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't reviewed the PR carefully, but it looks good, thank you!
Proposed changes
Support for quantified conditions. Closes #40 . Also added support for universal conditions.
Types of changes
Checklist
Further comments
None!