-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: main
Are you sure you want to change the base?
Conversation
Two new generators - one removes facts from init - one replaces literals from the goal with true
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.
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 |
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.
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): |
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.
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] |
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.
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""" |
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.
contained
return Truth() if atom == self.the_literal else negated_atom | ||
|
||
|
||
class GetLiteralsVisitor: |
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'm not sure a visitor makes sense here. Wouldn't a recursive function be a better fit?
This commit adds two new generators for PDDL. One is for pruning init the other for pruning goal.