Skip to content
PlanSys2Public

About

Klimax: an HTN planner for HDDL in C++20, usable as a library, an executable, from Python and from the Unified Planning Framework

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Klimax logo

Klimax (κλῖμαξ)

An HTN planner for HDDL in C++20, usable as a library, as an executable, from Python and from the Unified Planning Framework.

CI License: Apache-2.0 C++20 CMake 3.22 or newer Python 3.10 or newer Linux x86-64 and ARM64 HDDL 1.0 and 2.1 PyPI: klimax-planner Unified Planning engine: up-klimax

Klimax (Greek for ladder) plans with hierarchies of tasks. It reads HDDL, the language of the hierarchical tracks of the International Planning Competition (IPC), and gives back the sequence of actions together with its decomposition: which method was applied to each task and what each of its subtasks became. It is developed within the PlanSys2 organization, next to Kairos, whose modules it is built on (parser, grounder, Datalog engine, the evaluator and the validator of plans). It does not depend on ROS.

Status: version 1.0.0 (changelog). Klimax plans HDDL 1.0 problems (total and partial order) and those of HDDL 2.1: numeric fluents, durative actions (also ones that must run at once), timed initial literals, durative methods, orderings between the starts and the ends of tasks, and constraints on durations and on the states of the plan. The roadmap says what of them is checked but not yet planned with.

How it compares: on the benchmark of the HTN tracks of IPC 2023, with every plan checked by the IPC verifier and the same limits for all, Klimax solves 626 of the 761 total-order problems in 30 s (the best of the other thirteen configurations measured, 494) and 251 of the 283 partial-order ones (the best of the other seven, 207). Results by domain, where it is behind and the method in docs/results.md and docs/baseline.md.

What it does

  • Plans totally and partially ordered problems, with method preconditions, constraints between variables, the conditions and effects of ADL, numeric fluents, action costs and fluents whose value is an object.
  • Proves when a problem has no plan, instead of running out of time.
  • Anytime: after the first plan it goes on to better ones and, when none is left, says that the plan is the best: the cheapest by the metric of the problem when it adds up action costs, the shortest when there is no metric.
  • Verifies hierarchical plans in the format of the IPC, independently of the planner, and its own before returning them: a plan the verifier rejects is reported as an internal error, never given.
  • Checks a domain and a problem and reports every error with file, line and column.
  • Library first: no global state, a time limit on every call, plans returned as data.

Using it

Executable

klimax DOMAIN PROBLEM [--timeout S]           # the plan and its decomposition, in the IPC format
klimax DOMAIN PROBLEM --timeout S --anytime   # go on to better plans; says if none is better
klimax DOMAIN PROBLEM --tree                  # the plan as a tree, to read it
klimax --tree DOMAIN PROBLEM PLAN             # a plan in the IPC format, verified, as a tree
klimax DOMAIN PROBLEM --timeline              # a plan with times as a chart: what runs at once
klimax DOMAIN PROBLEM --no-verify             # skip the check of the plan before writing it
klimax --check DOMAIN PROBLEM                 # read the input and report every error
klimax --verify DOMAIN PROBLEM PLAN           # check a plan in the format of the IPC HTN tracks

Exit codes: 0 solved, 10 unsolvable (proved), 11 out of time, 12 not supported, 1 errors in the input.

C++

#include <klimax/klimax.hpp>

klimax::SolveOptions options;
options.seconds = 30;
klimax::SolveResult result = klimax::solve(domain_text, problem_text, options);
if (result.status == klimax::Status::Solved) {
  std::cout << result.plan;  // actions and decomposition, IPC format
}
find_package(klimax REQUIRED)
target_link_libraries(my_target PRIVATE klimax::klimax)

Python

pip install klimax-planner (Linux, x86-64 and arm64, Python 3.10 or later).

import klimax

result = klimax.solve(domain_text, problem_text, timeout=30)
if result.status == klimax.Status.SOLVED:
    for step in result.steps_of_plan:  # each action; each task with its method and subtasks
        print(step.id, step.task, step.args, step.method, step.subtasks)

More in python/README.md.

Unified Planning Framework

up-klimax makes Klimax an engine of the Unified Planning Framework: a oneshot and anytime planner for hierarchical problems, a validator of hierarchical plans and a compiler.

Building

Klimax needs Kairos installed with its internal modules (kairos::core):

git clone https://github.com/PlanSys2/kairos.git
git clone https://github.com/PlanSys2/klimax.git

cmake -S kairos -B build-kairos -DKAIROS_INSTALL_CORE=ON -DCMAKE_INSTALL_PREFIX=$PWD/prefix
cmake --build build-kairos -j && cmake --install build-kairos

cmake -S klimax -B build-klimax -DCMAKE_PREFIX_PATH=$PWD/prefix
cmake --build build-klimax -j
ctest --test-dir build-klimax --output-on-failure
./build-klimax/src/cli/klimax --version

Add -DKLIMAX_BUILD_PYTHON=ON for the Python module (needs nanobind). In a colcon workspace: colcon build --cmake-args -DKAIROS_INSTALL_CORE=ON.

For development: -DKLIMAX_SANITIZE="address;undefined" builds with AddressSanitizer and UndefinedBehaviorSanitizer. The fuzz targets in fuzz/ (the HDDL parser, check, verify, and solve, whose plans must all verify) replay their seeds as tests. With Clang, -DKLIMAX_BUILD_FUZZERS=ON builds them as libFuzzer binaries.

Documents

License

Apache-2.0.

About

Klimax: an HTN planner for HDDL in C++20, usable as a library, an executable, from Python and from the Unified Planning Framework

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages