Skip to content

drexlerd/Loki

Repository files navigation

Loki

Loki is a C++20 library for syntactic and semantic parsing and translation of PDDL files. Loki separates the parsing and translation of domain and problem files, allowing users to effectively work with collection of problems.

The parser is based on the canonical parser structure proposed in the Boost Spirit X3 library.

The translator is based on the method presented in section four of the paper "Concise finite-domain representations for PDDL planning tasks by Malte Helmert (AIJ 2009)".

Supported PDDL Requirements

  • :strips
  • :typing
  • :negative-preconditions
  • :disjunctive-preconditions
  • :equality
  • :existential-preconditions
  • :universal-preconditions
  • :quantified-preconditions
  • :conditional-effects
  • :numeric-fluents
  • :adl
  • :derived-predicates
  • :action-costs
  • :non-deterministic (unsupported in the translator)
  • :probabilistic-effects (unsupported in the translator)

Dependencies

Loki depends on a fraction of Boost's header-only libraries (Fusion, Spirit x3, Container), its performance benchmarking framework depends on GoogleBenchmark, and its testing framework depends on GoogleTest.

Loki consumes these native dependencies from pyyggdrasil:

uv pip install pyyggdrasil==0.0.2
cmake -S . -B build \
  -DCMAKE_PREFIX_PATH="$(python -c 'import pyyggdrasil; print(pyyggdrasil.native_prefix())')"

For offline/local development, install pyyggdrasil from the sibling source checkout instead:

cd ../yggdrasil
uv pip install --python ../Loki/.venv/bin/python .

Build Instructions

# Configure with the pyyggdrasil native prefix
cmake -S . -B build \
  -DCMAKE_PREFIX_PATH="$(python -c 'import pyyggdrasil; print(pyyggdrasil.native_prefix())')"
# Build
cmake --build build -j16
# Install (optional)
cmake --install build --prefix=<path/to/installation-directory>

For shared-library builds, disable static dependency lookup:

cmake -S . -B build \
  -DCMAKE_PREFIX_PATH="$(python -c 'import pyyggdrasil; print(pyyggdrasil.native_prefix())')" \
  -DBUILD_SHARED_LIBS=ON \
  -DLOKI_LINK_STATIC_DEPENDENCIES=OFF

Integration Instructions

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

import pypddl
import pyyggdrasil

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

Downstream CMake projects can then use:

cmake -S . -B build \
  -DCMAKE_PREFIX_PATH="$(python -c 'import pypddl; print(pypddl.native_prefix())')"

Running the Executables

The executable illustrates how to use Loki. It is disabled by default and can be enabled with -DLOKI_BUILD_EXECUTABLES=ON.

./build/exe/loki data/gripper/domain.pddl data/gripper/p-2-0.pddl

Running the Tests

The testing framework depends on GoogleTest and requires the additional compile flag -DLOKI_BUILD_TESTS=ON to be set in the cmake configure step.

Performance Benchmarks

The benchmark framework depends on GoogleBenchmark and requires the additional compile flag -DLOKI_BUILD_BENCHMARKS=ON to be set in the cmake configure step. The results from the GitHub action can be viewed here.

IDE Support

We developed Loki in Visual Studio Code. We recommend the C/C++ and CMake Tools extensions by Microsoft. Install pyyggdrasil==0.0.2 into the Python environment used for configuring CMake, then set the following Cmake: Configure Args in the CMake Tools extension settings under Workspace:

  • -DCMAKE_PREFIX_PATH=<output of python -c 'import pyyggdrasil; print(pyyggdrasil.native_prefix())'>
  • -DLOKI_BUILD_TESTS=ON
  • -DLOKI_BUILD_BENCHMARKS=ON

After running CMake: Configure in Visual Studio Code (ctrl + shift + p), you should see all include paths being correctly resolved.

Acknowledgements

This work was partially supported by the Wallenberg AI, Autonomous Systems and Software Program (WASP) funded by the Knut and Alice Wallenberg Foundation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors