concepts.dsl.expression.ExpressionDefinitionContext#
- class ExpressionDefinitionContext[source]#
Bases:
object
Methods
add_variables
(*args)Adding a list of new variables.
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
The list of variables.
The mapping from variable names to variables.
The domain of the expression.
The current definition scope (e.g., in a function).
The anonymous argument generator.
Whether the expression is defined in an effect of an operator.
Whether the slot functions are SGC functions (state-goal-constraints functions).
Whether to enable automatic predicate definition.
Whether to check the arguments of the functions.
- __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)
- 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:
- has_variable(variable)[source]#
- Parameters:
self (ExpressionDefinitionContext)
- Return type:
- 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)
- OPTION_NAMES = ['allow_auto_predicate_def', 'check_arguments']#
- anonymous_argument_generator: AnonymousFunctionArgumentGenerator#
The anonymous argument generator.
- domain: DSLDomainBase | None#
The domain of the expression.
- 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.