Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sparrow

> 编程语言
Open source

State-of-the-art nesting for 2D irregular strip packing

316 stars0 likes2 views
WebsiteGitHub

About

State-of-the-art nesting for 2D irregular strip packing

sparrow

Sparrows are master weavers, crafting nests with intricate patterns. They utilize geometry and symmetry to ensure structural integrity and stability. By incorporating precise angles, lengths, and weaving patterns, these birds achieve a balance between strength and efficiency. (read more)

The state-of-the-art nesting heuristic for 2D irregular strip packing

sparrow can be used to solve 2D irregular strip packing problems, also commonly referred to as nesting problems. This optimization algorithm builds on jagua-rs: a collision detection engine for 2D irregular cutting & packing problems.

This repository accompanies the paper: "An open-source heuristic to reboot 2D nesting research".

[!TIP] Try 2D nesting with sparrow in your browser

Import SVG, DXF or instance JSON, configure the nesting job, watch the search live and download the result. It runs locally on your device, with no installation.

sparrow in action

Nested by sparrow

Requirements

  • Rust ≥ 1.90

Usage

General usage:

bash
cargo run --release  -- \
    -i [path to input JSON, or a solution JSON] \
    -t [timelimit in seconds (default is 600s)]

The optimization process contains two distinct phases: exploration & compression. By default 80% of the timelimit is spent exploring and 20% is spent compressing. Pressing 'Ctrl + C' immediately moves the algorithm to the next phase, or terminates it.

All CLI options:

…

Concrete example:

bash
cargo run --release -- \
    -i data/input/swim.json

Live visualization

sparrow can show the search in a terminal dashboard alongside a live browser view of the current solution. The dashboard reports the current phase, progress, throughput, and logs. It continuously updates the SVG used by live_viewer.html:

bash
cargo run --release --features=tui -- \
    -i data/input/swim.json

For the browser viewer without the dashboard, open live_viewer.html and enable the live_svg feature:

bash
cargo run --release --features=live_svg -- \
    -i data/input/swim.json

Input

This repository uses the same JSON format as jagua-rs to represent instances. These are also available in Oscar Oliveira's OR-Datasets repository.

See jagua-rs README for details on the input format.

Output

Solutions are exported as SVG files in the output folder. The final SVG solution is saved as output/final_{name}.svg.

The SVG files serve both as a visual and exact representation of the solution. All original shapes and their exact transformations applied to them are defined within the SVG:

xml
    ...
    
        
            ...
        
        ...
    
    ...

The SVG spec defines that the transformations are applied from right to left. So here the item is always first rotated and then translated.

By default, a range of intermediate (and infeasible) solutions will be exported in output/sols_{name}. To disable this and export only a single final solution, compile with the only_final_svg feature:

bash
cargo run --release --features=only_final_svg -- \
    -i data/input/swim.json

The final solution is saved both in SVG and JSON format in output/final_{name}.svg and output/final_{name}.json, respectively.

Targeting maximum performance

This crate is highly optimized and is floating-point heavy. To enable the maximum performance, make sure target-cpu=native compiler flag is set, switch to the nightly toolchain (required for SIMD support) and enable the simd feature:

bash
  export RUSTFLAGS='-C target-cpu=native'
  export RUSTUP_TOOLCHAIN=nightly
  cargo run --release --features=simd,only_final_svg -- \
      -i data/input/swim.json

Testing

A suite of debug_assert!() checks are included throughout the codebase to verify the correctness of the heuristic. These assertions are omitted in release builds to maximize performance, but are active in test builds. Some basic integration tests are included that run the heuristic on a few example instances while all assertions are active:

bash
  cargo test

Alternatively you can enable all debug_assert!() checks in release builds by running the tests with the debug-release profile:

bash
cargo run --profile debug-release -- \
    -i data/input/swim.json

Experiments

All solutions from the comparative experiments in the paper can be found at data/experiments. The accompanying README details how to perform an exact reproduction of any benchmark run.

Related Projects

  • sparrow/studio: an interactive browser interface for sparrow
  • spyrrow: a Python wrapper of sparrow
  • sparrow-3d: a 3D adaptation of sparrow

Development

This repo is meant to remain a faithful representation of the algorithm described in the paper. However, I am open to pull requests containing bug fixes and speed/performance improvements as long as they do not alter the algorithm too significantly.

Feel free to fork the repository if you want to experiment with different heuristics or want to expand the functionality.

License

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

Acknowledgements

 

This project began development at the CODeS research group of NUMA - KU Leuven and was funded by Research Foundation - Flanders (FWO) (grant number: 1S71222N) until October 2025.

Since then, I have continued the development and maintenance of the project independently. If you find sparrow useful and would like to support its continued development and maintenance, you can do so through GitHub Sponsors or Buy Me a Coffee.

Issues· 6 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustalgorithmcamcnccompaction

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言