Skip to main content

Tyr datalog/planning library

Project description

Tyr: Generalized Planning in C++20 and Python

Tyr is designed to address several challenges in modern planning systems:

  1. Unified grounded and lifted planning within a type-safe API.

  2. Rapid prototyping through Python bindings with type hints, backed by a high-performance C++ core.

  3. Support for expressive numeric planning formalisms across both grounded and lifted reasoning paradigms (see Supported PDDL Features).

  4. Integration of learning and reasoning by supporting collections of planning tasks over a shared planning domain.

Technical Overview

  • PDDL frontend: Tyr uses Loki to parse, normalize, and translate PDDL input. The parser is implemented with Boost and provides informative error messages for syntactically invalid input. The normalization pipeline largely follows the approach described in Section 4 of Concise finite-domain representations for PDDL planning tasks.

  • Datalog engine: Tyr implements a parallel semi-naive Datalog engine for lifted successor generation, axiom evaluation, relaxed planning graph heuristics, and task grounding. Its execution model is synchronous and supports both rule-level and grounding-level parallelism.

  • Ground planning: For grounded tasks, Tyr uses data structures inspired by The Fast Downward Planning System to efficiently identify applicable actions in a given state. Grounding often yields substantial performance improvements, although it is not always feasible for large tasks.

  • State representation: Tyr statically analyzes domain and problem files and partitions predicates, functions, and related structures into strongly typed categories such as static, fluent, and derived atoms. This design prevents accidental mixing of conceptually different entities. To represent sequences compactly, Tyr uses tree databases of perfectly balanced binary trees, allowing common subsequences to be shared through shared subtrees. As a special case, Tyr synthesizes finite-domain variables for fluent atoms in grounded planning, largely following the method described in Section 5 of Concise finite-domain representations for PDDL planning tasks, enabling more compact storage when grounding is feasible.

  • Memory model: Tyr stores generated data in hierarchically structured, geometrically growing buffers. For variable-sized objects, it uses Cista for serialization and zero-copy deserialization. This design allows derived buffers to inherit data from parent buffers without duplication. For example, multiple tasks can share a domain, and multiple workers can share task data.

Getting Started

The library consists of a formalism and a planning component. The formalism component is responsible for representing PDDL entities. The planning component provides functionality for implementing search algorithms, as well as off-the-shelf implementations of eager A*, lazy GBFS, and heuristics such as blind, max, add, and FF. Below is a minimal overview of the Python and C++ APIs for implementing custom search algorithms.

Python Interface

Pytyr is available at PyPI and can be installed with pip install pytyr.

Detailed examples are available in the python/examples directory:

  • structures.py – Parse and traverse all planning formalism structures.
  • builder.py – Create new planning formalism structures.
  • invariants.py – Synthesize invariants, access candidate variable bindings, and match atoms through unification.
  • astar_eager.py – Use and customize off-the-shelf search algorithms.
  • gbfs_lazy.py – Implement a custom search algorithm from scratch.

The Python interface for implementing search algorithms is:

# Recommended namespace aliases
from pytyr.common import ExecutionContext
import pytyr.formalism.planning as tfp
import pytyr.planning.lifted as tpl  # pytyr.planning.ground also exists

# Parse and translate a task over a domain.
parser = tfp.Parser("domain.pddl")
# Instantiate a lifted task.
task = tpl.Task(parser.parse_task("problem.pddl"))

# Instantiate a single-threaded execution environment.
execution_context = ExecutionContext(1)

# Instantiate the planning objects. Factories assign unique context indices so
# state views from different state repositories hash and compare correctly.
axiom_evaluator_factory = tpl.AxiomEvaluatorFactory()
state_repository_factory = tpl.StateRepositoryFactory()
successor_generator_factory = tpl.SuccessorGeneratorFactory()
axiom_evaluator = axiom_evaluator_factory.create(task, execution_context)
state_repository = state_repository_factory.create(task, axiom_evaluator)
successor_generator = successor_generator_factory.create(task, execution_context, state_repository)

# Get the initial node (state + metric value)
initial_node = successor_generator.get_initial_node()

# Get the labeled successor nodes (sequence of ground action + node)
labeled_successor_nodes = successor_generator.get_labeled_successor_nodes(initial_node)

C++ Interface

The C++ interface for implementing search algorithms is:

#include <tyr/tyr.hpp>

// Recommended namespace aliases.
namespace tfp = tyr::formalism::planning;
namespace tp = tyr::planning;

// Parse and translate a task over a domain.
auto parser = tfp::Parser("domain.pddl");
// Instantiate a lifted task.
auto task = tp::Task<tp::LiftedTag>::create(parser.parse_task("problem.pddl"));

// Instantiate a single-threaded execution environment
auto execution_context = tyr::ExecutionContext::create(1);

// Instantiate the planning objects. Factories assign unique context indices so
// state views from different state repositories hash and compare correctly.
auto axiom_evaluator_factory = tp::AxiomEvaluatorFactory<tp::LiftedTag>();
auto state_repository_factory = tp::StateRepositoryFactory<tp::LiftedTag>();
auto successor_generator_factory = tp::SuccessorGeneratorFactory<tp::LiftedTag>();

auto axiom_evaluator = axiom_evaluator_factory.create(task, execution_context);
auto state_repository = state_repository_factory.create(task, axiom_evaluator);
auto successor_generator = successor_generator_factory.create(task, execution_context, state_repository);

// Get the initial node (state + metric value).
auto initial_node = successor_generator->get_initial_node();

// Get the labeled successor nodes (sequence of ground action + node).
auto labeled_successor_nodes = successor_generator->get_labeled_successor_nodes(initial_node);

Dependencies

Tyr consumes native dependencies from Python packages:

uv pip install pyyggdrasil>=0.0.8 pypddl>=1.0.4
cmake -S . -B build \
  -DPython_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')" \
  -DPython3_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')" \
  -DCMAKE_PREFIX_PATH="$(python -c 'import pypddl, pyyggdrasil; print(f"{pypddl.native_prefix()};{pyyggdrasil.native_prefix()}")')"

For offline/local development, install the native providers from sibling source checkouts first:

cd ../yggdrasil
uv pip install --python ../tyr/.venv/bin/python .
cd ../loki
uv pip install --python ../tyr/.venv/bin/python .

Build Instructions

cmake -S . -B build \
  -DPython_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')" \
  -DPython3_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')" \
  -DCMAKE_PREFIX_PATH="$(python -c 'import pypddl, pyyggdrasil; print(f"{pypddl.native_prefix()};{pyyggdrasil.native_prefix()}")')" \
  -DTYR_BUILD_SHARED=ON \
  -DTYR_LINK_STATIC_DEPENDENCIES=OFF

cmake --build build -j16
cmake --install build --prefix=<path/to/installation-directory>

Optional targets are disabled by default and can be enabled during configure:

  • -DTYR_BUILD_TESTS=ON
  • -DTYR_BUILD_EXECUTABLES=ON
  • -DTYR_BUILD_PROFILING=ON
  • -DTYR_BUILD_PYTYR=ON

More detailed build instructions are available here.

Integration Instructions

The Python package pytyr installs Tyr's native headers, shared library, and CMake package config under pytyr.native_prefix(). It depends on pypddl for Loki and pyyggdrasil for third-party native dependencies:

import pypddl
import pyyggdrasil
import pytyr

print(pytyr.native_prefix())
print(pypddl.native_prefix())
print(pyyggdrasil.native_prefix())

Downstream CMake projects can then use:

cmake -S . -B build \
  -DCMAKE_PREFIX_PATH="$(python -c 'import pytyr, pypddl, pyyggdrasil; print(f"{pytyr.native_prefix()};{pypddl.native_prefix()};{pyyggdrasil.native_prefix()}")')"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytyr-0.0.15.tar.gz (437.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pytyr-0.0.15-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pytyr-0.0.15-cp313-cp313-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pytyr-0.0.15-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pytyr-0.0.15-cp312-cp312-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pytyr-0.0.15-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pytyr-0.0.15-cp311-cp311-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pytyr-0.0.15-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pytyr-0.0.15-cp310-cp310-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pytyr-0.0.15-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (5.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pytyr-0.0.15-cp39-cp39-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file pytyr-0.0.15.tar.gz.

File metadata

  • Download URL: pytyr-0.0.15.tar.gz
  • Upload date:
  • Size: 437.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytyr-0.0.15.tar.gz
Algorithm Hash digest
SHA256 1759e5f79a13ed2e1cf433ab435f5b5dbcda94c3d2887620cc11ddf2f5506b52
MD5 8c7262f5a9019fa58f3ae9b0c30f425b
BLAKE2b-256 bf442c8dec84591a8326c1c395870f6c8390508b7178483d97c9853c361e1d5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15.tar.gz:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 172507c704233992eebf19c86c711ca0e722fa788ffc03dc717aa228767874ba
MD5 41a63082fd0911e5f2663292810ea0ee
BLAKE2b-256 0fbbfd2de468ad1db966f6cf0d7afdb2812ece0454df7d295dde74bf8e272bf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1cc097af3cdeb1b451106db51ab6e274e50896335b99229ce80a1cea2ccf8cb
MD5 3ecd7b0dedde3fe820326de054caae8e
BLAKE2b-256 96a14371260179c4d9968933e3a6ce897325a3b8fbf7995ab40ca274a4e58b79

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3ab50bb4a52a8824673a18db7fb9d9eb9e3aed828ac4c9e940a03e969208f939
MD5 f4a60ff66e17168e3cc991e56ea8bc43
BLAKE2b-256 908879157ef5f2478c5c4890bc09e111b1d644df7437132bf566eb65c1de8236

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c00abc047946d9d7a2852e43d9d26ef070a01f8b00b367a8c9e1b4d5810b2549
MD5 8504562fd8b6b4d5a26e22da0d79b2ae
BLAKE2b-256 d10e1ad7d8ee37067a363b28839889dbe4ba64be1befb45f4b91c4c52ad6f803

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f32a8856e4b3d934fa9eedf9e13455c20ae6199c3390d05a115001ca16fb3d5d
MD5 50b17bd0838f98bf727b3e0849f9d93e
BLAKE2b-256 9adb16ae7dc81a05edce22df6d0aee4a1d5001d253a17290c285ae8673995d4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f03254afdb4e58069678782d3fff0b48163d669267a277327e0b70ae466dbf36
MD5 d7bb9903576a6f6b609674abe78e4ef5
BLAKE2b-256 a98f233ffbb128a02945fec128d52f6a3c200fa5935a1408a26ba0b4b15b97c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b6eee05916a074b3df9a08b2a16c29cf67c08cc79dff579945fd5e33c95094ab
MD5 86fe92a21a8b6fe7a8a207644636871b
BLAKE2b-256 7afe5b2fa8e7a8f842bd6b02f4e3fcb6f384bfd192b6cc07cf75b15d48707491

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d2ec53fa1fe077450661e1db1c44ab0f88e6a878e13ee506f9860e288a699c71
MD5 8b842f7420f6fbbd05b9a2bd35f6fbb6
BLAKE2b-256 0a4533d04ff0d4df7a0bcad3ba64f1bb9520786581aa70360309c3f59871b447

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 38070b35a3f7a3bdddd31295dafd128cf3cd9c2367a4607d0ef35aaf23f03c6f
MD5 c2a6e0dc5ff4ef4e66dcbcb90a890890
BLAKE2b-256 605c0f42045a31a6e03b0ed3f179a789abf83fdc9e49f75155f42071b3ee6741

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytyr-0.0.15-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.15-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20a410a35deb774b35a0dbd49113032b44c9ab3f3f7a914d08edc5b7b9c00a62
MD5 4ff055bd094f00b4bc25ac8d293eaa32
BLAKE2b-256 8af73105374d089bf8df863c2a85449066d934f3c4a0da7ed468b51892d0bec6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.15-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on planning-and-learning/tyr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page