concepts.pdsketch.domain.Domain#

class Domain[source]#

Bases: DSLDomainBase

The planning domain definition.

Methods

declare_external_function(function_name, ...)

Declare an external function.

declare_external_function_crossref(...)

Declare a cross-reference to an external function.

define_axiom(name, parameters, ...)

Define a new axiom.

define_const(dtype, value)

Define a constant with the given type and value.

define_derived(name, arguments[, ...])

Define a new derived predicate.

define_fancy_generator(name, certifies[, ...])

Declare a new fancy generator.

define_function(function[, implementation])

Define a function in the domain.

define_generator(name, parameters, ...[, ...])

Define a new generator.

define_macro(name, parameters, sub_operators)

Define a new macro.

define_operator(name, parameters, ...[, ...])

Define a new operator.

define_operator_inner(name, operator)

define_predicate(name, arguments[, ...])

Define a new predicate.

define_predicate_inner(name, predicate_def)

define_regression_rule(name, parameters, ...)

Define a new regression rule.

define_type(typename[, parent_name])

Define a new type.

get_function(name)

Get the function with the given name.

get_type(typename)

Get a type by name.

incremental_define(string)

Incrementally define new parts of the domain.

parse(string[, variables])

Parse a string into an expression.

post_init()

Post-initialization of the domain.

print_summary()

Print a summary of the domain.

set_name(name)

Set the name of the domain.

Attributes

BUILTIN_NUMERIC_TYPES

BUILTIN_PYOBJ_TYPES

BUILTIN_TYPES

name

The name of the domain.

types

The types defined in the domain, as a dictionary from type names to types.

functions

A mapping from function name to the corresponding Predicate class.

constants

The constants defined in the domain, as a dictionary from constant names to values.

operators

from operator name to the corresponding Operator class.

operator_templates

from operator name to the corresponding Operator class.

regression_rules

from regression rule name to the corresponding RegressionRule class.

axioms

from axiom name to the corresponding Operator class.

generators

from generator name to the corresponding Generator class.

fancy_generators

from fancy generator name to the corresponding FancyGenerator class.

external_functions

from function name to the corresponding Function class.

external_function_crossrefs

A mapping from function name to another function name.

tv

A helper function that returns a variable with the given type.

__init__(name=None)[source]#

Initialize a planning domain.

Parameters:

name (str | None) – The name of the domain.

__new__(**kwargs)#
declare_external_function(function_name, argument_types, return_type, kwargs=None)[source]#

Declare an external function.

Parameters:
  • function_name (str) – the name of the external function.

  • argument_types (Sequence[ObjectType | ValueType | FunctionType]) – the argument types of the external function.

  • return_type (ObjectType | ValueType | FunctionType) – the return type of the external function.

  • kwargs (Dict[str, Any] | None) – the keyword arguments of the external function. Supported keyword arguments are: - observation: whether the external function is an observation variable. - state: whether the external function is a state variable.

Return type:

Function

declare_external_function_crossref(function_name, cross_ref_name)[source]#

Declare a cross-reference to an external function. This is useful when one function is an derived function of another function.

Parameters:
  • function_name (str) – the name of the external function.

  • cross_ref_name (str) – the name of the cross-reference.

define_axiom(name, parameters, preconditions, effects)[source]#

Define a new axiom.

Parameters:
  • name (str | None) – the name of the new axiom. If None, a unique name will be generated.

  • parameters (Sequence[Variable]) – the parameters of the new axiom.

  • preconditions (Sequence[Precondition]) – the preconditions of the new axiom.

  • effects (Sequence[Effect]) – the effects of the new axiom.

Returns:

the newly defined axiom.

Return type:

Operator

define_const(dtype, value)#

Define a constant with the given type and value.

Parameters:
  • dtype (ObjectType | ValueType) – the type of the constant.

  • value (str) – the value of the constant. The value should be a string that is the name of the constant.

define_derived(name, arguments, return_type=None, expr=None, state=False, generator_placeholder=False)[source]#

Define a new derived predicate. Note that a derived predicate can not be an observation variable.

Parameters:
Returns:

the newly defined derived predicate.

define_fancy_generator(name, certifies, priority=10, unsolvable=False)[source]#

Declare a new fancy generator. The difference between a fancy generator and a normal generator is that a fancy generator is not directional. That is, it can generate a set of variables satisfies the constraints, without requiring specific contexts to generates directions. Therefore, we don’t need to specify the context and generates of a fancy generator.

Parameters:
  • name (str) – the name of the new fancy generator.

  • certifies (ValueOutputExpression) – the certified condition of the new fancy generator.

  • priority (int) – the priority of the new fancy generator.

  • unsolvable (bool) – whether the new fancy generator is unsolvable.

Returns:

the newly declared fancy generator.

Return type:

Generator

define_function(function, implementation=True)#

Define a function in the domain.

Parameters:
  • function (Function | Callable) – the function to be defined.

  • implementation (bool) – whether to store the function body of function as the implementation of the function.

Returns:

the function that is defined.

Return type:

Function

define_generator(name, parameters, certifies, context, generates, priority=0, unsolvable=False)[source]#

Define a new generator.

Parameters:
Returns:

the newly defined generator.

Return type:

Generator

define_macro(name, parameters, sub_operators)[source]#

Define a new macro.

Parameters:
Returns:

the newly defined macro.

define_operator(name, parameters, preconditions, effects, controller, template=False, extends=None)[source]#

Define a new operator.

Parameters:
  • name (str) – the name of the new operator.

  • parameters (Sequence[Variable]) – the parameters of the new operator.

  • preconditions (Sequence[Precondition]) – the preconditions of the new operator.

  • effects (Sequence[Effect]) – the effects of the new operator.

  • controller (OperatorController) – the controller of the new operator.

  • template – whether the new operator is a template.

  • extends – the parent operator of the new operator.

Returns:

the newly defined operator.

Return type:

Operator

define_operator_inner(name, operator)[source]#
Parameters:
Return type:

Operator

define_predicate(name, arguments, return_type=BOOL, observation=None, state=None, generator_placeholder=False, inplace_generators=None)[source]#

Define a new predicate.

Parameters:
Returns:

the newly defined predicate.

define_predicate_inner(name, predicate_def)[source]#
Parameters:

predicate_def (Predicate) –

define_regression_rule(name, parameters, preconditions, goal_expression, body, always=False)[source]#

Define a new regression rule.

Parameters:
Returns:

the newly defined regression rule.

define_type(typename, parent_name='object')[source]#

Define a new type.

Parameters:
Returns:

the newly defined type.

Return type:

ObjectType | PyObjValueType | VectorValueType | ScalarValueType

get_function(name)#

Get the function with the given name.

Parameters:

name (str) – the name of the function.

Returns:

the function with the given name.

Return type:

Function

get_type(typename)[source]#

Get a type by name.

Parameters:

typename (str) – the name of the type.

Returns:

the type with the given name.

Return type:

ObjectType | PyObjValueType | VectorValueType | ScalarValueType | NamedTensorValueType

incremental_define(string)[source]#

Incrementally define new parts of the domain.

Parameters:

string (str) – the string to be parsed and defined.

parse(string, variables=None)[source]#

Parse a string into an expression.

Parameters:
Returns:

the parsed expression.

Return type:

Expression

post_init()[source]#

Post-initialization of the domain. This function should be called by the domain generator after all the domain definitions (predicates and operators) are done. Currently, the following post-initialization steps are performed:

  1. Analyze the static predicates.

print_summary()[source]#

Print a summary of the domain.

set_name(name)[source]#

Set the name of the domain.

Parameters:

name (str) – the new name of the domain.

BUILTIN_NUMERIC_TYPES = {'bool': ScalarValueType<bool>, 'float32': ScalarValueType<float32>, 'int64': ScalarValueType<int64>}#
BUILTIN_PYOBJ_TYPES = {'__regression_body_item__': PyObjValueType<__regression_body_item__>, '__totally_ordered_plan__': ListType<__totally_ordered_plan__>}#
BUILTIN_TYPES = ['object', 'pyobject', 'bool', 'int64', 'float32', '__totally_ordered_plan__', '__partially_ordered_plan__']#
axioms: Dict[str, Operator]#

from axiom name to the corresponding Operator class.

Type:

A mapping of axioms

constants: Dict[str, ObjectConstant]#

The constants defined in the domain, as a dictionary from constant names to values.

external_function_crossrefs: Dict[str, str]#

A mapping from function name to another function name. This is useful when defining one function as an derived function of another function.

external_functions: Dict[str, Function]#

from function name to the corresponding Function class.

Type:

A mapping of external functions

fancy_generators: Dict[str, FancyGenerator]#

from fancy generator name to the corresponding FancyGenerator class.

Type:

A mapping of fancy generators

functions: Dict[str, Predicate]#

A mapping from function name to the corresponding Predicate class. Note that, unlike the basic DSLDomainBase, in planning domain, all functions should be of type Predicate.

generators: Dict[str, Generator]#

from generator name to the corresponding Generator class.

Type:

A mapping of generators

name: str#

The name of the domain.

operator_templates: Dict[str, Operator]#

from operator name to the corresponding Operator class.

Type:

A mapping of operator templates

operators: Dict[str, Operator | MacroOperator]#

from operator name to the corresponding Operator class.

Type:

A mapping of operators

regression_rules: Dict[str, RegressionRule]#

from regression rule name to the corresponding RegressionRule class.

Type:

A mapping of regression rules

tv: _TypedVariableView#

A helper function that returns a variable with the given type. For example, domain.tv[‘object’](‘x’) returns a variable of type object with name x.

types: Dict[str, ObjectType | PyObjValueType | TensorValueTypeBase]#

The types defined in the domain, as a dictionary from type names to types.