Skip to content
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

New Generators for pruning init and goal #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

galvusdamor
Copy link

This commit adds two new generators for PDDL. One is for pruning init the other for pruning goal.

Two new generators
 - one removes facts from init
 - one replaces literals from the goal with true
Copy link
Member

@FlorianPommerening FlorianPommerening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request. I left a few comments in the code.

"""
def get_successors(self, state):
task = state[KEY_IN_STATE]
init_facts = task.init
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a copy here? init_facts = list(task.init)

@@ -83,3 +83,40 @@ def get_successors(self, state):
visitors.TaskElementEraseObjectVisitor(name))
yield Successor(child_state,
f"Removed object '{name}'. Remaining objects: {len(task.objects) - 1}")

class RemoveInit(SuccessorGenerator):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing a fact from init makes the task simpler in the sense that the PDDL is smaller but it might become harder to solve. Should we also add a generator that adds facts to the initial state? You couldn't use them both without running into an infinite loop but either one could be useful.

self.the_fact = fact

def visit_task(self, task):
new_init = [atom for atom in task.init if isinstance(atom, Assign) or atom != self.the_fact]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the relevance of the isinstance(atom, Assign) check? Is this for PDDL functions?



class GetLiteralsVisitor:
"""A visitor that returns the literals contains in a formula"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contained

return Truth() if atom == self.the_literal else negated_atom


class GetLiteralsVisitor:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure a visitor makes sense here. Wouldn't a recursive function be a better fit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants