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

Adding Support for Axioms and Derived Predicates #493

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

speckdavid
Copy link
Contributor

As part of the 3rd Sprint of the "Symbolic Search for Diverse Plans and Maximum Utility" project, we added support for Axioms + Derived Predicates to the UP. So that these can be represented internally as well as read from and written to PDDL.

We also created a notebook as a usage example: Axioms and Derived Predicates in the Unified Planning Library.

Best
David

@PoneyUHC
Copy link

PoneyUHC commented Oct 6, 2023

Would appreciate this feature in my actual project, looking forward to it :D !

@roeger
Copy link
Contributor

roeger commented Oct 26, 2023

Having this in main would be great for the Fast Downward grounder (currently throwing an error when grounding introduces axioms because they cannot be represented in the grounded UP model).

Copy link
Member

@mikand mikand left a comment

Choose a reason for hiding this comment

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

@speckdavid Many thanks for this PR.
@roeger I know very little about derived predicates and I left only a couple of comments. Can you do a more detailed code review?

from unified_planning.environment import get_environment, Environment


class Axiom(InstantaneousAction):
Copy link
Member

Choose a reason for hiding this comment

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

Why deriving from InstantaneousAction? This makes it possible to have Axioms passed to the add_action methods and causes some hacky code below. Why not a dedicated class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea was mainly to reuse the functionality and code of actions, not only when defining an action, but also for PDDL parsing. But I agree that we may have some side effects here. In general, I am open to creating a dedicated class not derived from InstantaneousAction, but I am a bit concerned that the PDDL parsing might become a bit more involved and we might get some redundant code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you have a look at the internal structure of the InstantaneousActiona and see what is that you really need? Maybe this could be a call to a small refactoring aimed at factorising what is needed to both instantaneous actions and axioms.

@@ -75,6 +79,17 @@ def is_bool_type(self) -> bool:
return True


class _DerivedBoolType(Type):
Copy link
Member

Choose a reason for hiding this comment

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

Does this information needs to be in the typing system or we can keep a list/map/set of predicates that are derived in the Problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the beginning, I simply wanted to use the Boolean type, but I ran into some problems. For example, when a planning problem is created, an assertion checks whether all variables have an initial value. For derived predicates, however, we cannot set such a value.

I think your suggestion of having a list/set of variables that are derived would also work if we can access it at the appropriate places. It will definitely simplify the code as the typing system is not touched. I will check it.

@mikand mikand requested review from hstairs and roeger November 6, 2023 15:54
@jendrikseipp
Copy link

I just stumbled over this as well: I had thought that the UP supports derived predicates already. Would be great to have this in the library!

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.

6 participants