concepts.dm.crow.crow_domain.CrowDomain#
- class CrowDomain[source]#
Bases:
DSLDomainBase
The planning domain definition.
Methods
Add an external function implementation file.
clone
([deep])declare_external_function
(function_name, ...)Declare an external function.
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 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 behavior name to the corresponding
CrowBehavior
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.
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.
- 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 | SequenceType] | Sequence[Variable] | Dict[str, ObjectType | ValueType | FunctionType | SequenceType]) – 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_behavior(name, arguments, goal, body, effect_body, heuristic=None, minimize=None, always=False)[source]#
Define a new behavior.
- Parameters:
name (str) – the name of the new behavior.
arguments (Sequence[Variable]) – the arguments of the new behavior.
goal (ValueOutputExpression | NullExpression) – the goal of the new behavior.
body (CrowBehaviorOrderingSuite) – the body of the new behavior.
effect_body (CrowBehaviorOrderingSuite) – the effect body of the new behavior.
heuristic (CrowBehaviorOrderingSuite | None) – the heuristic of the new behavior.
minimize (ValueOutputExpression | None) – the minimize condition of the new behavior.
always (bool) – whether the new behavior is always “feasible”.
- 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:
name (str) – the name of the new controller.
arguments (Sequence[Variable]) – the arguments of the new controller.
effect_body (CrowBehaviorOrderingSuite | None) – the effect body of the new controller.
- Returns:
the newly defined controller.
- Return type:
- 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 | SequenceType] | Sequence[Variable] | Dict[str, ObjectType | ValueType | FunctionType | SequenceType]) – the arguments of the new function.
return_type (ObjectType | ValueType | FunctionType | SequenceType) – the return type of the new function.
derived_expression (ValueOutputExpression | None) – the derived expression 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.
- 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:
name (str) – the name of the new feature.
arguments (Sequence[ObjectType | ValueType | FunctionType | SequenceType] | Sequence[Variable] | Dict[str, ObjectType | ValueType | FunctionType | SequenceType]) – 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.
default (Any | None) – the default value of the new feature.
- 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 | NullExpression] | ValueOutputExpression | NullExpression) – 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_object_constant(name, typename)[source]#
Define a new object constant.
- Parameters:
- Returns:
the newly defined constant.
- 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>, '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
- types: Dict[str, ObjectType | PyObjValueType | TensorValueTypeBase | AliasType]#
The types defined in the domain, as a dictionary from type names to types.