Utilities

PDDL.jl provides a variety of utilities for working with and manipulating planning domains, including plan simulation, domain grounding, domain caching, and tools for domain and formula analysis.

Simulation

It is often useful to simulate the results of applying a series of actions to an initial state. PDDL.jl supports this with the Simulator data type, and the associated PDDL.simulate method.

PDDL.simulateFunction
simulate([sim=StateRecorder()], domain::Domain, state::State, actions)

Simulates the evolution of a PDDL domain as a sequence of actions are executed from an initial state. The type of simulator, sim, specifies what information is collected and returned.

By default, sim is a StateRecorder, which records and returns the state trajectory.

source

The following types of Simulator are provided, depending on what results are desired:

PDDL.StateRecorderType
StateRecorder(max_steps::Union{Int,Nothing} = nothing)

Simulator that records the state trajectory, including the start state.

source
PDDL.EndStateSimulatorType
EndStateSimulator(max_steps::Union{Int,Nothing} = nothing)

Simulator that returns the end state of simulation.

source

Grounding

Many planning algorithms and search heuristics benefit from grounding of actions and axioms with respect to the fixed set of objects in the initial state. PDDL.jl provides the GroundAction data type to represent grounded actions, as well as the groundactions and groundaxioms functions to convert lifted Actions and axiom Clauses into lists of grounded actions:

PDDL.groundactionsFunction
groundactions(domain::Domain, state::State, action::Action)

Returns ground actions for a lifted action in a domain and initial state.

source
groundactions(domain::Domain, state::State)

Returns all ground actions for a domain and initial state.

source
PDDL.groundaxiomsFunction
groundaxioms(domain::Domain, state::State, axiom::Clause)

Converts a PDDL axiom to a set of ground actions.

source
groundaxioms(domain::Domain, state::State)

Convert all axioms into ground actions for a domain and initial state.

source

PDDL.jl also provides the ground function, which can be used to ground specific actions:

PDDL.groundMethod
ground(domain::Domain, state::State, action::Action, args)

Return ground action given a lifted action and action args. If the action is never satisfiable given the domain and state, return nothing.

source
PDDL.groundMethod
ground(domain::Domain, state::State, action::Action)

Grounds a lifted action in a domain and initial state, returning a group of grounded actions.

source

The ground function can also be used to ground an entire domain with respect to an initial state, returning a GroundDomain that can be used in place of the original domain:

PDDL.groundMethod
ground(domain::Domain, state::State)
ground(domain::Domain, problem::Problem)

Grounds a lifted domain with respect to a initial state or problem.

source
PDDL.GroundDomainType
GroundDomain(name, source, actions)

Ground PDDL domain, constructed from a lifted source domain, with a dictionary of ground actions.

source

Caching

Some applications of the PDDL.jl interface may result in repeated calls to costly interface functions with the same set of input arguments (e.g. repeatedly determining the set of available actions in value iteration). In such cases, it is useful to be able to memoize the outputs of these functions. PDDL.jl supports this via CachedDomains:

PDDL.CachedDomainType
CachedDomain{D, Ks, Vs}

Wraps an existing domain of type D, caching the outputs of calls to a subset of interface methods. Ks is a tuple of method identifiers, and Vs is a a tuple of corresponding cache types.

source
PDDL.CachedDomainMethod
CachedDomain(source::Domain)
CachedDomain(source::Domain, method_keys)

Construct a CachedDomain from a source domain, along with the associated caches for each cached method. A list of method_keys can be provided, where each key is a Symbol specifying the method to be cached.

By default, the following methods are cached: [:available, :relevant, :infer_static_fluents, :infer_affected_fluents, :infer_axiom_hierarchy].

source

Analysis

Static analysis of domains, actions, and formulae is often used in a variety of downstream tasks such as grounding, compilation, and relevance pruning. PDDL.jl provides a suite of analysis tools that can be helpful for these purposes.

Domain Analysis

Certain analyses are performed on planning domains as whole (e.g. inferring the set of static fluents). The following domain-level analyses are provided by PDDL.jl:

PDDL.infer_relevant_fluentsFunction
infer_relevant_fluents(domain)

Infer fluents that are relevant to some action precondition.

source
infer_relevant_fluents(domain, goals)
infer_relevant_fluents(domain, goals, axiom_parents)

Infer fluents that are relevant to achieving a set of goal fluents.

source

An associated set of (un-exported) utility functions are provided:

PDDL.is_staticFunction
is_static(term, domain)
is_static(term, domain, statics)

Check if term is static or composed of static subterms.

source
PDDL.is_affectedFunction
is_affected(term, domain)
is_affected(term, domain, affected)

Check if term is affected by some action or composed of affected subterms.

source
PDDL.substitute_axiomsFunction
substitute_axioms(term, domain; ignore)

Substitute derived predicates in a term with their axiom bodies.

source

Formula Analysis

PDDL.jl also provides a list of utilities for analyzing formula properties (some of which may be specific to the domain they are defined in). Note that these utilities are not exported.

The following utilities determine top-level properties of a Term.

PDDL.is_global_predFunction
is_global_pred(name)

Return whether a symbol refers to global predicate.

source
is_global_pred(term)

Check if term is a global predicate (comparison, equality, etc.).

source
PDDL.is_funcFunction
is_func(term, domain)

Check if term is a non-Boolean fluent (i.e. function).

source
PDDL.is_global_funcFunction
is_global_func(name)

Return whether a symbol refers to global function.

source
is_global_func(term)

Check if term is a global function, including global predicates.

source
PDDL.is_fluentFunction
is_fluent(term, domain)

Check if term is a (non-external) domain fluent.

source
PDDL.is_literalFunction
is_literal(term)

Check if term is a literal (an atomic formula or its negation.)

source

The following utilities determine properties of a Term or any of its nested subterms.

PDDL.has_funcFunction
has_func(term, domain)

Check if term contains a non-Boolean fluent (i.e. function).

source
PDDL.has_typeFunction
has_type(term, domain)

Check if term contains a type predicate.

source

The PDDL.constituents function can be used to decompose a formula into a list of its constituent fluent terms: