# batsresearch/planetarium architecture

> Architecture diagram of the GitHub repository batsresearch/planetarium, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/batsresearch/planetarium
- Repository: https://github.com/batsresearch/planetarium

## Overview

##### Project Type & Purpose
- This is an evaluation & dataset tool focused on converting and comparing PDDL problem descriptions.
- The key goal is to transform PDDL (and its corresponding natural language descriptions) into graph representations, “fully specify” these graphs (by adding necessary propositions), and then perform isomorphism checks to assess translation correctness.
- In addition to core evaluation, the project provides scripts for dataset generation (dataset_generator.py), finetuning (finetune.py), and planning (llm_planner.py).

##### Main Components & Their Placement
a. Input & Dataset Module:
- Dataset generator (dataset_generator.py and associated config files from the "experiment_cfgs" directory).
- Integration with external dataset repositories (linking to Hugging Face datasets as outlined in the README).

b. Core Processing / Evaluation Pipeline:
- PDDL Input: Mark a component for receiving two PDDL problem descriptions.
- Graph Construction:
- A node for “Graph Representation”, which is implemented by modules like planetarium/graph.py and planetarium/reduced_graph.py.
- That the transformation from PDDL to graph is central.
- Fully Specify Function:
- This module enriches the graph by adding “trivial” propositions. It is domain-specific. Reference planetarium/oracles (blocksworld.py, gripper.py, etc.) which implement the function for each domain.
- Graph Comparison / Isomorphism:
- A component representing the “Graph Isomorphism” checker. This is the core evaluation step that compares the fully specified graphs.
- The planetarium/metric.py module might also be used here to measure the similarity or correctness.

c. External Modules & Integrations:
- Integrate external planning & validation tools:
- Additional Components:
- “llm_planner.py” and “finetune.py” indicate there’s support for LLM-based planning as well as training/evaluation components. Represent these as optional modules that feed into or extend the evaluation pipeline.

##### Relationships & Data Flow
- Next, direct the flow into the "Fully Specified" module (using domain-specific oracle implementations) which enriches or adjusts the graph.
- Then, illustrate that the enhanced graph is sent to the Graph Isomorphism checker.
- Finally, the outcome (evaluation metrics) is provided by the evaluate.py script/module.
- Separately, a branch can show the “dataset generation” process and its configuration feed (via dataset_generator.py and experiment_cfgs files).

##### Architectural Patterns & Design Principles
- Modular Design: The project is clearly organized into modules grouped by purpose (graph building, evaluation, domain-specific functions, dataset management).
- Separation of Concerns: There is a clear segregation between graph transformation, evaluation, and data management.
- Extensibility: The “EXTENDING.md” and modular oracle design illustrate an architecture that invites the addition of new domains.
- Integration with External Systems: Show how the system relies on external planners (Fast-Downward and VAL) for parts of its functionality.

##### Technologies & Libraries
- Python is used as the primary language, with dependency management handled via Poetry and pyproject.toml.
- External planners: Fast-Downward (via Apptainer) and VAL.
- The project also utilizes data from the Hugging Face hub, evident from the README badges and dataset links.

## Diagram (Mermaid)

```mermaid
flowchart TD

    subgraph "Input & Dataset Module"
        DS["Dataset Generator"]:::dataset
        EXP["Dataset Configurations"]:::dataset
        Hug["External Dataset Repository"]:::external
    end

    subgraph "Core Processing / Evaluation Pipeline"
        PDDL["PDDL Input"]:::core

        subgraph "Graph Construction"
            G1["Graph (planetarium/graph.py)"]:::core
            G2["Reduced Graph (planetarium/reduced_graph.py)"]:::core
            CG["Combined Graph"]:::core
        end

        subgraph "Graph Enrichment (Fully Specify)"
            O1["Blocksworld Oracle (planetarium/oracles/blocksworld.py)"]:::core
            O2["Floortile Oracle (planetarium/oracles/floortile.py)"]:::core
            O3["Gripper Oracle (planetarium/oracles/gripper.py)"]:::core
            O4["Rover Single Oracle (planetarium/oracles/rover_single.py)"]:::core
            EG["Enriched Graph"]:::core
        end

        GI["Graph Isomorphism Checker"]:::core
        EV["Evaluation Metrics"]:::core
    end

    subgraph "External Modules & Integrations"
        PI["Planner Integration (Fast-Downward & VAL)"]:::external
        LLM["LLM-based Planning"]:::optional
        FT["Finetuning Script"]:::optional
    end

    EXP --> DS
    Hug --> DS
    DS --> PDDL

    PDDL --> G1
    PDDL --> G2
    G1 --> CG
    G2 --> CG

    CG --> O1
    CG --> O2
    CG --> O3
    CG --> O4
    O1 --> EG
    O2 --> EG
    O3 --> EG
    O4 --> EG

    EG --> GI
    GI --> EV

    PI --- EV
    LLM --- EV
    FT --- EV

    click DS "https://github.com/batsresearch/planetarium/blob/main/dataset_generator.py"
    click EXP "https://github.com/batsresearch/planetarium/tree/main/experiment_cfgs/"
    click G1 "https://github.com/batsresearch/planetarium/blob/main/planetarium/graph.py"
    click G2 "https://github.com/batsresearch/planetarium/blob/main/planetarium/reduced_graph.py"
    click O1 "https://github.com/batsresearch/planetarium/blob/main/planetarium/oracles/blocksworld.py"
    click O2 "https://github.com/batsresearch/planetarium/blob/main/planetarium/oracles/floortile.py"
    click O3 "https://github.com/batsresearch/planetarium/blob/main/planetarium/oracles/gripper.py"
    click O4 "https://github.com/batsresearch/planetarium/blob/main/planetarium/oracles/rover_single.py"
    click GI "https://github.com/batsresearch/planetarium/blob/main/planetarium/metric.py"
    click EV "https://github.com/batsresearch/planetarium/blob/main/evaluate.py"
    click PI "https://github.com/batsresearch/planetarium/blob/main/planetarium/downward.py"
    click LLM "https://github.com/batsresearch/planetarium/blob/main/llm_planner.py"
    click FT "https://github.com/batsresearch/planetarium/blob/main/finetune.py"

    classDef core fill:#CCD1D1,stroke:#2E4053,stroke-width:2px;
    classDef dataset fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef external fill:#ABEBC6,stroke:#1E8449,stroke-width:2px;
    classDef optional fill:#D6EAF8,stroke:#5499C7,stroke-width:2px;
```
