machetli.pddl — PDDL Files¶
This package allows transforming PDDL input files. Usually, in a Machetli script you will use it in the following way:
from machetli import pddl
initial_state = pddl.generate_initial_state("path/to/domain.pddl", "path/to/problem.pddl")
successor_generators = [pddl.RemoveActions(), ...]
You can then start your Machetli search using the initial PDDL problem
initial_state and a set of PDDL successor generators
successor_generators. Finally, write out your results using
pddl.write_files(result, "path/to/result-domain.pddl", "path/to/result-problem.pddl")
where result is the value returned by the
search function.
The successor generators described below denote possible transformations.
-
class
machetli.pddl.RemoveActions[source]¶ For each action schema in the PDDL domain, generate a successor where this action schema is removed. The order of the successors is randomized.
-
class
machetli.pddl.RemoveObjects[source]¶ For each object in the PDDL problem, generate a successor that removes this object from the PDDL task. The order of the successors is randomized.
-
class
machetli.pddl.RemovePredicates(replace_with='dynamic')[source]¶ For each predicate in the PDDL domain, generate a successor where this predicate is compiled away. This is accomplished by scanning the entire task for the atom to be removed, instantiating each instance of this atom with a constant according to
replace_with:"true"replaces all atoms of the removed predicate with true,"false"replaces all atoms of the removed predicate with false, and"dynamic"(default) replaces an atom of the removed predicate with true if it occurs positively and with false otherwise.
The order of the successors is randomized.
-
machetli.pddl.generate_initial_state(domain_path: Union[pathlib.Path, str], task_path: Union[pathlib.Path, str]) → dict[source]¶ Parse the PDDL task defined in the given PDDL files.
- Returns
a dictionary pointing to the task specified in the files.
-
machetli.pddl.run_evaluator(evaluate)[source]¶ Load the state passed to the script via its command line arguments, then run the given function evaluate on the domain and problem encoded in the state, and exit the program with the appropriate exit code. If the function returns
True, useEXIT_CODE_BEHAVIOR_PRESENT, otherwise useEXIT_CODE_NOT_BEHAVIOR_PRESENT. In addition to running the evaluator, this function creates the PDDL files as ‘domain.pddl’ and ‘problem.pddl’ in the current directory.This function is meant to be used as the main function of an evaluator script. Instead of a path to the state, the command line arguments can also be paths to a PDDL domain and problem (where the domain can be omitted if it can be found with automated naming rules). This is meant for testing and debugging the evaluator directly on PDDL input.
- Parameters
evaluate – is a function taking filenames of a PDDL domain and problem file as input and returning
Trueif the specified behavior occurs for the given instance, andFalseif it doesn’t. Other ways of exiting the function (exceptions,sys.exitwith exit codes other thanEXIT_CODE_BEHAVIOR_PRESENTorEXIT_CODE_BEHAVIOR_NOT_PRESENT) are treated as failed evaluations by the search.