Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.5%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: JoelSchnubel
  • Language: SMT
  • Default Branch: main
  • Size: 32.9 MB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 1
Created over 1 year ago · Last pushed 8 months ago
Metadata Files
Readme Citation

README.md

Factorio Factory Layout Optimization

Python License FastAPI DOI

A comprehensive framework for optimizing Factorio factory layouts using SMT solvers and advanced pathfinding algorithms. This project applies formal methods to solve the complex problem of factory design automation, achieving up to 97x performance improvements over previous approaches.

🎯 Overview

This project tackles the challenging problem of automated factory layout optimization in Factorio, with applications extending to real-world logistics and manufacturing systems. The solution combines:

  • SMT Solver Integration: Uses Z3, CVC5, and Yices for constraint satisfaction
  • Advanced Pathfinding: Multi-agent pathfinding for belt and pipe routing
  • Interactive Web Interface: FastAPI-based web application for easy use
  • Blueprint Generation: Automatic Factorio blueprint creation
  • Performance Analysis: Comprehensive solver evaluation and benchmarking

📋 Table of Contents

✨ Features

Core Functionality

  • Production Tree Calculation: Recursive analysis of recipe dependencies
  • Layout Optimization: SMT-based placement optimization for assemblers and infrastructure
  • Multi-Solver Support: Z3, CVC5, and Yices solver backends
  • Pathfinding: Advanced A* pathfinding for belt and pipe networks
  • Blueprint Export: Direct integration with Factorio blueprint format

Advanced Features

  • Interactive GUI: Manual input/output point configuration
  • Multi-Agent Pathfinding: Efficient routing for complex factory layouts
  • Power Pole Optimization: Automatic electrical infrastructure placement
  • Fluid Handling: Support for both belt-based and pipe-based transport
  • Performance Benchmarking: Comprehensive solver evaluation framework

Web Interface

  • Production Tree Generator: Single module optimization
  • Factory Builder: Multi-module factory construction
  • Solver Evaluation: Performance comparison tools
  • JSON Editor: Configuration file management

🚀 Installation

Prerequisites

  • Python 3.8 or higher
  • Git
  • Virtual environment (recommended)

Required SMT Solvers

Setup

  1. Clone the repository:

bash git clone https://github.com/JoelSchnubel/Bachelor-Thesis.git cd Bachelor-Thesis

  1. Create and activate virtual environment:

```bash python -m venv .venv

Windows

.venv\Scripts\activate

Linux/Mac

source .venv/bin/activate ```

  1. Install dependencies:

bash pip install -r requirements.txt

  1. Configure solver paths in solver_eval.py:

python CVC5_PATH = "path/to/cvc5.exe" YICES_PATH = "path/to/yices-smt2.exe"

  1. Run the application:

bash python main.py

The web interface will be available at http://localhost:8000

🎮 Usage

Web Interface

  1. Access the application: Open http://localhost:8000 in your browser
  2. Production Tree Generator: Create single module blueprints
  3. Factory Builder: Build complex multi-module factories
  4. Solver Evaluation: Compare solver performance

Command Line Interface

```python from FactorioProductionTree import FactorioProductionTree

Create a factory for producing electronic circuits

factory = FactorioProductionTree(width=20, height=15) productiondata = factory.calculateproduction("electronic-circuit", 60)

Set up manual I/O points

factory.manualInput() factory.manualOutput()

Optimize layout

factory.solve(productiondata, solvertype="z3")

Generate blueprint

paths, inserters = factory.buildbelts() factory.createblueprint("output.json", "blueprint.txt") ```

Solver Evaluation

```python import solver_eval

Run comprehensive solver evaluation

results = solvereval.evaluatesolvers() solvereval.saveresultstocsv(results) ```

🏗️ Architecture

Core Components

├── FactorioProductionTree.py # Main production planning and optimization ├── SMT_Solver.py # Z3 SMT solver integration ├── MultiAgentPathfinder.py # A* pathfinding for belt routing ├── FactoryBuilder.py # Multi-module factory construction ├── solver_eval.py # Solver evaluation framework └── main.py # FastAPI web interface

Key Classes

  • FactorioProductionTree: Main factory planning and optimization
  • SMTSolver: Z3-based layout optimization
  • MultiAgentPathfinder: Pathfinding for material transport
  • FactoryBuilder: Large-scale factory construction

📊 Performance

Our optimization approach achieves significant performance improvements:

  • Up to 97x faster than previous constraint-based approaches
  • Scalable to large factories with hundreds of assemblers
  • Efficient pathfinding for complex belt networks
  • Multi-solver support for optimal performance

Benchmarking Results

The framework includes comprehensive benchmarking capabilities:

bash python solver_eval.py

Results are saved to results/solver_evaluation.csv with detailed performance metrics.

🔧 Configuration

Main Configuration (config.json)

json { "grid": { "default_width": 16, "default_height": 10 }, "machines": { "default_assembler": "assembling-machine-2", "default_furnace": "electric-furnace" }, "pathfinding": { "allow_underground": true, "allow_splitters": true, "max_tries": 3 } }

Recipe Data (recipes.json)

Contains all Factorio recipes with ingredients, crafting times, and machine requirements.

Custome recipes can be added to the file.

Machine Data (machine_data.json)

Defines machine capabilities, crafting speeds, and transport specifications.

Can be adapted to include new machines with specialized I/O points.

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Remark

If you encounter an error while creating a module, it's most likely due to a missing asset for the item or machine you're trying to use. Only a selection of item assets and the most essential machine, inserter, and belt assets are preloaded.

To add new assets, simply copy the image from the Factorio Wiki and place it in the assets folder. Make sure all filenames are in lowercase and use hyphens - instead of underscores _.

🎓 Academic Usage

This project is part of a Bachelor's thesis: "Optimization of Factorio Factory Layouts: An SMT-Solver Approach" by Joel Schnubel at the University of Saarland.

Citation

If you use this software in your research, please cite using GitHubs cite feature.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • University of Saarland for academic support
  • Factorio community for inspiration and game mechanics
  • SMT solver developers (Z3, CVC5, Yices teams)
  • Open source contributors for foundational libraries

Owner

  • Login: JoelSchnubel
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
type: software
title: "SMT Solver Evaluation Framework"
abstract: "Creating factory layouts is a challenging issue with real-world applications in logistics and automated manufacturing. Factory layouts occur in numerous environments, from real-world warehouses to games like Factorio. However, creating layouts is computationally hard as it's closely linked to NP-hard problems like the orthogonal packing problem. Previous approaches employ constraint solvers to generate factory layouts. Due to the complexity, state-of-the-art approaches do not scale beyond a handful of machines. We present optimizations that enable the synthesis of larger-scale factories. By leveraging independent subproblems and compositional construction of layouts, we outperform previous techniques by up to 97 times. Furthermore, we identify efficiently solvable components within the synthesis task, allowing us to apply known polynomial-time algorithms to parts of the optimization process."
authors:
  - family-names: "Schnubel"
    given-names: "Joel"
    affiliation: "University of Saarland"
date-released: "2025-07-09"
version: "1.0.0"
license: MIT
repository-code: "https://github.com/JoelSchnubel/Factorio-Factory-Builder"
doi: 10.5281/zenodo.15836543
keywords:
  - "SMT solvers"
  - "Z3"
  - "CVC5"
  - "Yices"
  - "satisfiability modulo theories"
  - "automated reasoning"
  - "benchmark evaluation"
  - "solver comparison"
  - "bachelor thesis"
  - "academic research"
references:
  - type: thesis
    title: "Optimization of Factorio Factory Layouts: An SMT-Solver Approach"
    authors:
      - family-names: "Schnubel"
        given-names: "Joel"
    institution: "University of Saarland"
    thesis-type: "Bachelor's thesis"
    year: 2025
    month: 7
preferred-citation:
  type: thesis
  title: "Optimization of Factorio Factory Layouts: An SMT-Solver Approach"
  authors:
    - family-names: "Schnubel"
      given-names: "Joel"
  doi: 10.5281/zenodo.15836543
  institution: "University of Saarland"
  thesis-type: "Bachelor's thesis"
  year: 2025
  url: "https://github.com/JoelSchnubel/Factorio-Factory-Builder"

GitHub Events

Total
  • Public event: 1
  • Push event: 5
Last Year
  • Public event: 1
  • Push event: 5

Dependencies

requirements.txt pypi