# finnalberts/schasplm architecture

> Architecture diagram of the GitHub repository finnalberts/schasplm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/finnalberts/schasplm
- Repository: https://github.com/finnalberts/schasplm

## Overview

SchASPLM is a research prototype for using LLMs to turn scheduling-problem descriptions into Answer Set Programming (ASP) programs. Its main workflow is to provide a problem and instance details, generate program sections through tailored prompts, check and optionally repair ASP syntax, and assemble the result. The repository also includes a single-prompt baseline, several scheduling-problem specifications, model backends, and experiment results. The README identifies notebooks as the way to run the code; notebook-level orchestration is not shown in the sampled source.

Main entry points: [`ASP_Scheduler/scheduler.py`](https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py) (Staged ASP generator), [`LLM/bots.py`](https://github.com/finnalberts/schasplm/blob/main/LLM/bots.py) (Bot selection), [`1_ASP_Scheduler.ipynb`](https://github.com/finnalberts/schasplm/blob/main/1_ASP_Scheduler.ipynb) (Run notebooks), [`ASP_Scheduler/schedulerBaseline.py`](https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/schedulerBaseline.py) (Single-prompt baseline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Generation workflow"]
  node_notebooks["Run notebooks"]
  node_prompt_templates["Prompt templates"]
  node_scheduler["Staged ASP generator<br/>[scheduler.py]"]
  node_baseline["Single-prompt baseline"]
  node_instance_stage["Instance and generator<br/>[scheduler.py]"]
  node_constraints_stage["Constraint generation<br/>[scheduler.py]"]
  node_program_output["Full ASP program<br/>[scheduler.py]"]
end

subgraph group_models["LLM backends"]
  node_bot_factory["Bot selection<br/>[bots.py]"]
  node_model_service["Hosted inference"]
  node_local_models["Local inference<br/>[bots.py]"]
end

subgraph group_validation["Validation and metrics"]
  node_syntax_tools["ASP syntax checks<br/>[utils.py]"]
  node_clingo["Clingo parser"]
  node_syntax_repair["Syntax repair<br/>[scheduler.py]"]
  node_metrics[("Generation metrics<br/>[logger.py]")]
end

subgraph group_domain["Scheduling domain"]
  node_problem_specs["Problem specifications"]
  node_experiment_results["Experiment results"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs"| node_notebooks
node_notebooks -.->|"invokes"| node_scheduler
node_notebooks -.->|"invokes"| node_baseline
node_problem_specs -.->|"supplies descriptions"| node_scheduler
node_scheduler -->|"loads prompts"| node_prompt_templates
node_scheduler -->|"generates"| node_instance_stage
node_scheduler -->|"generates"| node_constraints_stage
node_scheduler -->|"loads bots"| node_bot_factory
node_baseline -->|"loads bot"| node_bot_factory
node_bot_factory -.->|"uses hosted inference"| node_model_service
node_bot_factory -.->|"selects local"| node_local_models
node_instance_stage -->|"contributes sections"| node_program_output
node_constraints_stage -->|"contributes constraints"| node_program_output
node_scheduler -->|"checks syntax"| node_syntax_tools
node_syntax_tools -->|"parses ASP"| node_clingo
node_scheduler -->|"repairs errors"| node_syntax_repair
node_syntax_repair -->|"loads repair bot"| node_bot_factory
node_scheduler -->|"logs metrics"| node_metrics
node_experiment_results -->|"reports evaluations"| node_researcher

click node_notebooks "https://github.com/finnalberts/schasplm/blob/main/1_ASP_Scheduler.ipynb"
click node_problem_specs "https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/problem_descriptions.py"
click node_prompt_templates "https://github.com/finnalberts/schasplm/tree/main/ASP_Scheduler/system_prompts"
click node_scheduler "https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py"
click node_baseline "https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/schedulerBaseline.py"
click node_instance_stage "https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py"
click node_constraints_stage "https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py"
click node_program_output "https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py"
click node_bot_factory "https://github.com/finnalberts/schasplm/blob/main/LLM/bots.py"
click node_local_models "https://github.com/finnalberts/schasplm/blob/main/LLM/bots.py"
click node_syntax_tools "https://github.com/finnalberts/schasplm/blob/main/utils/utils.py"
click node_syntax_repair "https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py"
click node_metrics "https://github.com/finnalberts/schasplm/blob/main/utils/logger.py"
click node_experiment_results "https://github.com/finnalberts/schasplm/tree/main/Results"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_notebooks,node_prompt_templates,node_scheduler,node_baseline,node_instance_stage,node_constraints_stage,node_program_output toneBlue
class node_bot_factory,node_model_service,node_local_models toneAmber
class node_syntax_tools,node_clingo,node_syntax_repair,node_metrics toneMint
class node_problem_specs,node_experiment_results toneRose
class node_researcher toneIndigo
```

## Components

### Generation workflow

- [Run notebooks](https://github.com/finnalberts/schasplm/blob/main/1_ASP_Scheduler.ipynb): `1_ASP_Scheduler.ipynb`
- [Prompt templates](https://github.com/finnalberts/schasplm/tree/main/ASP_Scheduler/system_prompts): `ASP_Scheduler/system_prompts`
- [Staged ASP generator](https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py): `ASP_Scheduler/scheduler.py`
- [Single-prompt baseline](https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/schedulerBaseline.py): `ASP_Scheduler/schedulerBaseline.py`
- [Instance and generator](https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py): `ASP_Scheduler/scheduler.py`
- [Constraint generation](https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py): `ASP_Scheduler/scheduler.py`
- [Full ASP program](https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py): `ASP_Scheduler/scheduler.py`

### LLM backends

- [Bot selection](https://github.com/finnalberts/schasplm/blob/main/LLM/bots.py): `LLM/bots.py`
- **Hosted inference**
- [Local inference](https://github.com/finnalberts/schasplm/blob/main/LLM/bots.py): `LLM/bots.py`

### Validation and metrics

- [ASP syntax checks](https://github.com/finnalberts/schasplm/blob/main/utils/utils.py): `utils/utils.py`
- **Clingo parser**
- [Syntax repair](https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/scheduler.py): `ASP_Scheduler/scheduler.py`
- [Generation metrics](https://github.com/finnalberts/schasplm/blob/main/utils/logger.py): `utils/logger.py`

### Scheduling domain

- [Problem specifications](https://github.com/finnalberts/schasplm/blob/main/ASP_Scheduler/problem_descriptions.py): `ASP_Scheduler/problem_descriptions.py`
- [Experiment results](https://github.com/finnalberts/schasplm/tree/main/Results): `Results`

### Other components

- **Researcher**

## Connections

- Researcher → Run notebooks: runs (evidence: `README.md`)
- Run notebooks → Staged ASP generator: invokes
- Run notebooks → Single-prompt baseline: invokes
- Problem specifications → Staged ASP generator: supplies descriptions
- Staged ASP generator → Prompt templates: loads prompts (evidence: `ASP_Scheduler/scheduler.py`)
- Staged ASP generator → Instance and generator: generates (evidence: `ASP_Scheduler/scheduler.py`)
- Staged ASP generator → Constraint generation: generates (evidence: `ASP_Scheduler/scheduler.py`)
- Staged ASP generator → Bot selection: loads bots (evidence: `ASP_Scheduler/scheduler.py`)
- Single-prompt baseline → Bot selection: loads bot (evidence: `ASP_Scheduler/schedulerBaseline.py`)
- Bot selection → Hosted inference: uses hosted inference
- Bot selection → Local inference: selects local (evidence: `LLM/bots.py`)
- Instance and generator → Full ASP program: contributes sections (evidence: `ASP_Scheduler/scheduler.py`)
- Constraint generation → Full ASP program: contributes constraints (evidence: `ASP_Scheduler/scheduler.py`)
- Staged ASP generator → ASP syntax checks: checks syntax (evidence: `ASP_Scheduler/scheduler.py`)
- ASP syntax checks → Clingo parser: parses ASP (evidence: `utils/utils.py`)
- Staged ASP generator → Syntax repair: repairs errors (evidence: `ASP_Scheduler/scheduler.py`)
- Syntax repair → Bot selection: loads repair bot (evidence: `ASP_Scheduler/scheduler.py`)
- Staged ASP generator → Generation metrics: logs metrics (evidence: `ASP_Scheduler/scheduler.py`)
- Experiment results → Researcher: reports evaluations (evidence: `README.md`)
