Skip to content

About

A distributed 2D geometric packing solver, verification pipeline, and benchmark tracker.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Shape Packing

A distributed 2D geometric packing solver, verification pipeline, and benchmark tracker.

The project searches for tighter packings of congruent polygons, circles, polyforms, and curved containers, verifies every candidate in-process with Separating Axis Theorem (SAT) collision and containment checks, and tracks progress alongside published bounds from Erich Friedman's Packing Center, Packomania, independent researchers, and open frontier families.

Contributing Compute & Submitting Packings

You do not need to clone this repository, install Python, or compile Rust to contribute:

  1. Submit External Packings (/submit): Already computed or maintained packings externally? Paste JSON, CSV, or plain coordinate tables on the Submit page to preview, verify, and archive them with attribution.
  2. In-Browser WebAssembly Worker: Open the Contribute page, enter a username, select thread count, and start crunching directly in your browser.
  3. Standalone Desktop Worker (shape-packing-worker): Download the prebuilt archive for your platform from GitHub Releases:
    • Windows (x86_64): shape-packing-worker-windows-x86_64.zip
    • Windows (ARM64): shape-packing-worker-windows-arm64.zip
    • Linux (x86_64): shape-packing-worker-linux-x86_64.tar.gz
    • Linux (ARM64): shape-packing-worker-linux-arm64.tar.gz
    • macOS (Universal): shape-packing-worker-macos-universal.tar.gz

Extract and run the binary. On first launch, a setup wizard asks for the coordinator URL, your username, and CPU thread count, then saves credentials (worker_id and worker_secret) to ~/.shape_packing_worker.json. To run on login without administrator privileges:

shape-packing-worker autostart enable

Supported Shapes and Problem Catalog

All shapes, aliases, enabled pair rules, and N bounds are declared in src/shape_packing/shape_catalog.json and loaded by src/shape_packing/catalog.py:

  • Benchmark Shapes: Regular polygons (3 through 10 sides), CIRCLE, TAN, DOMINO, L, plus curved circle containers (SEMICIRCLE, QUADRANT) seeded from data/packingVerification/*.json and extended to N=1..100.
  • Frontier Shapes: Canonical convex quadrilaterals (RHOMBUS, PARALLELOGRAM, TRAPEZOID) paired with {3, 4, 5, 6, 7, 8, CIRCLE} and each other across N=1..100.
  • Universal Problem Selector: Edit problem_ranges.default_max_n, problem_ranges.pair_max_n, pair_rules.disabled_pairs, or pair_rules.disabled_problems in src/shape_packing/shape_catalog.json to adjust what the coordinator seeds and serves without editing Python code.

Local Installation

Requirements

  • Python 3.10 or higher
  • Rust toolchain 1.75 or higher (cargo, rustc)
  • Node.js 20 or higher (only needed if building site/)

Setup

git clone https://github.com/targed/shape-packing.git
cd shape-packing

python -m venv .venv
# Linux/macOS: source .venv/bin/activate
# Windows (PowerShell): .venv\Scripts\Activate.ps1
pip install -r requirements.txt

cargo build --release --manifest-path packer_rs/Cargo.toml

To build the standalone volunteer binary:

cargo build --release --bin shape-packing-worker --no-default-features --manifest-path packer_rs/Cargo.toml

Common Commands

# Suggest a high-priority target problem
python -m src.shape_packing.cli suggest

# Solve a specific problem locally
python -m src.shape_packing.cli run --problem 5_TAN_in_4 --attempts 5000

# Start a local coordinator server
python -m uvicorn src.shape_packing.server.app:app --host 0.0.0.0 --port 8000

# Run the Python worker daemon or tray GUI against a coordinator
python -m src.shape_packing.client.native_worker --server http://localhost:8000 --username your_name --cores 4
python -m src.shape_packing.client.gui

# Rebuild static site data and verify the Astro frontend
python scripts/build_site_data.py
npm test --prefix site
npm run build --prefix site

Running Tests

pytest tests/test_security_api.py tests/test_package_imports.py tests/test_server_database.py tests/test_server_scheduler.py tests/test_solution_tools.py tests/test_native_worker.py tests/test_client_controller.py tests/test_client_gui.py tests/test_client_autostart.py tests/test_client_tray.py
cargo test --manifest-path packer_rs/Cargo.toml
npm test --prefix site

Project Layout

shape-packing/
├── .github/                  # Workflows, issue forms, and PR template
├── data/
│   ├── packingVerification/  # Reference benchmark JSON datasets
│   ├── records/              # Verified candidate solution packages
│   └── priority_queue.json   # Priority queue for local search
├── docs/                     # Technical guides, security docs, and specs
├── packer_rs/                # Rust solver (SAT + L-BFGS/Adam), PyO3, WASM, and worker binary
├── scripts/                  # Importers, exporters, and site data builders
├── site/                     # Astro web dashboard and browser WASM worker
├── src/shape_packing/        # Python package (catalog, verifier, CLI, coordinator, client)
└── tests/                    # Python test suite

Documentation

Supporting the Server

Using this project and its hosted server is completely free. Running and maintaining the server does come with ongoing hosting costs. If you find it useful and want to help keep it running or fund future upgrades, you can support it via GitHub Sponsors. Donations are always appreciated, never required!

About

A distributed 2D geometric packing solver, verification pipeline, and benchmark tracker.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages