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.planning 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 = ygg::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:

  • pyyggdrasil >= 0.0.18, < 0.1 for shared third-party native dependencies.
  • pypddl >= 1.0.11, < 1.1 for Loki's PDDL parser library, headers, and CMake package.

The shared workspace layout, layered install order, and the common build-from-source and CMake-integration patterns are documented in the Planning and Learning build instructions; the sections below cover tyr/pytyr-specific details.

Build C++

Install Tyr's native dependency providers into the active Python environment, then configure CMake with their native prefixes:

python -m pip install 'pyyggdrasil>=0.0.18,<0.1' 'pypddl>=1.0.11,<1.1'

cmake -S . -B build \
  -DPython_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')" \
  -DPython3_EXECUTABLE="$(python -c 'import sys; print(sys.executable)')"

cmake --build build -j4

CMake discovers the installed provider packages automatically through cmake/bootstrap_pyyggdrasil.cmake (which locates pyyggdrasil and adds its native prefix to CMAKE_PREFIX_PATH; find_package(yggdrasil) then resolves the rest of the chain) and links against the yggdrasil::yggdrasil and loki::parsers targets. To point at different prefixes explicitly:

cmake -S . -B build \
  -DCMAKE_PREFIX_PATH="$(python -m pyyggdrasil --prefix);$(python -m pypddl --prefix)"

CMake options:

Option Default Description
TYR_BUILD_TESTS OFF Build Tyr tests.
TYR_BUILD_EXECUTABLES OFF Build Tyr executables.
TYR_BUILD_PROFILING OFF Build Tyr profiling targets.
TYR_BUILD_PYTYR OFF Build pytyr Python bindings.
TYR_ENABLE_FMT_FORMATTERS ON Enable the public fmt::formatter specializations of Tyr, Loki, and yggdrasil (TYR_/LOKI_/YGG_ENABLE_FMT_FORMATTERS macros, all default-on in the headers).
TYR_HEADER_INSTANTIATION OFF Enable stronger inlining at higher compile-time cost.
TYR_ENABLE_INNER_PARALLELISM OFF Enable inner rule parallelism.
TYR_USE_LLD ON Use LLVM lld when available.
TYR_ENABLE_LTO ON Enable link-time optimization for optimized builds.
TYR_STATE_STORAGE_POLICY Tree State storage backend; accepted values are Tree and Hashset.

Install Tyr from a configured build directory with:

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

More detailed Tyr-specific build instructions are available in docs/BUILD.md.

Build Python

python -m pip install .[test]
pytest python/tests

CMake Integration

This section covers pytyr-specific paths and targets; the general pattern for consuming the native prefixes from CMake is in the common CMake integration instructions.

The Python package pytyr installs Tyr's native headers, shared library, and CMake package config under pytyr.native_prefix(). Use pytyr.cmake_prefix() and pytyr.cmake_dir() (or python -m pytyr --prefix / --cmake-dir from the shell) to locate them. Downstream CMake projects should include the native prefixes of pytyr and its native package dependencies in CMAKE_PREFIX_PATH:

cmake -S . -B build \
  -DCMAKE_PREFIX_PATH="$(python -m pyyggdrasil --prefix);$(python -m pypddl --prefix);$(python -m pytyr --prefix)"

Tyr exports the tyr::core aggregate target.

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.25.tar.gz (404.2 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.25-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

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

pytyr-0.0.25-cp313-cp313-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pytyr-0.0.25-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

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

pytyr-0.0.25-cp312-cp312-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pytyr-0.0.25-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

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

pytyr-0.0.25-cp311-cp311-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pytyr-0.0.25-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

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

pytyr-0.0.25-cp310-cp310-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pytyr-0.0.25-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

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

pytyr-0.0.25-cp39-cp39-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pytyr-0.0.25.tar.gz
  • Upload date:
  • Size: 404.2 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.25.tar.gz
Algorithm Hash digest
SHA256 302f08f0219bc8966376e703424605dddc55a0f6930ea0824fd355e2c88feb74
MD5 cc30c3b75df45e3c3779abef0f5249a4
BLAKE2b-256 108208c5ecabe30013dcbd6b63c0fbfb435df5de0ad5bc3995a51f471bb1d614

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25.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.25-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2240a290030e0375670da8b5c28647f65b234cfe205070c0e7c1ad096cd4fad5
MD5 e60371ea65b89b1977e575f3d763a737
BLAKE2b-256 2e969208ecdc164276de2bce93f018251806a6c44eb0ac4cdf65a0756bd0df6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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.25-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5dbd7f19a7a90de3fb4954da7018b659dbcca7f9937d9ed6388cd70dbb72178d
MD5 64394888a753228fc520e4091481a93a
BLAKE2b-256 ed1fa0dfdab761192bbbbcd273f83286d7ce8418b4dfae7c6eb4e178f9b2a233

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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.25-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6ec051220008142c5dbc511d58366b40ef1a7f19b66e7ab68066a5755107e47e
MD5 c794898487a2a43576a7589737cbf881
BLAKE2b-256 68a824c4a4de7bc63a8c770e35f7e5ef036c6abace563f0b823f63fa8df657f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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.25-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c71be49cb1690ff334c29f5d3fcaac4978c4d50d13e3242c0027a1a33631dab
MD5 377b6549a34466b9387d4a3fb13581a5
BLAKE2b-256 ac2b31cc7f99a8bf9e3094be9d2d2088fd8add833c47b2015298a91458e63344

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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.25-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 22e01da58b4f11858a2003544a1b42c76d41eb7d73fc35a918f911aa6897c7c8
MD5 5ffd589a3517a908fbc83439f4687aa3
BLAKE2b-256 f7905c5a835a4c99a7a09856e681075bfcbed77babf92c9c6a7edc3313a5c4e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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.25-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac298288ef7f2f63e1806c549c9cef2b988e55a56c9603992c183391e64255c1
MD5 2e9e60b6549fe484ec878f7b8bddb101
BLAKE2b-256 7513527c381759ddcec2916117b610705b2bd8fedcb7191caec2cf869cf05d49

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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.25-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5e0d3af89679544604ee79b96760634a4e9d44eb6f2c9218833089e26b86d086
MD5 7833371fade483f996740bdc2a5c14d2
BLAKE2b-256 1037540e11481a1b95b147bae745ce52ea092c60fd69c4a11685bbfeeee60bf8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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.25-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d15968f9bf33fb8e70a982b6001b3527d07a39cf19fa9cc0adcfbec4bd2cab7
MD5 d56684e7d697b3d55855c2683196c7f2
BLAKE2b-256 468be749beb60a1ebaa8db58e6f2434cc6336196c65d4a95b827c8b93c5797d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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.25-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3e3fdec39b46d9449b30a87fc111eb39a65d16c47c833c05d222f516a2e9ed16
MD5 d04cf4548c77ae10a26c6b26b6408c45
BLAKE2b-256 0a742ea8ed907c7b9044e80cbfcfe1c18bdb150a64dcb9bfbc90f21bd7463d3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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.25-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pytyr-0.0.25-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b3301a85583aa4878642865d073aba34cbb5dfdeedee2d2c9c7ac082f1b9a06
MD5 f2f96cbf7323027a1c39098dc05e8cbf
BLAKE2b-256 c724972eccf8fad5979edfbdaac7ce57bf4f7f91b8e4f411378c379fa417eed4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytyr-0.0.25-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