diff --git a/setup.py b/setup.py index ef7397c..b07c72e 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ long_description = fh.read() setuptools.setup(name='lifted-pddl', - version='1.2.1', + version='1.2.2', description='A lightweight framework for parsing PDDL in lifted form.', long_description=long_description, long_description_content_type="text/markdown", diff --git a/src/lifted_pddl/__init__.py b/src/lifted_pddl/__init__.py index 0584430..48680cc 100644 --- a/src/lifted_pddl/__init__.py +++ b/src/lifted_pddl/__init__.py @@ -1,5 +1,5 @@ # __init__.py -__version__ = "1.2.1" +__version__ = "1.2.2" from lifted_pddl.parser import Parser diff --git a/src/lifted_pddl/__pycache__/__init__.cpython-39.pyc b/src/lifted_pddl/__pycache__/__init__.cpython-39.pyc index c2dc739..91627fd 100644 Binary files a/src/lifted_pddl/__pycache__/__init__.cpython-39.pyc and b/src/lifted_pddl/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/lifted_pddl/__pycache__/parser.cpython-39.pyc b/src/lifted_pddl/__pycache__/parser.cpython-39.pyc index bad74c7..fb440e9 100644 Binary files a/src/lifted_pddl/__pycache__/parser.cpython-39.pyc and b/src/lifted_pddl/__pycache__/parser.cpython-39.pyc differ diff --git a/src/lifted_pddl/parser.py b/src/lifted_pddl/parser.py index 5ce5948..4f00f8a 100644 --- a/src/lifted_pddl/parser.py +++ b/src/lifted_pddl/parser.py @@ -246,9 +246,15 @@ def parse_problem(self, problem_path): # Each goal is represented as a tuple (is_true, pred_name, object_indexes) # object_indexes is a tuple containing the index of each object the atom of the goal is instantiated on # is_true equals False if the goal is negative (e.g., (not (at t1 l1)) ) and True otherwise - subformulas = problem.goal.subformulas - self.goals = set([(True, x.predicate.name, tuple(self.object_names.index(obj.name) for obj in x.subterms)) if isinstance(x, Atom) else \ - (False, x.subformulas[0].predicate.name, tuple(self.object_names.index(obj.name) for obj in x.subformulas[0].subterms)) for x in subformulas]) + + # The goal contains a single atom (e.g., ( :goal (and (on b2 b1))) ) + if isinstance(problem.goal, Atom): + self.goals = set([(True, problem.goal.predicate.name, tuple(self.object_names.index(obj.name) for obj in problem.goal.subterms))]) + + else: # The goal contains more than a single atom + subformulas = problem.goal.subformulas + self.goals = set([(True, x.predicate.name, tuple(self.object_names.index(obj.name) for obj in x.subterms)) if isinstance(x, Atom) else \ + (False, x.subformulas[0].predicate.name, tuple(self.object_names.index(obj.name) for obj in x.subformulas[0].subterms)) for x in subformulas]) # Returns the name of the object whose index is @obj_ind def get_object_name(self, obj_ind):