Skip to main content

PackingSolver

Build PyPI Python ≥ 3.12 License: MIT Try it online

A state-of-the-art solver for cutting and packing problems.

Online solver · Documentation · Ask a question

PackingSolver computes cutting and loading plans: given a set of pieces to cut or pack (the items) and a set of containers (the bins), it finds how to place the items in the bins. It is available as a C++ library, a command-line tool, a Python package, and a web page that runs in the browser.

Problem types

Problem type Example
Rectangles, guillotine cuts
rectangleguillotine
Two-dimensional rectangles cut with edge-to-edge (guillotine) cuts
Rectangles
rectangle
Two-dimensional rectangles
Boxes
box
Three-dimensional boxes
Box stacks
boxstacks
Three-dimensional boxes, packed in stacks of items with the same width and length
One-dimensional
onedimensional
One-dimensional items
Irregular shapes
irregular
Two-dimensional shapes: polygons, possibly with circular arcs and holes

Features

PackingSolver supports the following objectives:

  • Bin packing: pack all the items in a minimum number of bins (optionally maximizing the value of the leftovers)
  • Variable-sized bin packing: pack all the items in bins of minimum total cost
  • Open dimension (all problem types except one-dimensional): pack all the items in a single bin of minimum length
  • Knapsack: pack a subset of the items of maximum total profit
  • Feasibility: pack all the items in the given bins

Each problem type comes with its own constraints:

Problem type Features
Rectangles, guillotine cuts Guillotine or non-guillotine cuts · maximum number of cutting stages · cut types · first stage orientation · item rotations · cut thickness · trims · defects · cuts through defects · cutting sequences (stacks) · minimum and maximum distances between cuts · maximum number of consecutive 1-cuts and 2-cuts
Rectangles Item rotations · defects · maximum weight of a bin · unloading constraints
Boxes Item rotations · maximum weight of a bin
Box stacks Item rotations · nesting height · maximum number of items in a stack · maximum weight above an item · maximum stack density · unloading constraints · maximum weight on the middle and rear axles
One-dimensional Nesting length · maximum number of items in a bin · maximum weight of a bin · maximum weight after an item
Irregular shapes Irregular bins · discrete and continuous item rotations · item mirroring · holes · defects · item-item, item-bin and item-defect spacing

Getting started

In the browser

The online solver runs PackingSolver in your browser. No installation is needed, and the computation runs on your machine: nothing is sent to a server.

Python

Install the Python package from PyPI (Python ≥ 3.12):

pip install packingsolver

Example (rectangles, guillotine cuts):

import packingsolver.rectangleguillotine as psg

instance_builder = psg.InstanceBuilder()
instance_builder.set_objective(psg.Objective.BinPackingWithLeftovers)
instance_builder.add_bin_type(1000, 700, copies=5)
instance_builder.add_item_type(250, 200, copies=2)
instance_builder.add_item_type(150, 300, copies=2)
instance_builder.add_item_type(200, 150, copies=3)
instance = instance_builder.build()

parameters = psg.OptimizeParameters()
parameters.time_limit = 5
output = psg.optimize(instance, parameters)

psg.visualize(output.solution).show()
Rectangles
import packingsolver.rectangle as psr

instance_builder = psr.InstanceBuilder()
instance_builder.set_objective(psr.Objective.BinPackingWithLeftovers)
instance_builder.add_bin_type(1000, 500, copies=10)
instance_builder.add_item_type(300, 200, copies=10)
instance_builder.add_item_type(250, 150, copies=10)
instance = instance_builder.build()

parameters = psr.OptimizeParameters()
parameters.time_limit = 5
output = psr.optimize(instance, parameters)

psr.visualize(output.solution).show()
Boxes
import packingsolver.box as psb

instance_builder = psb.InstanceBuilder()
instance_builder.set_objective(psb.Objective.Knapsack)
instance_builder.add_bin_type(216, 173, 110)
instance_builder.add_item_type(108, 76, 30, copies=20)
instance_builder.add_item_type(110, 43, 25, copies=20)
instance_builder.add_item_type(92, 81, 55, copies=20)
instance = instance_builder.build()

parameters = psb.OptimizeParameters()
parameters.time_limit = 5
output = psb.optimize(instance, parameters)

psb.visualize(output.solution).show()
Box stacks
import packingsolver.boxstacks as psbs

instance_builder = psbs.InstanceBuilder()
instance_builder.set_objective(psbs.Objective.Knapsack)
instance_builder.add_bin_type(7500, 2400, 3000)
instance_builder.add_item_type(2500, 800, 750, stackability_id=0, copies=10)
instance_builder.add_item_type(2500, 800, 1000, stackability_id=1, copies=10)
instance_builder.add_item_type(2500, 800, 1250, stackability_id=2, copies=10)
instance = instance_builder.build()

parameters = psbs.OptimizeParameters()
parameters.time_limit = 5
output = psbs.optimize(instance, parameters)

psbs.visualize(output.solution).show()
One-dimensional
import packingsolver.onedimensional as pso

instance_builder = pso.InstanceBuilder()
instance_builder.set_objective(pso.Objective.BinPacking)
instance_builder.add_bin_type(1000, copies=100)
for length in [
        193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
        269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347,
        349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421,
        431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499]:
    instance_builder.add_item_type(length)
instance = instance_builder.build()

parameters = pso.OptimizeParameters()
parameters.time_limit = 5
output = pso.optimize(instance, parameters)

pso.visualize(output.solution).show()
Irregular shapes
import packingsolver.irregular as psi

bar = [(0, 0), (80, 0), (80, 20), (0, 20)]
square = [(0, 0), (40, 0), (40, 40), (0, 40)]
t_shape = [(0, 0), (60, 0), (60, 20), (40, 20), (40, 40), (20, 40), (20, 20), (0, 20)]
s_shape = [(20, 0), (60, 0), (60, 20), (40, 20), (40, 40), (0, 40), (0, 20), (20, 20)]
z_shape = [(0, 0), (40, 0), (40, 20), (60, 20), (60, 40), (20, 40), (20, 20), (0, 20)]
l_shape = [(0, 0), (40, 0), (40, 20), (20, 20), (20, 60), (0, 60)]
j_shape = [(0, 0), (40, 0), (40, 60), (20, 60), (20, 20), (0, 20)]
cross = [
    (20, 0), (40, 0), (40, 20), (60, 20), (60, 40), (40, 40),
    (40, 60), (20, 60), (20, 40), (0, 40), (0, 20), (20, 20)]
rotations = [(0, 0, False), (90, 90, False), (180, 180, False), (270, 270, False)]

instance_builder = psi.InstanceBuilder()
instance_builder.set_objective(psi.Objective.BinPacking)
instance_builder.add_bin_type(psi.build_rectangle(0, 180, 0, 160), copies=3)
instance_builder.add_item_type(psi.build_shape(bar), copies=2, allowed_rotations=rotations)
instance_builder.add_item_type(psi.build_shape(square), copies=2)
instance_builder.add_item_type(psi.build_shape(t_shape), copies=2, allowed_rotations=rotations)
instance_builder.add_item_type(psi.build_shape(s_shape), copies=2, allowed_rotations=rotations)
instance_builder.add_item_type(psi.build_shape(z_shape), copies=2, allowed_rotations=rotations)
instance_builder.add_item_type(psi.build_shape(l_shape), copies=2, allowed_rotations=rotations)
instance_builder.add_item_type(psi.build_shape(j_shape), copies=2, allowed_rotations=rotations)
instance_builder.add_item_type(psi.build_shape(cross), copies=3)
instance = instance_builder.build()

parameters = psi.OptimizeParameters()
parameters.time_limit = 5
output = psi.optimize(instance, parameters)

psi.visualize(output.solution).show()

Command line

Build the command-line tools with CMake:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel
cmake --install build --config Release --prefix install

Example (rectangles, guillotine cuts):

./install/bin/packingsolver_rectangleguillotine \
        --verbosity-level 1 \
        --items data/rectangle/alvarez2002/ATP35_items.csv \
        --bins data/rectangle/alvarez2002/ATP35_bins.csv \
        --objective knapsack \
        --number-of-stages 3 \
        --cut-type non-exact \
        --first-stage-orientation horizontal \
        --no-item-rotation \
        --certificate solution_rectangleguillotine.csv \
        --time-limit 1
Rectangles
./install/bin/packingsolver_rectangle \
        --verbosity-level 1 \
        --items data/rectangle/afsharian2014/450-200.txt/C22M25R10N15_D4_items.csv \
        --bins data/rectangle/afsharian2014/450-200.txt/C22M25R10N15_D4_bins.csv \
        --defects data/rectangle/afsharian2014/450-200.txt/C22M25R10N15_D4_defects.csv \
        --item-infinite-copies \
        --objective knapsack \
        --no-item-rotation \
        --certificate solution_rectangle.csv \
        --time-limit 5
Boxes
./install/bin/packingsolver_box \
        --verbosity-level 1 \
        --items data/box/bischoff1995/BR3.txt_1 \
        --objective knapsack \
        --certificate solution_box.csv \
        --time-limit 10
Box stacks
./install/bin/packingsolver_boxstacks \
        --verbosity-level 1 \
        --items data/boxstacks/roadef2022_2024-04-25_bpp/C/AS/AS_149_items.csv \
        --bins data/boxstacks/roadef2022_2024-04-25_bpp/C/AS/AS_149_bins.csv \
        --parameters data/boxstacks/roadef2022_2024-04-25_bpp/C/AS/AS_149_parameters.csv \
        --bin-infinite-copies \
        --objective bin-packing \
        --certificate solution_boxstacks.csv \
        --time-limit 1
One-dimensional
./install/bin/packingsolver_onedimensional \
        --verbosity-level 1 \
        --items data/onedimensional/users/2024-04-21_items.csv \
        --bins data/onedimensional/users/2024-04-21_bins.csv \
        --parameters data/onedimensional/users/2024-04-21_parameters.csv \
        --certificate solution_onedimensional.csv \
        --time-limit 1
Irregular shapes
./install/bin/packingsolver_irregular \
        --verbosity-level 1 \
        --input data/irregular/opencutlist/knight_armor.json \
        --certificate solution_irregular.json \
        --time-limit 10

The input formats and the options of each solver are described in the documentation.

Visualizing a solution

Open a solution certificate (--certificate) in the solution viewer, or run:

python3 scripts/visualize.py solution_rectangleguillotine.csv

Questions

Questions and feedback are welcome in the discussions. Bugs can be reported in the issues.

License

PackingSolver is released under the MIT license.

Metadata

Release files for packingsolver 0.1.1174

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for packingsolver 0.1.1174
File Size Uploaded
packingsolver-0.1.1174.tar.gz 823.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for packingsolver 0.1.1174
File
packingsolver-0.1.1174-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
packingsolver-0.1.1174-cp312-abi3-win32.whl CPython 3.12 abi3 Windows x86-32 Details
packingsolver-0.1.1174-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
packingsolver-0.1.1174-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details
packingsolver-0.1.1174-cp312-abi3-macosx_11_0_x86_64.whl CPython 3.12 abi3 macOS 11.0+ x86-64 Details
packingsolver-0.1.1174-cp312-abi3-macosx_11_0_arm64.whl CPython 3.12 abi3 macOS 11.0+ ARM64 Details

Total release size: 28.6 MB

Release files / packingsolver-0.1.1174.tar.gz

Download URL packingsolver-0.1.1174.tar.gz
Size 823.9 kB
Tags Source
SHA-256 checksum
How to use checksums
39a0761f9a7652c683192f042f04a00ba30c70bb2c88872d5ca031839eeea9a4
BLAKE2b-256 checksum
How to use checksums
d7b255c6871b7c813f92f135c89a5ee91ccf43ebd75f6af4214521be6bae8f70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / packingsolver-0.1.1174-cp312-abi3-win_amd64.whl

Download URL packingsolver-0.1.1174-cp312-abi3-win_amd64.whl
Size 4.0 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
26cf4fb4f0622425d17508f75b698ede4663036d440a68be08b6a16bd142f05c
BLAKE2b-256 checksum
How to use checksums
45b296a59ca5e6c4b5b6fcee3a3b7b6fb1951e13e794a3d7f10098221e539eda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / packingsolver-0.1.1174-cp312-abi3-win32.whl

Download URL packingsolver-0.1.1174-cp312-abi3-win32.whl
Size 3.6 MB
Tags CPython 3.12 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
3311c00c4488284af2c1542d1c0bfab45806c8106610abe6fa243471a551dfd6
BLAKE2b-256 checksum
How to use checksums
67278cb65866b8109f3531fb3543429b06c10af1da22c5b47173364fe3718980
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / packingsolver-0.1.1174-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL packingsolver-0.1.1174-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 5.8 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
9081638ac6fc20b7dd28947a00e7caed286b765ed9b07d2500446acc74928cba
BLAKE2b-256 checksum
How to use checksums
c6133a5b982678550b961afcc99531f1d2beaad4dc04c511b121a9a16dd71626
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / packingsolver-0.1.1174-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL packingsolver-0.1.1174-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 5.4 MB
Tags CPython 3.12 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
59534980eae3adf36c0ae0d504616385756fc019ce6909d853f309c98a8ee01d
BLAKE2b-256 checksum
How to use checksums
18f12b7ae9724289855036d81e50e8cb5af289eb782b8e02e1b57e86cda4358f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / packingsolver-0.1.1174-cp312-abi3-macosx_11_0_x86_64.whl

Download URL packingsolver-0.1.1174-cp312-abi3-macosx_11_0_x86_64.whl
Size 4.8 MB
Tags CPython 3.12 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
972768abf9bd1e86198a8748a2c56d553e6b104258a3b9e798c136e9141a3479
BLAKE2b-256 checksum
How to use checksums
82619389f3c8f5dcd5247bc5a3f9c0d57d30b71cb5d8ad68ed64c4ce88deaf4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / packingsolver-0.1.1174-cp312-abi3-macosx_11_0_arm64.whl

Download URL packingsolver-0.1.1174-cp312-abi3-macosx_11_0_arm64.whl
Size 4.2 MB
Tags CPython 3.12 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
80070cdacb693162c984b5d612440a6973ca0b155a1c440a1301d9fc6513119b
BLAKE2b-256 checksum
How to use checksums
dfe879569403405ecd022e426d4c5d52cbe4d3a799d3ab1a6c43ae6fbef31090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1174 This release

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page