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 theParser
trait.interning
- Enables string interning forName
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§
Structs§
- Action
Definition - An action definition.
- Action
Symbol - An action symbol name.
- Atomic
Formula Skeleton - An atomic formula skeleton.
- Atomic
Function Skeleton - 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.
- Basic
Function Term - Usage
- Constants
- A set of constants.
- Derived
Predicate - A derived predicate.
- Domain
- The
Domain
type specifies a problem domain in which to plan. - Domain
Constraints Def - A domain constraints definition; wraps a
ConGD
. - Durative
Action Definition - 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).
- Durative
Action Symbol - A durative action symbol.
- Effects
- An effect. Occurs e.g. in a
ActionDefinition
. - Equality
Atomic Formula - FAssign
Da - An timed effect assignment operation. Will perform the
specified assignment
at
TimeSpecifier
whenNumericFluents
is allowed. - FComp
- An fluent comparison used as part of a
GoalDefinition
whenNumericFluents
is allowed. - ForallC
Effect - Applies the specified effects for all listed variables.
- Function
Symbol - A function symbol name.
- Function
Term - A function term.
- Function
Type - A function type.
- Function
Typed - A typed function element.
- Function
Typed List - A list of typed elements.
- Functions
- A set of functions.
- GoalDef
- A problem goal definition; wraps a
PreconditionGoalDefinitions
. - Init
Elements - A wrapper around a list of
InitElement
values. - Length
Spec - Deprecated since PDDL 2.1.
- Metric
Spec - A metric specification.
- Name
- A name.
- Number
- A number.
- Objects
- A list of objects.
- Precondition
Goal Definitions - Zero, one or many precondition goal definitions.
- Predicate
- A predicate name.
- Predicate
Atomic Formula - Predicate
Definitions - A set of predicate definitions.
- Pref
ConG Ds - 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.
- Preference
Name - A name of a preference.
- Primitive
Type - A primitive type.
- Problem
- A domain-specific problem declaration.
- Problem
Constraints Def - A problem constraints definition; wraps a [
PrefConGD
]. - Requirements
- A set of domain requirements.
- Structure
Defs - A set of structure definitions.
- Timeless
- A timeless predicate.
- Typed
- A typed element.
- Typed
List - A list of typed elements.
- Types
- A set of types.
- Variable
- A variable name.
- WhenC
Effect - Applies the specified effects for all listed variables.
Enums§
- Assign
Op - An assignment operation.
- Assign
OpT - An assignment operation.
- Atomic
Formula - An atomic formula.
- Binary
Comp - A binary comparison operation.
- Binary
Op - A binary operation.
- CEffect
- A (potentially conditional) effect. Occurs as part of
Effects
. - Con2GD
- A type that represents either a
GoalDefinition
or an embeddedConGD
. - ConGD
- Usage
- Conditional
Effect - A conditional effect as used by
CEffect::When
andTimedEffect::Conditional
. - DOp
- Usage
- Duration
Constraint - Usage
- Duration
Value - A duration value, either a
Number
or anFExp
. - Durative
Action Effect - A durative action effect used in
DurativeActionDefinition
. - Durative
Action Goal Definition - 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.
- Goal
Definition - A goal definition.
- Init
Element - Usage
- Interval
- An interval used in
TimedGD::Over
. - Literal
- An
AtomicFormula
or its negated value. - MetricF
Exp - 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 anEffect
) or aConditionalEffect
. - Precondition
Goal Definition - A precondition goal definition.
- Pref
ConGD - Requirements
- Pref
TimedGD - A (preferred) timed goal definition.
- PreferenceGD
- A preferred goal definition.
- Requirement
- Domain requirements.
- Simple
Duration Constraint - A simple duration constraint.
- Structure
Def - A domain structure definition.
- Term
- A term, i.e. a
Name
,Variable
orFunctionTerm
. - Time
Specifier - A time specifier used in e.g.
TimedGD::At
andTimedEffect
. - Timed
Effect - 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>)
.