Skip to content

Commit

Permalink
fix(interpreted functions): correctly added missing imports to shortc…
Browse files Browse the repository at this point in the history
…uts and model init
  • Loading branch information
Samuel Gobbi committed Sep 13, 2024
1 parent 7cc2f4d commit 013e396
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions unified_planning/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
)
from unified_planning.model.fnode import FNode
from unified_planning.model.fluent import Fluent
from unified_planning.model.interpreted_function import InterpretedFunction
from unified_planning.model.object import Object
from unified_planning.model.operators import OperatorKind
from unified_planning.model.parameter import Parameter
Expand Down Expand Up @@ -93,6 +94,7 @@
"ExpressionManager",
"FNode",
"Fluent",
"InterpretedFunction",
"Object",
"OperatorKind",
"Parameter",
Expand Down
17 changes: 17 additions & 0 deletions unified_planning/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,23 @@ def FluentExp(
return get_environment().expression_manager.FluentExp(fluent, params)


def InterpretedFunctionExp(
interpreted_function: "unified_planning.model.InterpretedFunction",
params: Sequence[Expression] = tuple(), # -------
) -> FNode:
"""
| Creates an expression for the given ``interpreted_function`` and ``parameters``.
| Restriction: ``parameters type`` must be compatible with the ``InterpretedFunction`` :func:``signature <unified_planning.model.InterpretedFunction.signature>``
:param interpreted_function: The ``InterpretedFunction`` that will be set as the ``payload`` of this expression.
:param params: The Iterable of expressions acting as ``parameters`` for this ``InterpretedFunction``.
:return: The created ``InterpretedFunction`` Expression.
"""
return get_environment().expression_manager.InterpretedFunction(
interpreted_function, params
)


def Always(expression: BoolExpression) -> FNode:
"""
Creates an expression of the form:
Expand Down

0 comments on commit 013e396

Please sign in to comment.