abcorrea / asp-grounding-planning

0 stars 3 forks source link

ASP encoding to ground planning tasks

Encodes the relaxed-reachability of a PDDL planning task as a logic program. The canonical model of this program is equivalent to all reachable atoms (and actions). This can be used to find all possible ground atoms that are relaxed-reachable in the planning task. In fact, this is how Fast Downward grounds the input tasks. Similarly, this is how Powerlifted extracts delete-relaxation heurisitics without grounding the problem.

You can either do the traditional grounding in one pass or do a two-step grounding, which is slower but can ground larger tasks. For details, see Corrêa et al. (ICAPS 2023).

Installation

We recommend using a Python virtual environment. You need to use Python >= 3.7 to execute the scripts. Once inside the virtual environment, you can run

$ python setup.py install

or

$ pip install -e .

while in the root directory of the repository. You also need to have the grounder you want to use in your PATH (see below).

Basic Usage

There are two main scripts in the repo: generate-asp-model.py and count-ground-actions.py. The first one simply encodes the task as a Datalog program (with some options) and then grounds it using some off-the-shelf grounder; the second one counts or grounds (depending on the parameters) the actions of the task given a set of relaxed-reachable atoms. Usually, to run count-ground-actions.py, you need to have the output model from generate-asp-model.py stored.

To run the program generate-asp-model, execute

$ ./generate-asp-model.py -i /path/to/instance.pddl [-m MODEL-OUTPUT] [-t THEORY-OUTPUT]

where /path/to/instance.pddl is the path to a PDDL instance. It is necessary that there is a PDDL domain file in the same directory as instance.pddl, though. The script will infer the domain file automatically or you can pass it with parameter -d.

The program will generate the Datalog encoding corresponding to the PDDL task and ground it using some selected grounder (default: gringo). The Datalog file will be saved in MODEL-OUTPUT (default: output.theory); the canonical model (together with any other output from the grounder) will be saved in THEORY-OUTPUT (default: output.model).

There are some extra options one can use:

To run the count-ground-actions program for upper-bounding the number of action atoms in the grounding and for computing alternative groundings, you must set the following environment variables:

Then, you can execute

$ ./ count-ground-actions.py -m MODEL-OUTPUT -t THEORY-WITH-ACTIONS [--choices] [--output] [--extendedOutput] [--counter-path SCRIPT]

where MODEL-OUTPUT is the path to the MODEL-OUTPUT obtained with a call to the program above, and THEORY-WITH-ACTIONS is the path to the theory file containing action predicates obtained by the same call above (this file is automatically generated with the name output-with-actions.theory by the generate-asp-model.py script).

The key to this program is the counting/solving script used. The ones used in the experiments (Corrêa et al. ICAPS 2023) are:

There are other counting scripts in the codebase (lpcnt_nopp, lpcnt_omni, lpcnt_opt). They are different configurations that might work better for specific instances. However, they were not used in the aforementioned experiments.

There are some extra options that one can optionally turn on: