New Generators for pruning init and goal#83
Conversation
Two new generators - one removes facts from init - one replaces literals from the goal with true
FlorianPommerening
left a comment
There was a problem hiding this comment.
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.
Do we need a copy here? init_facts = list(task.init)
| yield Successor(child_state, | ||
| f"Removed object '{name}'. Remaining objects: {len(task.objects) - 1}") | ||
|
|
||
| class RemoveInit(SuccessorGenerator): |
There was a problem hiding this comment.
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.
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""" |
| return Truth() if atom == self.the_literal else negated_atom | ||
|
|
||
|
|
||
| class GetLiteralsVisitor: |
There was a problem hiding this comment.
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.