Skip to content

irregular: add a Benders decomposition and a MILP NFP algorithm - #773

Merged
fontanf merged 1 commit into
masterfrom
irregular-benders-decomposition
Nov 1, 2026
Merged

fontanf merged 1 commit into
masterfrom
irregular-benders-decomposition

Conversation

@fontanf

@fontanf fontanf commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Two new exact algorithms for the irregular problem type: a combinatorial Benders decomposition, and a MILP NFP algorithm which proves that a set of items doesn't fit in a bin. Together, they prove the optimality of bin packing instances, and they are used in the exact optimization mode.

Benders decomposition

New algorithm benders_decomposition, for the Knapsack, BinPacking and VariableSizedBinPacking objectives, like the rectangle one:

  • The master problem is a onedimensional instance: each item and each bin is reduced to its area (rounded down for the items, up for the bins, so that it stays a relaxation). The resources of the instance are copied into it.
  • For each bin of the solution of the master problem, a subproblem checks whether its items fit in it.
  • When they don't, the infeasible items are reduced to a minimal infeasible subset, which gives a no-good cut, encoded as a resource of the bin type.
  • The bound of the master problem is reported only while every cut is proven.

With the MILP NFP algorithm in the subproblems (--benders-decomposition-use-milp-nfp 1, always on in the exact mode):

  • The items of a bin are added one by one, largest first, until they are proven not to fit: proving it for a few large items is often much cheaper than for all of them. The answers are cached.
  • If the relaxation of all the items of a bin is feasible, the positions of its solution are used as a packing when the items don't overlap.
  • The proven cuts are lifted: an item type gets a coefficient 1 if every selection of one copy of it with |S| - 1 items of the cut is proven infeasible (at most 4 item types per cut).

MILP NFP

New algorithm milp_nfp: given a bin type and a set of items, it tries to prove that the items don't fit. For each rotation combination, it solves a MILP on the positions of the reference points: each item in its inner-fit rectangle, and for each pair of items, the relative position in a convex piece of the region outside of their no-fit polygon (one binary variable per piece, big-M constraints). The rotation combinations are solved in parallel, with an early stop as soon as one of them is feasible.

  • The exact fits (an item exactly in a notch of another one) are the feasible segments and points of null area returned by the no-fit polygon computation; they are added as convex pieces, so that an infeasible MILP is a proof.
  • Symmetries: identical rotations, identical items, and the 180 degrees symmetry of the bounding box of the bin.
  • Core widening: the part of the height of an item that no other item can reach is a horizontal band that belongs to it alone, so the item counts as widened to the width of the bin on it; a cheap area test.
  • Sub-combinations: before solving the MILP of a combination, its sub-combinations without one of the items are checked; their statuses are cached across calls.

It also solves the Feasibility objective with a single bin (--use-milp-nfp 1).

Integration

  • In the exact mode, the Benders decomposition is selected for the Knapsack objective with a single bin, and the MILP NFP algorithm for the Feasibility objective with a single bin.
  • The column generation of irregular now supports the Dual pricing type: the Benders decomposition, with the MILP NFP algorithm, solves the pricing problems when a bound is needed.
  • New knapsack goal in the irregular instances: the column generation sets it for both pricing types, and the Benders decomposition stops as soon as it reaches it or proves that it can't.
  • New CLI options --use-benders-decomposition, --benders-decomposition-use-milp-nfp and --use-milp-nfp, and the matching Python parameters use_benders_decomposition, benders_decomposition_use_milp_nfp and use_milp_nfp.

Results

Exact mode, with the tree search, 300 s, on the bin packing instances of data/irregular/martinez2017:

  • proven optimal: albano_sb, dighe1_sb, dighe2_sb, fu_sb, han_sb, jakobs1_sb, mao_sb, poly1a_sb, shapes0_sb, shapes1_sb, shapes2_sb;
  • open: jakobs2_sb, poly2a_sb to poly5b_sb, shirts_sb, swimm_sb, trousers_sb. When more items fit in a bin, the minimal infeasible subsets have 5 items or more, and each one takes seconds to prove.

The Benders decomposition alone gives bounds at least as good as the column generation with dual pricing on every instance, better on jakobs2_sb, poly2b_sb and shirts_sb, and is faster on the shapes*_sb instances.

Tests

  • milp_nfp_test.cpp: too large squares, exact fits, interlocked steps with and without rotation, crosses, core widening, symmetries, packing from the solution of the relaxation, infeasibility proven by optimize in the exact mode.
  • benders_decomposition_test.cpp: one test per objective, on 60 x 40 items, two of which can't be side by side in a 100 x 100 bin, so that the area bound is weak; the exact mode; the knapsack goal; the dual pricing of the column generation (fails without it).
  • data/irregular/tests/feasibility_poly*_five_items*.json: five items of poly1a_sb and poly2a_sb, for the analysis of the MILP NFP algorithm.

Documentation

New pages doc/internals/irregular/benders_decomposition.rst and doc/internals/irregular/milp_nfp.rst, in the layout of the detailed algorithm pages; the irregular summary, the algorithm selection and the column generation pages are updated.

The figures of these pages (the iteration of the Benders decomposition, the convex pieces and the exact fit of a no-fit polygon, the core widening) are generated as SVG by scripts/doc_figures/irregular_benders_decomposition.py and scripts/doc_figures/irregular_milp_nfp.py, with scripts/doc_figures/figure.py.

@fontanf
fontanf force-pushed the irregular-benders-decomposition branch from 4b2775b to 613750e Compare October 31, 2026 21:15
Benders decomposition, for the Knapsack, BinPacking and
VariableSizedBinPacking objectives: the master problem assigns the items
to the bins by area, as a onedimensional problem, and the subproblems
check whether the items of each bin fit. The minimal infeasible subsets
of the bins which don't fit give no-good cuts, which are lifted when they
are proven.

MILP NFP, which proves that a set of items doesn't fit in a bin: for
each rotation combination, a MILP selects, for each pair of items, a
convex piece of the region outside of their no-fit polygon. Exact fits,
symmetries, core widening and the reuse of infeasible sub-combinations.

In the Exact mode, the Benders decomposition is selected for the
Knapsack objective with a single bin, and the MILP NFP algorithm for the
Feasibility objective with a single bin, and the subproblems of the
Benders decomposition use the MILP NFP algorithm. The column generation
supports the Dual pricing type, solved with the Benders decomposition,
and the knapsack goal is added to the irregular instances.

Documentation of both algorithms, with figures.
@fontanf
fontanf force-pushed the irregular-benders-decomposition branch from 613750e to cb99a07 Compare October 31, 2026 22:33
@fontanf
fontanf merged commit d53224c into master Nov 1, 2026
16 checks passed
@fontanf
fontanf deleted the irregular-benders-decomposition branch November 1, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant