concepts.pdsketch.predicate.Predicate#

class Predicate[source]#

Bases: Function

A predicate is a special function that can part of the observation or state space. Predicate does not support overloaded function types. Currently, predicates are only used in planning domains.

Methods

from_function(function[, implementation, sig])

Create a function object from an actual Python function.

get_overridden_call([ftype_index])

Get the overridden call function.

get_sub_function(ftype_index)

mark_static([flag])

Mark a predicate as static (i.e., its grounded value will never change).

partial(*args[, execute_fully_bound_functions])

remap_arguments(remapping)

Generate a new Function object with a different argument order.

rename(new_name)

Rename the predicate.

set_function_body(function_body)

Set the function body.

set_function_name(function_name)

Set the function name.

Attributes

all_sub_functions

arguments

flags

flag_value}.

is_generator_function

is_overloaded

Return True if the function is overloaded.

nr_arguments

return_type

is_static

Whether the predicate is a static predicate.

is_cacheable

Whether the predicate can be cached.

is_observation_variable

Whether the predicate is an observation variable.

is_state_variable

Whether the predicate is a state variable.

is_generator_placeholder

Whether the predicate is a generator placeholder.

inplace_generators

The names of the inplace defined generators associated with this predicate.

evaluation_mode

The evaluation mode of the predicate.

is_sgc_function

Whether the predicate is a state-goal-constraint function.

__call__(*args, **kwargs)#

Call self as a function.

__init__(name, ftype, derived_expression=None, overridden_call=None, observation=None, state=None, generator_placeholder=None, inplace_generators=None, simulation=False, execution=False, is_sgc_function=False)[source]#

Initialize a predicate.

Parameters:
  • name (str) – the name of the predicate.

  • ftype (FunctionType) – the function type of the predicate.

  • derived_expression (str | None) – the derived expression of the predicate.

  • overridden_call (Callable | None) – the overridden call of the predicate.

  • observation (bool | None) – whether the predicate is an observation variable.

  • state (bool | None) – whether the predicate is a state variable.

  • generator_placeholder (bool | None) – whether the predicate is a generator placeholder.

  • inplace_generators (Sequence[str] | None) – the names of the inplace defined generators associated with this predicate. This value is stored for macro operator extension.

  • simulation (bool) – whether the predicate is a simulation-dependent function.

  • execution (bool) – whether the predicate is an execution-dependent function.

  • is_sgc_function (bool) – whether the predicate is a state-goal-constraint function.

__new__(**kwargs)#
classmethod from_function(function, implementation=True, sig=None)#

Create a function object from an actual Python function.

Parameters:
  • function (Callable) – The function.

  • implementation (bool) – Whether the function is an implementation. Defaults to True.

  • sig (Signature | None) – The signature of the function. Defaults to None.

get_overridden_call(ftype_index=None)#

Get the overridden call function.

Parameters:

ftype_index (int | None)

Return type:

Callable | None

get_sub_function(ftype_index)#
Parameters:

ftype_index (int)

Return type:

Function

mark_static(flag=True)[source]#

Mark a predicate as static (i.e., its grounded value will never change).

Parameters:

flag (bool) – Whether to mark the predicate as static.

partial(*args, execute_fully_bound_functions=False, **kwargs)#
Return type:

Function | FunctionApplicationExpression

remap_arguments(remapping)#

Generate a new Function object with a different argument order. Specifically, remapping is a permutation. The i-th argument to the new function will be the remapping[i]-th argument in the old function.

Parameters:

remapping (List[int]) – The remapping.

Returns:

The new function.

Return type:

Function

rename(new_name)[source]#

Rename the predicate.

Parameters:

new_name (str)

Return type:

Predicate

set_function_body(function_body)#

Set the function body.

Parameters:

function_body (Callable)

set_function_name(function_name)#

Set the function name.

Parameters:

function_name (str)

property all_sub_functions#
property arguments: Tuple[Variable]#
evaluation_mode: FunctionEvaluationDefinitionMode#

The evaluation mode of the predicate.

property flags: Dict[str, bool]#

flag_value}.

Type:

Return the flags of the predicate, which is a dictionary of {flag_name

inplace_generators: Tuple[str, ...]#

The names of the inplace defined generators associated with this predicate.

is_cacheable: bool#

Whether the predicate can be cached. Specifically, if it contains only “ObjectTypes” as arguments.

property is_generator_function: bool#
is_generator_placeholder: bool#

Whether the predicate is a generator placeholder.

is_observation_variable: bool#

Whether the predicate is an observation variable.

property is_overloaded: bool#

Return True if the function is overloaded.

is_sgc_function: bool#

Whether the predicate is a state-goal-constraint function.

is_state_variable: bool#

Whether the predicate is a state variable.

is_static: bool#

Whether the predicate is a static predicate. I.e., the predicate will never be changed.

property nr_arguments: int#
property return_type: ObjectType | ValueType | FunctionType | SequenceType#