Crate pddl

Source
Expand description

§A PDDL 3.1 parser, strongly typed

This crates provides a PDDL 3.1 parser implementation based on nom.

§Default crate features

  • parser - Enables parsing of PDDL types through the Parser trait.
  • interning - Enables string interning for Name types to reduce memory footprint.

§Example

The two core types of a PDDL are Domain and Problem. This example shows how to parse them:

use pddl::{Parser, Domain, Problem};

const BRIEFCASE_WORLD: &'static str = r#"
    (define (domain briefcase-world)
        (:requirements :strips :equality :typing :conditional-effects)
        (:types location physob)
        (:constants B P D - physob)
        (:predicates (at ?x - physob ?y - location)
                     (in ?x ?y - physob))

        (: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)))))) )

        (:action put-in
            :parameters (?x - physob ?l - location)
            :precondition (not (= ?x B))
            :effect (when (and (at ?x ?l) (at B ?l))
                    (in ?x)) )

        (:action take-out
            :parameters (?x - physob)
            :precondition (not (= ?x B))
            :effect (not (in ?x)) )
    )
    "#;

const BRIEFCASE_WORLD_PROBLEM: &'static str = r#"
    (define (problem get-paid)
        (:domain briefcase-world)
        (:init (place home) (place office)
            (object p) (object d) (object b)
            (at B home) (at P home) (at D home) (in P))
        (:goal (and (at B office) (at D office) (at P home)))
    )
    "#;

let domain = Domain::from_str(BRIEFCASE_WORLD).unwrap();
let problem = Problem::from_str(BRIEFCASE_WORLD_PROBLEM).unwrap();

// All elements were parsed.
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_eq!(domain.structure().len(), 3);

// All elements were parsed.
assert_eq!(problem.name(), "get-paid");
assert_eq!(problem.domain(), "briefcase-world");
assert!(problem.requirements().is_empty());
assert_eq!(problem.init().len(), 9);
assert_eq!(problem.goals().len(), 3);

Re-exports§

pub use parsers::Parser;parser

Modules§

parsersparser
Provides parsing functions, as well as the Parser trait.

Structs§

ActionDefinition
An action definition.
ActionSymbol
An action symbol name.
AtomicFormulaSkeleton
An atomic formula skeleton.
AtomicFunctionSkeleton
A numeric fluent, similar to a predicate, is a variable which applies to zero or more objects and maintains a value throughout the duration of the plan.
BasicFunctionTerm
Usage
Constants
A set of constants.
DerivedPredicate
A derived predicate.
Domain
The Domain type specifies a problem domain in which to plan.
DomainConstraintsDef
A domain constraints definition; wraps a ConGD.
DurativeActionDefinition
A durative action represents an action which takes an amount of time to complete. The amount of time is expressible as either a value or as an inequality (allow for both fixed duration and ranged duration actions).
DurativeActionSymbol
A durative action symbol.
Effects
An effect. Occurs e.g. in a ActionDefinition.
EqualityAtomicFormula
FAssignDa
An timed effect assignment operation. Will perform the specified assignment at TimeSpecifier when NumericFluents is allowed.
FComp
An fluent comparison used as part of a GoalDefinition when NumericFluents is allowed.
ForallCEffect
Applies the specified effects for all listed variables.
FunctionSymbol
A function symbol name.
FunctionTerm
A function term.
FunctionType
A function type.
FunctionTyped
A typed function element.
FunctionTypedList
A list of typed elements.
Functions
A set of functions.
GoalDef
A problem goal definition; wraps a PreconditionGoalDefinitions.
InitElements
A wrapper around a list of InitElement values.
LengthSpec
Deprecated since PDDL 2.1.
MetricSpec
A metric specification.
Name
A name.
Number
A number.
Objects
A list of objects.
PreconditionGoalDefinitions
Zero, one or many precondition goal definitions.
Predicate
A predicate name.
PredicateAtomicFormula
PredicateDefinitions
A set of predicate definitions.
PrefConGDs
A list of PrefConGD values. This represents the (and ...) variant of the PDDL definition, modeling cases of zero, one or many values.
Preference
A preference.
PreferenceName
A name of a preference.
PrimitiveType
A primitive type.
Problem
A domain-specific problem declaration.
ProblemConstraintsDef
A problem constraints definition; wraps a [PrefConGD].
Requirements
A set of domain requirements.
StructureDefs
A set of structure definitions.
Timeless
A timeless predicate.
Typed
A typed element.
TypedList
A list of typed elements.
Types
A set of types.
Variable
A variable name.
WhenCEffect
Applies the specified effects for all listed variables.

Enums§

AssignOp
An assignment operation.
AssignOpT
An assignment operation.
AtomicFormula
An atomic formula.
BinaryComp
A binary comparison operation.
BinaryOp
A binary operation.
CEffect
A (potentially conditional) effect. Occurs as part of Effects.
Con2GD
A type that represents either a GoalDefinition or an embedded ConGD.
ConGD
Usage
ConditionalEffect
A conditional effect as used by CEffect::When and TimedEffect::Conditional.
DOp
Usage
DurationConstraint
Usage
DurationValue
A duration value, either a Number or an FExp.
DurativeActionEffect
A durative action effect used in DurativeActionDefinition.
DurativeActionGoalDefinition
A durative action goal definition.
FExp
A function/fluent expression used e.g. in a DurationValue.
FExpDa
Usage
FExpT
An f-exp-t.
FHead
A function declaration.
GoalDefinition
A goal definition.
InitElement
Usage
Interval
An interval used in TimedGD::Over.
Literal
An AtomicFormula or its negated value.
MetricFExp
A metric function expression.
MultiOp
An operation with multiple operands.
Optimization
An optimization instruction.
PEffect
A p-effect. Occurs as part of a CEffect (within an Effect) or a ConditionalEffect.
PreconditionGoalDefinition
A precondition goal definition.
PrefConGD
Requirements
PrefTimedGD
A (preferred) timed goal definition.
PreferenceGD
A preferred goal definition.
Requirement
Domain requirements.
SimpleDurationConstraint
A simple duration constraint.
StructureDef
A domain structure definition.
Term
A term, i.e. a Name, Variable or FunctionTerm.
TimeSpecifier
A time specifier used in e.g. TimedGD::At and TimedEffect.
TimedEffect
A timed effect, either conditional, continuous or derived from a fluent, e.g. DurativeActionEffect.
TimedGD
A timed goal definition.
Type
A type selection from <primitive-type> | (either <primitive-type>).

Traits§

ToTyped

Type Aliases§

NameLiteral
TermLiteral
TypedNames
TypedVariables