Klimax is an HTN planner for HDDL. This module gives its library to Python: planning, checking a domain and a problem, and verifying plans.
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):statusisSOLVED,UNSOLVABLE(proved),TIMEOUT,UNSUPPORTED,INVALID_INPUT(seediagnostics) orINTERNAL_ERROR. Every plan is verified, independently of the search, before it is returned (verify). Withdecompositionit 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. Withanytime=Trueit goes on after the first plan looking for better ones, callingon_plan(plan, steps)with each, until none is left or the time runs out;optimalsays whether the last one was proved the best. Better is cheaper by the:metricof the problem when it adds up action costs, shorter when there is none.costis the value of the metric for the plan (Nonewithout 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; withdecomposition, a valid plan also as steps.metricis 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 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__)"