SkillAgentSearch skills...

Packingsolver

A solver for (geometrical) packing problems

Install / Use

/learn @fontanf/Packingsolver

README

PackingSolver

A state-of-the-art solver for (geometrical) packing problems.

PackingSolver solves the following problem types:

| Problem types | Examples | :------------------------- |:------------------------- rectangleguillotine<ul><li>Items: two-dimensional rectangles</li><li>Only edge-to-edge cuts are allowed</li></ul> | <img src="https://github.com/fontanf/packingsolver/blob/master/img/rectangleguillotine.png" align=center width="512"> rectangle<ul><li>Items: two-dimensional rectangles</li></ul> | <img src="https://github.com/fontanf/packingsolver/blob/master/img/rectangle.png" align=center width="512"> box<ul><li>Items: three-dimensional rectangular parallelepipeds</li></ul> | <img src="https://github.com/fontanf/packingsolver/blob/master/img/box.png" align=center width="512"> boxstacks<ul><li>Items: three-dimensional rectangular parallelepipeds</li><li>Items can be stacked; a stack contains items with the same width and length</li></ul> | <img src="https://github.com/fontanf/packingsolver/blob/master/img/boxstacks.png" align=center width="512"> onedimensional<ul><li>Items: one-dimensional items</li></ul> | <img src="https://github.com/fontanf/packingsolver/blob/master/img/onedimensional.png" align=center width="512"> irregular<ul><li>Items: two-dimensional polygons</li></ul> | <img src="https://github.com/fontanf/packingsolver/blob/master/img/irregular.png" align=center width="512">

Compilation

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

rectangleguillotine solver

Features:

  • Objectives:
    • Knapsack
    • Open dimension X
    • Open dimension Y
    • Bin packing
    • Bin packing with leftovers
    • Variable-sized bin packing
  • Item types:
    • With or without rotations
    • Stacks (precedence constraints on the order in which items are extracted)
  • Bins types:
    • May contain defects
    • Allow or forbid cutting through a defect
  • Two- and three-staged, exact, non-exact, roadef2018 and homogenous patterns
  • First cut vertical, horizontal or any
  • Trims
  • Cut thickness
  • Minimum distance between consecutive 1-cuts
  • Maximum distance between consecutive 1-cuts
  • Minimum distance between consecutive 2-cuts
  • Minimum distance between cuts
  • Maximum number of consecutive 2-cuts

Example:

./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
<details><p>
=================================
          PackingSolver          
=================================

Problem type
------------
RectangleGuillotine

Instance
--------
Objective:                Knapsack
Number of item types:     29
Number of items:          153
Number of bin types:      1
Number of bins:           1
Number of stacks:         29
Number of defects:        0
Number of stages:         3
Cut type:                 NonExact
First stage orientation:  Horizontal
min1cut:                  0
max1cut:                  -1
min2cut:                  0
max2cut:                  -1
Minimum waste:            1
one2cut:                  0
Cut through defects:      0
Cut thickness:            0

        Time        Profit   # items                         Comment
        ----        ------   -------                         -------
       0.001         68970         1         TS g 5 d Horizontal q 1
       0.002         72000         1         TS g 5 d Horizontal q 1
       0.009        140970         2         TS g 5 d Horizontal q 1
       0.010        144000         2         TS g 5 d Horizontal q 1
       0.011        212970         3         TS g 5 d Horizontal q 1
       0.012        216000         3         TS g 5 d Horizontal q 1
       0.013        284970         4         TS g 5 d Horizontal q 1
       0.014        292395         5         TS g 5 d Horizontal q 1
       0.015        306705         5         TS g 5 d Horizontal q 1
       0.016        348839         5         TS g 5 d Horizontal q 1
       0.017        358042         6         TS g 5 d Horizontal q 1
       0.018        372343         6         TS g 5 d Horizontal q 1
       0.019        379768         7         TS g 5 d Horizontal q 1
       0.020        388389         7         TS g 5 d Horizontal q 1
       0.021        408379         7         TS g 5 d Horizontal q 1
       0.022        415804         8         TS g 5 d Horizontal q 1
       0.023        424425         8         TS g 5 d Horizontal q 1
       0.024        444415         8         TS g 5 d Horizontal q 1
       0.025        451840         9         TS g 5 d Horizontal q 1
       0.026        460461         9         TS g 5 d Horizontal q 1
       0.027        480451         9         TS g 5 d Horizontal q 1
       0.029        496497        10         TS g 5 d Horizontal q 1
       0.030        502186        10         TS g 5 d Horizontal q 1
       0.031        523921        11         TS g 5 d Horizontal q 1
       0.032        539967        12         TS g 5 d Horizontal q 1
       0.033        547003         9         TS g 5 d Horizontal q 2
       0.034        561304         9         TS g 5 d Horizontal q 2
       0.035        581548         9         TS g 5 d Horizontal q 2
       0.036        588973        10         TS g 5 d Horizontal q 2
       0.036        597058        10         TS g 5 d Horizontal q 2
       0.037        599368        11         TS g 5 d Horizontal q 2
       0.039        602118        14         TS g 4 d Horizontal q 2
       0.043        605793        11         TS g 5 d Horizontal q 9
       0.049        606147        13        TS g 5 d Horizontal q 19
       0.059        606672        12        TS g 5 d Horizontal q 42
       0.074        607062        14        TS g 5 d Horizontal q 94
       0.104        609550        15       TS g 5 d Horizontal q 211
       0.154        610101        31       TS g 4 d Horizontal q 141
       0.155        610578        31       TS g 4 d Horizontal q 141
       0.156        610787        32       TS g 4 d Horizontal q 141
       0.212        611135        34       TS g 4 d Horizontal q 211
       0.294        614725        31       TS g 4 d Horizontal q 316
       0.304        614967        42       TS g 4 d Horizontal q 316
       0.453        616880        16      TS g 5 d Horizontal q 1139
       0.874        619897        28      TS g 4 d Horizontal q 1066

Final statistics
----------------
Time (s):  1.0037

Solution
--------
Number of items:  28 / 153 (18.3007%)
Item area:        619897 / 4322082 (14.3426%)
Item profit:      619897 / 4.32208e+06 (14.3426%)
Number of bins:   1 / 1 (100%)
Bin cost:         623040
Waste:            3143
Waste (%):        0.504462
Full waste:       3143
Full waste (%):   0.504462
</p></details>

Visualize solution:

python3 scripts/visualize_rectangleguillotine.py solution_rectangleguillotine.csv

rectangle solver

Features:

  • Objectives:
    • Knapsack
    • Open dimension X
    • Open dimension Y
    • Bin packing
    • Bin packing with leftovers
    • Variable-sized bin packing
  • Item types:
    • With or without rotations
  • Bin types:
    • May contain defects
    • Maximum weight
  • Unloading constraints: only horizontal/vertical movements, increasing x/y

Example:

./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
<details><p>
=================================
          PackingSolver          
=================================

Problem type
------------
Rectangle

Instance
--------
Objective:             Knapsack
Number of item types:  25
Number of items:       247
Number of bin types:   1
Number of bins:        1
Number of groups:      1
Number of defects:     4
Unloading constraint:  None
Total item area:       2576510
Total item width:      33005
Total item height:     17382
Smallest item width:   47
Smallest item height:  21
Total bin area:        90000
Total item weight:     0
Total bin weight:      0

        Time        Profit   # items                         Comment
        ----        ------   -------                         -------
       0.001         10773         1                  TS g 4 d X q 1
       0.002         17052         1                  TS g 4 d X q 1
       0.002         23765         1                  TS g 4 d X q 1
       0.003         27825         2                  TS g 4 d X q 1
       0.003         30429         2                  TS g 4 d X q 1
       0.004         34538         2                  TS g 4 d Y q 1
       0.004         39178         3                  TS g 4 d Y q 1
       0.005         40237         4                  TS g 4 d X q 1
       0.005         43421         2                  TS g 5 d Y q 1
       0.006         43818         4                  TS g 4 d Y q 1
       0.006         50405         5                  TS g 4 d X q 1
       0.007         52631         6                  TS g 4 d X q 1
       0.007         53985         5                  TS g 5 d Y q 1
       0.008         54875     

Related Skills

View on GitHub
GitHub Stars197
CategoryDevelopment
Updated10h ago
Forks37

Languages

C++

Security Score

100/100

Audited on Mar 26, 2026

No findings