Skip to content

Commit 97df27d

Browse files
GiggleLiuclaude
andcommitted
fix: update BinPacking model for main refactors, enrich paper entry
- Remove stale problem_size_names/values (trait methods removed on main) - Add declare_variants! with verified O*(2^n) complexity (Björklund+ 2009) - Remove unnecessary Default trait bound on impl block - Add edge-case tests: empty items, wrong config length, out-of-range bin, f64 - Expand paper problem-def with background, algorithm citation, example, figure - Regenerate problem_schemas.json and reduction_graph.json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e926fc5 commit 97df27d

3 files changed

Lines changed: 187 additions & 117 deletions

File tree

docs/paper/reductions.typ

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,43 @@ Biclique Cover is equivalent to factoring the biadjacency matrix $M$ of the bipa
803803
]
804804

805805
#problem-def("BinPacking")[
806-
Given $n$ items with sizes $s_1, dots, s_n in RR^+$ and bin capacity $C > 0$, find an assignment $x: {1, dots, n} -> {1, dots, n}$ minimizing $|{x(i) : i = 1, dots, n}|$ (number of distinct bins used) subject to $forall j: sum_(i: x(i) = j) s_i lt.eq C$.
806+
Given $n$ items with sizes $s_1, dots, s_n in RR^+$ and bin capacity $C > 0$, find an assignment $x: {1, dots, n} -> NN$ minimizing $|{x(i) : i = 1, dots, n}|$ (the number of distinct bins used) subject to $forall j: sum_(i: x(i) = j) s_i lt.eq C$.
807+
][
808+
Bin Packing is one of the classical NP-hard optimization problems @garey1979, with applications in logistics, cutting stock, and cloud resource allocation. The best known exact algorithm runs in $O^*(2^n)$ time via inclusion-exclusion over set partitions @bjorklund2009.
809+
810+
*Example.* Consider $n = 6$ items with sizes $(6, 6, 5, 5, 4, 4)$ and capacity $C = 10$. The lower bound is $ceil(30 slash 10) = 3$ bins. An optimal packing uses exactly 3 bins: $B_1 = {6, 4}$, $B_2 = {6, 4}$, $B_3 = {5, 5}$, each with total load $10 = C$.
811+
812+
#figure({
813+
canvas(length: 1cm, {
814+
let s = 0.28
815+
let w = 1.0
816+
let gap = 0.6
817+
let bins = ((6, 4), (6, 4), (5, 5))
818+
let fills = (
819+
(graph-colors.at(0), graph-colors.at(1)),
820+
(graph-colors.at(0), graph-colors.at(1)),
821+
(graph-colors.at(2), graph-colors.at(2)),
822+
)
823+
for i in range(3) {
824+
let x = i * (w + gap)
825+
draw.rect((x, 0), (x + w, 10 * s), stroke: 0.8pt + black)
826+
let y = 0
827+
for j in range(bins.at(i).len()) {
828+
let sz = bins.at(i).at(j)
829+
let c = fills.at(i).at(j)
830+
draw.rect((x, y), (x + w, y + sz * s), stroke: 0.4pt, fill: c)
831+
draw.content((x + w / 2, y + sz * s / 2), text(8pt, fill: white)[#sz])
832+
y += sz * s
833+
}
834+
draw.content((x + w / 2, -0.3), text(8pt)[$B_#(i + 1)$])
835+
}
836+
draw.line((-0.15, 10 * s), (2 * (w + gap) + w + 0.15, 10 * s),
837+
stroke: (dash: "dashed", paint: luma(150), thickness: 0.5pt))
838+
draw.content((-0.5, 10 * s), text(7pt)[$C$])
839+
})
840+
},
841+
caption: [Optimal packing of items with sizes $(6, 6, 5, 5, 4, 4)$ into 3 bins of capacity $C = 10$. Numbers indicate item sizes; all bins are fully utilized.],
842+
) <fig:binpacking-example>
807843
]
808844

809845
// Completeness check: warn about problem types in JSON but missing from paper

docs/src/reductions/problem_schemas.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@
5151
}
5252
]
5353
},
54+
{
55+
"name": "BinPacking",
56+
"description": "Assign items to bins minimizing number of bins used, subject to capacity",
57+
"fields": [
58+
{
59+
"name": "sizes",
60+
"type_name": "Vec<W>",
61+
"description": "Item sizes s_i for each item"
62+
},
63+
{
64+
"name": "capacity",
65+
"type_name": "W",
66+
"description": "Bin capacity C"
67+
}
68+
]
69+
},
5470
{
5571
"name": "CircuitSAT",
5672
"description": "Find satisfying input to a boolean circuit",

0 commit comments

Comments
 (0)