Metadata-Version: 2.4
Name: klimax-planner
Version: 1.0.0
Summary: Klimax: an HTN planner for HDDL, in Python
Keywords: planning,htn,hddl,hierarchical planning,robotics,plansys2
Author: Francisco Martín Rico
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Project-URL: Homepage, https://github.com/PlanSys2/klimax
Requires-Python: >=3.10
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Description-Content-Type: text/markdown

# Klimax in Python

Klimax is an HTN planner for HDDL. This module gives its library to Python: planning, checking
a domain and a problem, and verifying plans.

```python
import klimax

domain = open("domain.hddl").read()
problem = open("problem.hddl").read()

result = klimax.solve(domain, problem, timeout=30)
if result.status == klimax.Status.SOLVED:
    print(result.plan)                 # the format of the IPC HTN tracks
    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)
```

- `solve(domain, problem, timeout=0, decomposition=True, anytime=False, on_plan=None,
  verify=True)`: `status` is `SOLVED`, `UNSOLVABLE`
  (proved), `TIMEOUT`, `UNSUPPORTED`, `INVALID_INPUT` (see `diagnostics`) or `INTERNAL_ERROR`.
  Every plan is verified, independently of the search, before it is returned (`verify`).
  With `decomposition` it is also given as steps: of each task, its method, the values of the method's parameters and which
  step is each of its subtasks.
  With `anytime=True` it goes on after the first plan looking for better ones, calling
  `on_plan(plan, steps)` with each, until none is left or the time runs out; `optimal` says
  whether the last one was proved the best. Better is cheaper by the `:metric` of the problem
  when it adds up action costs, shorter when there is none. `cost` is the value of the metric
  for the plan (`None` without one).
- `check(domain, problem)`: every error found, with file, line and column.
- `verify(domain, problem, plan, decomposition=False)`: whether a plan in the IPC format
  solves the problem, and why not; with `decomposition`, a valid plan also as steps. `metric`
  is the value of the problem's metric at the end of a valid plan.

With durative actions or timed initial literals the plan has times: `makespan` is when it ends,
each step of `steps_of_plan` has `start` and `end` (a task, from the first of its actions to
the last), and in `plan` each action is written `id time: (action args) [duration]`.

Hierarchical problems with total or partial order, numeric fluents, action costs and time
(see the [roadmap](../docs/roadmap.md) for what of time is not planned with yet). To build from
source, Kairos must be installed with `-DKAIROS_INSTALL_CORE=ON`:

```
cmake -S . -B build -DKLIMAX_BUILD_PYTHON=ON -DCMAKE_PREFIX_PATH=<kairos prefix>
cmake --build build
PYTHONPATH=build/python python -c "import klimax; print(klimax.__version__)"
```
