Skip to content

Commit

Permalink
Solved bug that occurred when parsing problems whose goal contained a…
Browse files Browse the repository at this point in the history
… single atom
  • Loading branch information
TheAeryan committed Jun 23, 2023
1 parent d402385 commit 47a7ae5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/lifted_pddl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# __init__.py

__version__ = "1.2.1"
__version__ = "1.2.2"

from lifted_pddl.parser import Parser
Binary file modified src/lifted_pddl/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified src/lifted_pddl/__pycache__/parser.cpython-39.pyc
Binary file not shown.
12 changes: 9 additions & 3 deletions src/lifted_pddl/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 47a7ae5

Please sign in to comment.