Domain

Struct Domain 

Source
pub struct Domain { /* private fields */ }
Expand description

The Domain type specifies a problem domain in which to plan.

§Usage

This is the top-level type of a domain description. See also Problem.

§Example

let input = r#"(define (domain briefcase-world)
      (:requirements :strips :equality :typing :conditional-effects)
      (:types location physob)
      (:constants
            B ; the briefcase
            P ; the paycheck
            D
            - physob)
      (:predicates (at ?x - physob ?y - location) ; an item is at a location
                   (in ?x ?y - physob))           ; an item is in another item
      (:constraints (and))

      ; Move briefcase from one location to another.
      (:action mov-B
           :parameters (?m ?l - location)
           :precondition (and (at B ?m) (not (= ?m ?l)))
           :effect (and (at B ?l) (not (at B ?m))
                        (forall (?z)
                            (when (and (in ?z) (not (= ?z B)))
                                  (and (at ?z ?l) (not (at ?z ?m)))))) )

      ; Put the item in the briefcase.
      (:action put-in
           :parameters (?x - physob ?l - location)
           :precondition (not (= ?x B))  ; the item must not be the briefcase itself
           :effect (when (and (at ?x ?l) (at B ?l))
                 (in ?x)) )

      ; Take the item out of the briefcase.
      (:action take-out
           :parameters (?x - physob)
           :precondition (not (= ?x B)) ; the item must be the briefcase itself
           :effect (not (in ?x)) )
    )"#;

let domain = Domain::from_str(input).unwrap();

assert_eq!(domain.name(), "briefcase-world");
assert_eq!(domain.requirements().len(), 4);
assert_eq!(domain.types().len(), 2);
assert_eq!(domain.constants().len(), 3);
assert_eq!(domain.predicates().len(), 2);
assert!(domain.constraints().is_empty());
assert_eq!(domain.structure().len(), 3);

Implementations§

Source§

impl Domain

Source

pub fn builder(name: Name, structure: StructureDefs) -> Self

Creates a builder to easily construct Domain instances.

Source

pub fn with_extends<N: IntoIterator<Item = Name>>(self, names: N) -> Self

Adds a list of optional domain names this domain definition extends upon. This is a PDDL 1.2 construct.

Source

pub fn with_requirements(self, requirements: Requirements) -> Self

Adds a list of optional domain requirements.

Source

pub fn with_types<T: Into<Types>>(self, types: T) -> Self

Adds a list of optional type declarations.

Source

pub fn with_constants<C: Into<Constants>>(self, constants: C) -> Self

Adds a list of optional constant declarations.

Source

pub fn with_predicates<P: Into<PredicateDefinitions>>( self, predicates: P, ) -> Self

Adds a list of optional predicate definitions.

Source

pub fn with_functions<F: Into<Functions>>(self, functions: F) -> Self

Adds a list of optional function definitions.

Source

pub fn with_constraints(self, constraints: DomainConstraintsDef) -> Self

Adds a list of optional constraints.

Source

pub fn with_timeless(self, timeless: Timeless) -> Self

Adds a list of timeless predicates.

Source

pub const fn name(&self) -> &Name

Gets the domain name.

Source

pub fn extends(&self) -> &[Name]

Gets the names of the domains this definition extends. This is a PDDL 1.2 construct.

Source

pub const fn requirements(&self) -> &Requirements

Returns the optional domain requirements. If no requirements were specified by the domain, STRIPS is implied.

Source

pub const fn types(&self) -> &Types

Returns the optional type declarations.

§Requirements

Requires Typing.

Source

pub const fn constants(&self) -> &Constants

Returns the optional constant definitions.

Source

pub const fn predicates(&self) -> &PredicateDefinitions

Returns the optional predicate definitions.

Source

pub const fn functions(&self) -> &Functions

Returns the optional function definitions.

§Requirements

Requires Fluents.

Source

pub const fn constraints(&self) -> &ConGD

Returns the optional constraint declaration.

Source

pub const fn structure(&self) -> &StructureDefs

Returns the domain structure definitions.

Trait Implementations§

Source§

impl AsRef<Functions> for Domain

Source§

fn as_ref(&self) -> &Functions

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<PredicateDefinitions> for Domain

Source§

fn as_ref(&self) -> &PredicateDefinitions

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Requirements> for Domain

Source§

fn as_ref(&self) -> &Requirements

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<StructureDefs> for Domain

Source§

fn as_ref(&self) -> &StructureDefs

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Types> for Domain

Source§

fn as_ref(&self) -> &Types

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Domain

Source§

fn clone(&self) -> Domain

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Domain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Parser for Domain

Available on crate feature parser only.
Source§

fn parse<'a, S: Into<Span<'a>>>(input: S) -> ParseResult<'a, Self::Item>

Parses a domain definition.

§Example
let input = r#"
 ; A toy domain.
 (define (domain briefcase-world)
      ; If no requirements are provided, :strips is implied.
      (:requirements :strips :equality :typing :conditional-effects)
      (:types location physob) ; type definitions could also be represented as predicates
      (:constants B P D - physob)
      (:predicates (at ?x - physob ?y - location)
                   (in ?x ?y - physob))
      (:constraints (and))

      ; Move briefcase from one location to another.
      (:action mov-B
           :parameters (?m ?l - location)
           :precondition (and (at B ?m) (not (= ?m ?l)))
           :effect (and (at B ?l) (not (at B ?m))
                        (forall (?z)
                            (when (and (in ?z) (not (= ?z B)))
                                  (and (at ?z ?l) (not (at ?z ?m)))))) )

      ; Put the item in the briefcase if it is not already in there.
      (:action put-in
           :parameters (?x - physob ?l - location)
           :precondition (not (= ?x B))
           :effect (when (and (at ?x ?l) (at B ?l))
                 (in ?x)) )

      ; Take the item out of the briefcase if it is in there.
      (:action take-out
           :parameters (?x - physob)
           :precondition (not (= ?x B))
           :effect (not (in ?x)) )
    )"#;

let (_, domain) = Domain::parse(input).unwrap();

assert_eq!(domain.name(), &Name::new("briefcase-world"));
assert_eq!(domain.requirements().len(), 4);
assert_eq!(domain.types().len(), 2);
assert_eq!(domain.constants().len(), 3);
assert_eq!(domain.predicates().len(), 2);
assert!(domain.constraints().is_empty());
assert_eq!(domain.structure().len(), 3);
§See also

See parse_domain.

Source§

type Item = Domain

Source§

fn parse_span(input: Span<'_>) -> ParseResult<'_, Self::Item>

Parses the input into the specified Item type.
Source§

fn from_str(input: &str) -> Result<Self::Item, Err<ParseError<'_>>>

Uses the Parser::parse method to parse the input and, if successful, discards the unparsed remaining input.
Source§

impl PartialEq for Domain

Source§

fn eq(&self, other: &Domain) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Domain

Auto Trait Implementations§

§

impl Freeze for Domain

§

impl RefUnwindSafe for Domain

§

impl Send for Domain

§

impl Sync for Domain

§

impl Unpin for Domain

§

impl UnwindSafe for Domain

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.