concepts.dsl.expression.ExpressionDefinitionContext#

class ExpressionDefinitionContext[source]#

Bases: object

Methods

add_variables(*args)

Adding a list of new variables.

as_default()

gen_random_named_variable(dtype)

Generate a variable expression with a random name.

get_variable(variable)

has_variable(variable)

mark_is_effect_definition(is_effect_definition)

is_effect_definition is a boolean flag that indicates whether the current expression is defined in an effect of an operator.

new_variables(*args)

Adding a list of new variables.

options(**kwargs)

with_variables(*args)

Reset the list of variables.

wrap_variable(variable)

Attributes

OPTION_NAMES

is_effect_definition

variables

The list of variables.

variable_name2obj

The mapping from variable names to variables.

domain

The domain of the expression.

scope

The current definition scope (e.g., in a function).

anonymous_argument_generator

The anonymous argument generator.

is_effect_definition_stack

Whether the expression is defined in an effect of an operator.

slot_functions_are_sgc

Whether the slot functions are SGC functions (state-goal-constraints functions).

allow_auto_predicate_def

Whether to enable automatic predicate definition.

check_arguments

Whether to check the arguments of the functions.

__getitem__(variable)[source]#
Parameters:

variable (str | Variable)

Return type:

VariableExpression

__init__(*variables, domain=None, scope=None, is_effect_definition=False, slot_functions_are_sgc=False, allow_auto_predicate_def=True, check_arguments=True)[source]#

Initialize the context.

Parameters:
  • variables (Variable) – The variables that are available in the expression.

  • domain (DSLDomainBase | None) – the domain of the expression.

  • scope (str | None) – the current definition scope (e.g., in a function). This variable will be used to generate unique names for the functions.

  • is_effect_definition (bool) – whether the expression is defined in an effect of an operator.

  • slot_functions_are_sgc (bool) – whether the slot functions are SGC functions (state-goal-constraints functions).

  • allow_auto_predicate_def (bool) – whether to enable automatic predicate definition.

  • check_arguments (bool) – whether to check the arguments of the functions.

__new__(**kwargs)#
add_variables(*args)[source]#

Adding a list of new variables. Unlike new_variables(), the variables will be directly added to the current context.

Parameters:

args (Variable)

as_default()[source]#
gen_random_named_variable(dtype)[source]#

Generate a variable expression with a random name. This utility is useful in “flatten_expression”. See the doc for that function for details.

Return type:

Variable

get_variable(variable)[source]#
Parameters:

variable (str | Variable)

Return type:

Variable

has_variable(variable)[source]#
Parameters:
Return type:

bool

mark_is_effect_definition(is_effect_definition)[source]#

is_effect_definition is a boolean flag that indicates whether the current expression is defined in an effect of an operator. This function is a context manager and is only used in planning tasks.

Parameters:

is_effect_definition (bool)

new_variables(*args)[source]#

Adding a list of new variables. This function is a context manager, and the variables will be removed after the context is closed.

Parameters:

args (Variable)

options(**kwargs)[source]#
with_variables(*args)[source]#

Reset the list of variables.

Parameters:

args (Variable)

wrap_variable(variable)[source]#
Parameters:

variable (str | Variable)

Return type:

VariableExpression

OPTION_NAMES = ['allow_auto_predicate_def', 'check_arguments']#
allow_auto_predicate_def: bool#

Whether to enable automatic predicate definition.

anonymous_argument_generator: AnonymousFunctionArgumentGenerator#

The anonymous argument generator.

check_arguments: bool#

Whether to check the arguments of the functions.

domain: DSLDomainBase | None#

The domain of the expression.

property is_effect_definition: bool#
is_effect_definition_stack: List[bool]#

Whether the expression is defined in an effect of an operator.

scope: str | None#

The current definition scope (e.g., in a function). This variable will be used to generate unique names for the functions.

slot_functions_are_sgc: bool#

Whether the slot functions are SGC functions (state-goal-constraints functions).

variable_name2obj: Dict[str, Variable]#

The mapping from variable names to variables.

variables: List[Variable]#

The list of variables.