FOND Utilities and Helpers
Project description
FOND Utilities
Utilities for parsing and manipulating the FOND planning language (those containing non-deterministic oneof effects). At this point the system can:
- Check a file contains a legal FOND domain/problem.
- Normalize a FOND planning domain (i.e., have a single top-level
oneofclause in the effect). - Compute the all-outcome determinization of a FOND domain, where each non-deterministic action is replaced with a set of deterministic actions, each encoding one possible effect outcome of the action. A solution in the deterministic version amounts to a weak plan solution in the original FOND problem.
- Note the determinizer produces another PDDL domain and does not deal with the problem itself, unlike the SAS-based determinizers used in other planners (like PRP, FONDSAT, or CFOND-ASP) that are are based on the SAS translator in Fast-Downard classical planner and produce a SAS encoding of the determinization of a specific instance planning problem. For these determinizers that output SAS encodings, please refer to the individual planners or the translator-fond repo.
[!IMPORTANT] The system accepts effects that are an arbitrary nesting of
oneof, conditional effects, andand. See section Format allowed on effects at the bottom about format accepted.
Install
The fond-utils system can be installed (as a package) directly from its PyPi repository:
$ pip install fond-utils
Alternatively, it can be installed directly from the repo:
$ pip install git+https://github.com/AI-Planning/fond-utils
or, clone the repository and install:
$ git clone https://github.com/AI-Planning/fond-utils
$ cd fond-utils
$ pip install .
The system already includes a CLI console application fond-utils that will generally be the tool to use. To check the installation was successful just run:
$ fond-utils -h
usage: fond-utils [-h] --input INPUT [--output OUTPUT] [--outproblem OUTPROBLEM] [--prefix PREFIX] [--suffix SUFFIX]
[--console]
{check,determinize,normalize}
Utilities to process FOND PDDL
positional arguments:
{check,determinize,normalize}
options:
-h, --help show this help message and exit
--input INPUT Input domain file
--output OUTPUT Output domain file
--outproblem OUTPROBLEM
Optional output problem file
--prefix PREFIX Prefix for determinized action outcome identifier (Default: _DETDUP_)
--suffix SUFFIX Suffix for determinized action outcome identifier
--console Print the domain after processing
[!NOTE] The scripts on this system relies on the pddl parser, which can be easily installed via PyPi repository (
pip install pddl). The pddl system relies itself on the lark parsing library. The fond-utils system, however, extendspddlto accept single files containing both the domain and the problem instance, and will be extended further to accept labelled outcomes in the effects.
Quickstart
You can use the fond-utils package in two ways: as a library, and as a CLI tool.
As a CLI application tool
To just check that the PDDL input file is parsed well, use the command check and report to console:
$ fond-utils check --input https://raw.githubusercontent.com/AI-Planning/fond-utils/refs/heads/main/tests/domain_03.pddl
Since the system is provided as a module fondutils, this would be equivalent to:
$ python -m fondutils check --input https://raw.githubusercontent.com/AI-Planning/fond-utils/refs/heads/main/tests/domain_03.pddl
Note this would work if you have cloned the repo rather than installed the actual package; for example:
$ git clone https://github.com/AI-Planning/fond-utils
$ cd fond-utils
$ python -m fondutils check --input tests/domain_03.pddl
Normalize a domain
To simply perform normalization (i.e., have a single top-level oneof clause in the effect):
$ fond-utils normalize --input tests/domain_05.pddl --output normalized-domain.pddl
Example test/domain_05.pddl includes some complex (nested) oneof effects. The name of the normalized domain will be the original name with suffix _NORM.
All-outcome determinization
To perform the determinization, use the command determinize:
$ fond-utils determinize --input tests/domain_03.pddl --output determinized-domain.pddl
The name of the determinized domain will be the original name with a possible suffix separated with an underscore (default _NEW). Use --suffix-domain "" to use no suffix (same name as original domain).
The deterministic versions of a non-deterministic action are enumerated (starting from 1) with possible prefix and suffix on the number, each part separated with an underscore _. For example, the third deterministic action of operator move would be named move_<PREFIX>_3_<SUFFIX>; if no prefix or suffix is set, it would be just move_3.
[!TIP] To change the default operator name prefix
DETDUPuse the options--prefix, and to add a suffix after the number, use--suffix. To set the suffix for the domain name use--suffix-domain. To get the resulting PDDL printed on console use--console:
$ fond-utils determinize --input tests/domain_03.pddl --prefix "PRE" --suffix "SUF" --suffix-domain "NEW" --console
(define (domain blocks-domain_NEW)
(:requirements :equality :typing)
(:types block)
(:predicates (clear ?b - block) (emptyhand) (holding ?b - block) (on ?b1 - block ?b2 - block) (on-table ?b - block))
(:action pick-up_PRE_1_SUF
:parameters (?b1 - block ?b2 - block)
:precondition (and (not (= ?b1 ?b2)) (emptyhand) (clear ?b1) (on ?b1 ?b2))
:effect (and (holding ?b1) (clear ?b2) (not (emptyhand)) (not (clear ?b1)) (not (on ?b1 ?b2)))
)
(:action pick-up_PRE_2_SUF
:parameters (?b1 - block ?b2 - block)
:precondition (and (not (= ?b1 ?b2)) (emptyhand) (clear ?b1) (on ?b1 ?b2))
:effect (and (clear ?b2) (on-table ?b1) (not (on ?b1 ?b2)))
)
(:action pick-up_PRE_3_SUF
:parameters (?b1 - block ?b2 - block)
:precondition (and (not (= ?b1 ?b2)) (emptyhand) (clear ?b1) (on ?b1 ?b2))
:effect (and )
)
(:action put-down
:parameters (?b - block)
:precondition (holding ?b)
:effect (and (on-table ?b) (emptyhand) (clear ?b) (not (holding ?b)))
)
)
This resulting PDDL domain is now deterministic and can then be used as input to the original Fast-Downward SAS translator.
[!WARNING] If the new domain is named with a suffix (as in the default case), existing problem instances may not be compatible with the new domain, as they will still refer to the original domain in the
:domainsection. If these problem instances will be used with the new PDDL encoding, either use no suffix for the domain name (so it will keep the same name as the original) or change the:domainsection in the problem instances to match the new name that includes the suffix (by setting private property_domain_name). Note that if the file parsed included the problem as well, the CLI tool will do such update so that the resulting problem will have its domain name matching the new domain.
As a library
This is an example of how we can normalize and determinize a PDDL non-deterministic domain programmatically:
import io
import inspect
from pathlib import Path
import requests
from pddl import parse_domain
from pddl.formatter import domain_to_string
from fondutils.determizer import determinize
from fondutils.normalizer import normalize
# get a domain from AI-Planning/fond-domains repo
URL_DOMAIN = "https://raw.githubusercontent.com/AI-Planning/fond-domains/refs/heads/main/benchmarks/blocksworld-2/domain.pddl"
r = requests.get(URL_DOMAIN)
domain_file = io.StringIO(r.content.decode("utf-8"))
domain = parse_domain(domain_file)
# compute the normalization of the domain and print it on console
domain_norm = normalize(domain)
print(domain_to_string(domain_norm))
# compute the determinization of the domain and print it on console
domain_det = determinize(domain)
print(domain_to_string(domain_det))
To parse parse files that contain both domain and problem together, we can use function parse_domain_problem in fondutils.pddl. Note how the following code also sets explicit domain suffix and operators prefixes and suffixes, and how we update the domain name in the problem to match the new one:
import io
import inspect
from pathlib import Path
import requests
from pddl.formatter import domain_to_string, problem_to_string
from fondutils.pddl import parse_domain_problem
from fondutils.determizer import determinize
from fondutils.normalizer import normalize
# get a domain from AI-Planning/fond-domains repo
URL_DOMAIN = "https://raw.githubusercontent.com/AI-Planning/fond-utils/refs/heads/main/tests/domprob_03.pddl"
r = requests.get(URL_DOMAIN)
domain_file = io.StringIO(r.content.decode("utf-8"))
domain, problem = parse_domain_problem(domain_file)
# compute the determinization of the domain and print it on console
domain_det = determinize(domain, dom_suffix="XYZ", op_prefix="PRE", op_suffix="SUF")
print(domain_to_string(domain_det))
# update domain name in problem to match new domain name and print updated problem
problem._domain_name = domain_det.name
print(problem_to_string(problem))
Format allowed on effects
The determinizer accepts effects that are an arbitrary nesting of oneof, conditional effects, and and.
If the effect is just one oneof clause, then it corresponds to the Unary Nondeterminism (1ND) Normal Form without conditionals in:
- Jussi Rintanen: Expressive Equivalence of Formalisms for Planning with Sensing. ICAPS 2003: 185-194
When there are many oneof clauses in a top-level and effect, the cross-product of all the oneof clauses will determine the deterministic actions.
Authors
- Sebastian Sardina (ssardina) - RMIT University
- Christian Muise (haz) - Queen's University
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fond_utils-0.2.0.tar.gz.
File metadata
- Download URL: fond_utils-0.2.0.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
866b23ebb8477c9beb7de61b8fe3ae253fb13c7f9768580cf4dfa68a6d77f1f2
|
|
| MD5 |
01c60c36efc1bb86b9d6161a7e3e3572
|
|
| BLAKE2b-256 |
258a06a13764ab89128fc0972c22e3ce66136db05e735cac384bd77afa3b5a9c
|
Provenance
The following attestation bundles were made for fond_utils-0.2.0.tar.gz:
Publisher:
python-publish.yml on AI-Planning/fond-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fond_utils-0.2.0.tar.gz -
Subject digest:
866b23ebb8477c9beb7de61b8fe3ae253fb13c7f9768580cf4dfa68a6d77f1f2 - Sigstore transparency entry: 1151900910
- Sigstore integration time:
-
Permalink:
AI-Planning/fond-utils@f0880ba707c6320899795705ca0bac6093a0a0bb -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/AI-Planning
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f0880ba707c6320899795705ca0bac6093a0a0bb -
Trigger Event:
release
-
Statement type:
File details
Details for the file fond_utils-0.2.0-py3-none-any.whl.
File metadata
- Download URL: fond_utils-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8c9f0215e76fd19863a678ab525c7e22694944fc40e50d30fa7f214ad475f8a
|
|
| MD5 |
cb7de9dc4c7e86c758433f55b2c6cc1e
|
|
| BLAKE2b-256 |
77b677c73a2f04241fea243d098ad7c1ea09ec166777f9df98d42c0bf7a75664
|
Provenance
The following attestation bundles were made for fond_utils-0.2.0-py3-none-any.whl:
Publisher:
python-publish.yml on AI-Planning/fond-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fond_utils-0.2.0-py3-none-any.whl -
Subject digest:
e8c9f0215e76fd19863a678ab525c7e22694944fc40e50d30fa7f214ad475f8a - Sigstore transparency entry: 1151900966
- Sigstore integration time:
-
Permalink:
AI-Planning/fond-utils@f0880ba707c6320899795705ca0bac6093a0a0bb -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/AI-Planning
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f0880ba707c6320899795705ca0bac6093a0a0bb -
Trigger Event:
release
-
Statement type: