concepts.dm.crow.crow_domain.CrowDomain#

class CrowDomain[source]#

Bases: DSLDomainBase

The planning domain definition.

Methods

add_external_function_implementation_file(...)

Add an external function implementation file.

clone([deep])

declare_external_function(function_name, ...)

Declare an external function.

declare_external_function_crossref(...)

Declare a cross-reference to an external function.

define_behavior(name, arguments, goal, body, ...)

Define a new behavior.

define_const(dtype, value)

Define a constant with the given type and value.

define_controller(name, arguments[, effect_body])

Define a new controller.

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

Define a new function.

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

Define a new feature.

define_function(function[, implementation])

Define a function in the domain.

define_generator(name, arguments, certifies)

Define a new generator.

define_object_constant(name, typename)

Define a new object constant.

define_type(typename[, parent_name])

Define a new type.

get_behavior(name)

get_controller(name)

Get a controller by name.

get_feature(name)

Get a feature by name.

get_function(name)

Get a function by name.

get_generator(name)

get_type(typename)

Get a type by name.

has_behavior(name)

has_controller(name)

Check whether a controller exists.

has_feature(name)

Check whether a feature exists.

has_function(name)

Check whether a function exists.

has_generator(name)

has_type(typename)

Check whether a type exists.

incremental_define(string)

Incrementally define new parts of the domain.

make_executor()

Make an executor for this domain.

parse(string[, state, variables])

Parse a string into an expression.

post_init()

Post-initialization of the domain.

print_summary([external_functions, ...])

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

from function name to the corresponding CrowFunction class.

features

from feature name to the corresponding CrowFeature class.

controllers

from controller name to the corresponding Controller class.

constants

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

behaviors

from behavior name to the corresponding CrowBehavior class.

generators

from generator name to the corresponding CrowGeneratorBase class.

external_functions

from function name to the corresponding Function class.

external_function_crossrefs

A mapping from function name to another function name.

external_function_implementation_files

A list of external function implementation files (e.g., Python libs that implements the external functions).

__init__(name=None)[source]#

Initialize a planning domain.

Parameters:

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

__new__(**kwargs)#
add_external_function_implementation_file(file_path)[source]#

Add an external function implementation file. This is useful if we want to declare external functions directly in the domain file.

Parameters:

file_path (str) – the path of the external function implementation file.

clone(deep=True)[source]#
Parameters:

deep (bool)

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

Declare an external function.

Parameters:
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_behavior(name, arguments, goal, body, effect_body, heuristic=None, minimize=None, always=False)[source]#

Define a new behavior.

Parameters:
Returns:

the newly defined behavior.

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_controller(name, arguments, effect_body=None)[source]#

Define a new controller.

Parameters:
Returns:

the newly defined controller.

Return type:

CrowController

define_crow_function(name, arguments, return_type=BOOL, *, derived_expression=None, generator_placeholder=False, inplace_generators=None, simulation=False, execution=False, is_generator_function=False)[source]#

Define a new function.

Parameters:
Returns:

the newly defined function.

define_feature(name, arguments, return_type=BOOL, *, derived_expression=None, observation=None, state=None, default=None)[source]#

Define a new feature.

Parameters:
Returns:

the newly defined feature.

Return type:

CrowFeature

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, arguments, certifies, inputs=None, outputs=None, priority=0, simulation=False, execution=False)[source]#

Define a new generator.

Parameters:
Returns:

the newly defined generator.

Return type:

CrowGeneratorBase

define_object_constant(name, typename)[source]#

Define a new object constant.

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

  • typename (str) – the type of the new constant.

Returns:

the newly defined constant.

Return type:

ObjectConstant

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

Define a new type.

Parameters:
Returns:

the newly defined type.

Return type:

ObjectType | PyObjValueType | VectorValueType | ScalarValueType

get_behavior(name)[source]#
Parameters:

name (str)

Return type:

CrowBehavior

get_controller(name)[source]#

Get a controller by name.

Parameters:

name (str) – the name of the controller.

Returns:

the controller with the given name.

Return type:

CrowController

get_feature(name)[source]#

Get a feature by name.

Parameters:

name (str) – the name of the feature.

Returns:

the feature with the given name.

Return type:

CrowFeature

get_function(name)[source]#

Get a function by name.

Parameters:

name (str) – the name of the function.

Returns:

the function with the given name.

Return type:

CrowFunction

get_generator(name)[source]#
Parameters:

name (str)

Return type:

CrowGeneratorBase

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

has_behavior(name)[source]#
Parameters:

name (str)

Return type:

bool

has_controller(name)[source]#

Check whether a controller exists.

Parameters:

name (str) – the name of the controller.

Returns:

whether the controller exists.

Return type:

bool

has_feature(name)[source]#

Check whether a feature exists.

Parameters:

name (str) – the name of the feature.

Returns:

whether the feature exists.

Return type:

bool

has_function(name)[source]#

Check whether a function exists.

Parameters:

name (str) – the name of the function.

Returns:

whether the function exists.

Return type:

bool

has_generator(name)[source]#
Parameters:

name (str)

Return type:

bool

has_type(typename)[source]#

Check whether a type exists.

Parameters:

typename (str) – the name of the type.

Returns:

whether the type exists.

incremental_define(string)[source]#

Incrementally define new parts of the domain.

Parameters:

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

make_executor()[source]#

Make an executor for this domain.

Return type:

CrowExecutor

parse(string, state=None, 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(external_functions=False, full_generators=False)[source]#

Print a summary of the domain.

Parameters:
  • external_functions (bool)

  • full_generators (bool)

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>, 'string': PyObjValueType<string>}#
BUILTIN_PYOBJ_TYPES = {'__behavior_body__': PyObjValueType<__behavior_body__>}#
BUILTIN_TYPES = ['object', 'pyobject', 'bool', 'int64', 'float32', 'string', '__totally_ordered_plan__']#
behaviors: Dict[str, CrowBehavior]#

from behavior name to the corresponding CrowBehavior class.

Type:

A mapping of behaviors

constants: Dict[str, ObjectConstant]#

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

controllers: Dict[str, CrowController]#

from controller name to the corresponding Controller class.

Type:

A mapping of controllers

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_function_implementation_files: List[str]#

A list of external function implementation files (e.g., Python libs that implements the external functions).

external_functions: Dict[str, Function]#

from function name to the corresponding Function class.

Type:

A mapping of external functions

features: Dict[str, CrowFeature]#

from feature name to the corresponding CrowFeature class.

Type:

A mapping of features

functions: Dict[str, CrowFunction]#

from function name to the corresponding CrowFunction class.

Type:

A mapping of functions

generators: Dict[str, CrowGeneratorBase]#

from generator name to the corresponding CrowGeneratorBase class.

Type:

A mapping of generators

name: str#

The name of the domain.

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

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