concepts.dm.crow.domain.CrowDomain#

class CrowDomain[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_action(name, arguments, goal, body, ...)

Define a new action.

define_const(dtype, value)

Define a constant with the given type and value.

define_controller(name, arguments[, extends])

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_type(typename[, parent_name])

Define a new type.

get_action(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_action(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.

actions

from action name to the corresponding CrowAction 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.

__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:
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_action(name, arguments, goal, body, preconditions, effects, always=False)[source]#

Define a new action.

Parameters:
Returns:

the newly defined action.

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, extends=None)[source]#

Define a new controller.

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

  • arguments (Sequence[Variable]) – the arguments of the new controller.

  • extends (str | None) –

Returns:

the newly defined controller.

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)[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:
  • name (str) – the name of the new generator.

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

  • certifies (Sequence[ValueOutputExpression] | ValueOutputExpression) – the certified condition of the new generator.

  • inputs (Sequence[Variable] | None) – the input variables of the new generator.

  • outputs (Sequence[Variable] | None) – the output variables of the new generator.

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

  • simulation (bool) – whether the new generator requires the up-to-date simulation state to evaluate.

  • execution (bool) – whether the new generator requires the up-to-date execution state to evaluate.

Returns:

the newly defined generator.

Return type:

CrowGeneratorBase

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

Define a new type.

Parameters:
Returns:

the newly defined type.

Return type:

ObjectType | PyObjValueType | VectorValueType | ScalarValueType

get_action(name)[source]#
Parameters:

name (str) –

Return type:

CrowAction

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_action(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>}#
BUILTIN_PYOBJ_TYPES = {'__control__': PyObjValueType<__control__>, '__regression_body_item__': PyObjValueType<__regression_body_item__>, '__totally_ordered_plan__': ListType<__totally_ordered_plan__>}#
BUILTIN_TYPES = ['object', 'pyobject', 'bool', 'int64', 'float32', '__control__', '__totally_ordered_plan__', '__partially_ordered_plan__']#
actions: Dict[str, CrowAction]#

from action name to the corresponding CrowAction class.

Type:

A mapping of actions

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_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]#

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