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 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 an executor for this domain.
parse
(string[, state, variables])Parse a string into an expression.
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
The name of the domain.
The types defined in the domain, as a dictionary from type names to types.
from function name to the corresponding
CrowFunction
class.from feature name to the corresponding
CrowFeature
class.from controller name to the corresponding
Controller
class.The constants defined in the domain, as a dictionary from constant names to values.
from action name to the corresponding
CrowAction
class.from generator name to the corresponding
CrowGeneratorBase
class.from function name to the corresponding
Function
class.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:
function_name (str) – the name of the external function.
argument_types (Sequence[ObjectType | ValueType | FunctionType] | Sequence[Variable] | Dict[str, ObjectType | ValueType | FunctionType]) – the argument types of the external function.
return_type (ObjectType | ValueType | FunctionType | SequenceType) – 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:
- 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.
- define_action(name, arguments, goal, body, preconditions, effects, always=False)[source]#
Define a new action.
- Parameters:
name (str) – the name of the new action.
arguments (Sequence[Variable]) – the arguments of the new action.
goal (ValueOutputExpression) – the goal of the new action.
body (CrowActionOrderingSuite) – the body of the new action.
preconditions (Sequence[CrowPrecondition]) – the preconditions of the new action.
effects (Sequence[CrowEffect]) – the effects of the new action.
always (bool) – whether the new action is always feasible.
- 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_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:
name (str) – the name of the new function.
arguments (Sequence[ObjectType | ValueType | FunctionType] | Sequence[Variable] | Dict[str, ObjectType | ValueType | FunctionType]) – the arguments of the new function.
return_type (ObjectType | ValueType | FunctionType | SequenceType) – the return type of the new function.
generator_placeholder (bool) – whether the new function is a generator placeholder.
inplace_generators (Sequence[str] | None) – a list of generators that will be defined in-place for this function.
simulation (bool) – whether the new function requires the up-to-date simulation state to evaluate.
execution (bool) – whether the new function requires the up-to-date execution state to evaluate.
is_generator_function (bool) – whether the new function is a generator function.
derived_expression (ValueOutputExpression | None) –
- 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:
name (str) – the name of the new feature.
arguments (Sequence[ObjectType | ValueType | FunctionType] | Sequence[Variable] | Dict[str, ObjectType | ValueType | FunctionType]) – the arguments of the new feature.
return_type (ObjectType | ValueType | FunctionType | SequenceType) – the return type of the new feature.
derived_expression (ValueOutputExpression | None) – the derived expression of the new feature.
observation (bool | None) – whether the new feature is an observation variable.
state (bool | None) – whether the new feature is a state variable.
- Returns:
the newly defined feature.
- Return type:
- define_function(function, implementation=True)#
Define a function in the domain.
- 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:
- define_type(typename, parent_name='object')[source]#
Define a new type.
- Parameters:
typename – the name of the new type.
parent_name (VectorValueType | ScalarValueType | str | None) – the parent type of the new type, default to ‘object’.
- Returns:
the newly defined type.
- Return type:
ObjectType | PyObjValueType | VectorValueType | ScalarValueType
- 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:
- 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:
- 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:
- 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_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.
- parse(string, state=None, variables=None)[source]#
Parse a string into an expression.
- Parameters:
string (str | Expression) – the string to be parsed.
variables (Sequence[Variable] | None) – the variables to be used in the expression.
state (State | None) –
- Returns:
the parsed expression.
- Return type:
- 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:
Analyze the static predicates.
- print_summary(external_functions=False, full_generators=False)[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 = {'__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
- types: Dict[str, ObjectType | PyObjValueType | TensorValueTypeBase]#
The types defined in the domain, as a dictionary from type names to types.