PDDL Planning Domains (puxle.pddls)¶
PuXle supports the STRIPS subset of PDDL with automatic grounding and JAX-optimized state representation.
PDDL¶
- class puxle.pddls.pddl.PDDL[source]¶
Bases:
PuzzlePuXle wrapper that turns a PDDL domain + problem into a
Puzzle.Supports the STRIPS subset of PDDL:
Positive and negative preconditions (conjunctive).
Add / delete effects (no conditional or quantified effects).
Conjunctive positive goals.
Typed objects with type-hierarchy resolution.
The state is a packed boolean vector over grounded atoms (1 bit per atom via xtructure bitpacking). The solve-config stores a goal mask rather than a full target state, enabling partial-goal problems.
The class delegates heavy lifting to helper modules:
type_system— type hierarchy extraction.grounding— predicate and action grounding.masks— JAX mask construction.formatting— pretty-printing utilities.state_defs— dynamic state/solve-config classes.
- Parameters:
- __init__(domain, problem, **kwargs)[source]¶
Initialize PDDL puzzle from domain and problem (files or objects).
- classmethod from_preset(domain, problem=None, *, problem_basename=None, **kwargs)[source]¶
Create a PDDL instance by resolving absolute paths to data under puxle/data/pddls/.
This mirrors the absolute-path loading style used by puzzles like Sokoban.
- Parameters:
- Returns:
Initialized PDDL environment.
- Return type:
- define_solve_config_class()[source]¶
Define solve config with goal mask instead of target state.
- Return type:
- get_initial_state(solve_config, key=None, data=None)[source]¶
Return initial state.
- Return type:
- Parameters:
solve_config (SolveConfig)
- get_actions(solve_config, state, action, filled=True)[source]¶
Get the next state and cost for a given action using JAX.
- is_solved(solve_config, state)[source]¶
Check if state satisfies goal conditions.
- Return type:
- Parameters:
solve_config (SolveConfig)
state (State)
- get_string_parser()[source]¶
Return string parser for states. If a solve_config is provided, annotate goal atoms.
- Return type:
- get_img_parser()[source]¶
Return image parser for states. If a solve_config is provided, annotate goal atoms.
- Return type:
- get_solve_config_string_parser()[source]¶
Return string parser for solve config with goal mask.
- Return type:
- get_solve_config_img_parser()[source]¶
Return image parser for solve config with goal mask.
- Return type:
Grounding¶
Predicate and action grounding for PDDL environments.
Generates the universe of grounded atoms and grounded actions by instantiating every typed predicate / action schema with all valid object combinations drawn from the problem’s typed-object pool.
Masks¶
JAX boolean-mask construction for PDDL preconditions, effects, and goals.
Each grounded action is encoded as four boolean vectors over the atom universe: positive preconditions, negative preconditions, add effects, and delete effects. Initial-state and goal masks are also built here.
- puxle.pddls.masks.extract_goal_conditions(goal)[source]¶
Extract atomic conditions from a goal formula object.
- puxle.pddls.masks.build_masks(grounded_actions, atom_to_idx, num_atoms)[source]¶
Builds JAX masks for preconditions (pos/neg) and effects.
Formatting¶
Pretty-printing utilities for PDDL states, actions, and solve configs.
Provides colour-coded terminal output (via termcolor and optional
rich) for debugging and visualisation of grounded atoms and actions.
Type System¶
PDDL type-hierarchy extraction and object grouping.
Builds parent/ancestor/descendant maps from a domain’s :types block
and uses them to group problem objects by the most specific type,
propagating objects to supertypes as needed for grounding.
- puxle.pddls.type_system.collect_type_hierarchy(domain)[source]¶
Extract best-effort type hierarchy from a PDDL domain object.
Returns (parent, ancestors, descendants). - parent: type -> immediate parent - ancestors: type -> transitive set of ancestors - descendants: type -> transitive set of descendants
State Definitions¶
Dynamic state and solve-config class builders for PDDL environments.
Constructs xtructure-backed State (packed boolean atom vector) and
SolveConfig (goal mask) dataclasses tailored to a specific grounded
PDDL problem.
- puxle.pddls.state_defs.build_state_class(env, num_atoms, init_state, string_parser)[source]¶
- Return type:
- Parameters:
PDDLFuse (Domain Fusion)¶
- puxle.pddls.fusion.api.fuse_and_load(domain_paths, params=None, name='fused-domain', **kwargs)[source]¶
Fuses multiple PDDL domains and returns a PuXle PDDL environment.
- Parameters:
domain_paths (
List[str]) – List of paths to PDDL domain files.params (
Optional[FusionParams]) – Fusion and modification parameters.name (
str) – Name of the resulting domain.**kwargs – Additional arguments for PDDL constructor.
- Return type:
- Returns:
A PDDL instance with the fused domain and a simple/empty problem.
- puxle.pddls.fusion.api.generate_benchmark(domain_paths, output_dir, count=10, params=None, difficulty_depth_range=(5, 20))[source]¶
Generates a suite of PDDL domain/problem files for external benchmarks.
- puxle.pddls.fusion.api.iterative_fusion(base_domains, depth, params, name_prefix='fused')[source]¶
Performs iterative fusion to increase complexity.
- Parameters:
depth (
int) – Number of fusion iterations (1 = basic fusion)params (
FusionParams) – Fusion and modification parametersname_prefix (
str) – Prefix for generated domain names
- Return type:
Domain- Returns:
Final fused domain after ‘depth’ iterations
- puxle.pddls.fusion.api.generate_benchmark_with_varying_depth(base_domains, output_dir, depth_range=(1, 3), problems_per_depth=10, params=None)[source]¶
Generates benchmarks across a range of fusion depths.
- Parameters:
- Return type:
- class puxle.pddls.fusion.domain_fusion.DomainFusion[source]¶
Bases:
objectEngine for fusing multiple PDDL domains into a single domain.
- class puxle.pddls.fusion.action_modifier.ActionModifier[source]¶
Bases:
objectModifies actions by stochastically adding preconditions and effects.
- __init__(params)[source]¶
- Parameters:
params (FusionParams)
- class puxle.pddls.fusion.action_modifier.FusionParams[source]¶
Bases:
objectFusionParams(prob_add_pre: float = 0.1, prob_add_eff: float = 0.1, prob_rem_pre: float = 0.05, prob_rem_eff: float = 0.05, prob_neg: float = 0.1, rev_flag: bool = True, seed: int = 42)