FAILURE MAP
← Case archive

FA-95161 / Warehouse slotting and bin packing / Open access

Nested bin fill: repeated SKU line overwrites · case 01

When an order has two lines for the same SKU only the last line quantity is placed.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Duplicate SKU lines replace the earlier quantity instead of adding to it.

VERIFIED REPAIR

Sum quantities of duplicate SKU lines before sizing the nested stack.

Unsuccessful approach: Keeping the larger line quantity still loses the smaller line.

Case contract

lines [[sku, qty, unit_volume, nest_increment]]. Lines for the same SKU are merged. A nesting SKU (increment > 0) occupies unit_volume + (qty-1)*increment; others qty*unit_volume; qty 0 contributes nothing and is not counted. Bin fits when total <= bin_vol and distinct stocked SKUs <= max_skus. Return [total, fits].

Why this case matters

Nesting products such as cups and trays occupy far less space than unit cube suggests.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(lines, bin_vol, max_skus):
    merged = {}
    for sku, qty, uv, nv in lines:
        if sku in merged:
            merged[sku] = [qty, uv, nv]
        else:
            merged[sku] = [qty, uv, nv]
    total = 0
    count = 0
    for sku, (qty, uv, nv) in merged.items():
        if qty <= 0:
            continue
        count += 1
        if nv > 0:
            total += uv + (qty - 1) * nv
        else:
            total += qty * uv
    return [total, total <= bin_vol and count <= max_skus]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['merged lines nest together', [[['CUP', 5, 10, 2], ['CUP', 5, 10, 2]], 30, 1], [28, True]], ['generated mix 1', [[['LID', 0, 4, 0], ['TRY', 10, 25, 5], ['TRY', 5, 25, 5], ['CUP', 2, 10, 2], ['BWL', 10, 30, 6]], 120, 2], [191, False]], ['nesting', [[['CUP', 10, 10, 2]], 30, 1], [28, True]], ['zero line', [[['CUP', 1, 10, 2], ['BOX', 0, 40, 0]], 30, 1], [10, True]], ['sku limit', [[['CUP', 1, 10, 2], ['LID', 1, 4, 0]], 100, 1], [14, False]], ['capacity equal', [[['CUP', 11, 10, 2]], 30, 1], [30, True]], ['non nesting', [[['BOX', 2, 40, 0]], 80, 1], [80, True]], ['generated mix 9', [[['CUP', 10, 10, 2], ['TRY', 10, 25, 5], ['BOX', 5, 40, 0], ['LID', 10, 4, 0], ['BWL', 2, 30, 6]], 80, 1], [374, False]]], [['generated mix 23', [[['TRY', 2, 25, 5], ['CUP', 10, 10, 2], ['TRY', 0, 25, 5]], 150, 2], [58, True]], ['generated mix 22', [[['BOX', 2, 40, 0], ['BOX', 10, 40, 0], ['BOX', 0, 40, 0], ['BOX', 2, 40, 0], ['LID', 1, 4, 0]], 50, 2], [564, False]], ['zero line', [[['CUP', 1, 10, 2], ['BOX', 0, 40, 0]], 30, 1], [10, True]], ['sku limit', [[['CUP', 1, 10, 2], ['LID', 1, 4, 0]], 100, 1], [14, False]], ['capacity equal', [[['CUP', 11, 10, 2]], 30, 1], [30, True]], ['generated mix 9', [[['CUP', 10, 10, 2], ['TRY', 10, 25, 5], ['BOX', 5, 40, 0], ['LID', 10, 4, 0], ['BWL', 2, 30, 6]], 80, 1], [374, False]], ['generated mix 17', [[['CUP', 5, 10, 2]], 50, 2], [18, True]], ['generated mix 27', [[['CUP', 2, 10, 2]], 100, 1], [12, True]]], [['generated mix 42', [[['LID', 5, 4, 0], ['BWL', 1, 30, 6], ['BWL', 1, 30, 6]], 100, 2], [56, True]], ['generated mix 40', [[['BOX', 10, 40, 0], ['CUP', 5, 10, 2], ['CUP', 1, 10, 2], ['BWL', 5, 30, 6], ['BWL', 0, 30, 6]], 100, 2], [474, False]], ['nesting', [[['CUP', 10, 10, 2]], 30, 1], [28, True]], ['merged lines nest together', [[['CUP', 5, 10, 2], ['CUP', 5, 10, 2]], 30, 1], [28, True]], ['non nesting', [[['BOX', 2, 40, 0]], 80, 1], [80, True]], ['generated mix 20', [[['BOX', 5, 40, 0]], 120, 1], [200, False]], ['generated mix 28', [[['TRY', 0, 25, 5]], 120, 1], [0, True]], ['generated mix 36', [[['CUP', 0, 10, 2], ['TRY', 1, 25, 5], ['BOX', 1, 40, 0], ['BWL', 5, 30, 6]], 100, 3], [119, False]]], [['generated mix 67', [[['TRY', 2, 25, 5], ['BOX', 10, 40, 0], ['LID', 0, 4, 0], ['TRY', 0, 25, 5]], 100, 1], [430, False]], ['generated mix 61', [[['TRY', 1, 25, 5], ['TRY', 5, 25, 5], ['TRY', 2, 25, 5]], 100, 1], [60, True]], ['zero line', [[['CUP', 1, 10, 2], ['BOX', 0, 40, 0]], 30, 1], [10, True]], ['sku limit', [[['CUP', 1, 10, 2], ['LID', 1, 4, 0]], 100, 1], [14, False]], ['capacity equal', [[['CUP', 11, 10, 2]], 30, 1], [30, True]], ['generated mix 31', [[['BOX', 2, 40, 0], ['BOX', 5, 40, 0], ['LID', 10, 4, 0], ['LID', 0, 4, 0]], 80, 3], [320, False]], ['generated mix 39', [[['BOX', 10, 40, 0], ['LID', 0, 4, 0]], 120, 3], [400, False]], ['generated mix 47', [[['TRY', 10, 25, 5]], 80, 1], [70, True]]], [['generated mix 1', [[['LID', 0, 4, 0], ['TRY', 10, 25, 5], ['TRY', 5, 25, 5], ['CUP', 2, 10, 2], ['BWL', 10, 30, 6]], 120, 2], [191, False]], ['generated mix 73', [[['LID', 10, 4, 0], ['CUP', 5, 10, 2], ['BOX', 1, 40, 0], ['CUP', 10, 10, 2], ['LID', 10, 4, 0]], 100, 3], [158, False]], ['nesting', [[['CUP', 10, 10, 2]], 30, 1], [28, True]], ['merged lines nest together', [[['CUP', 5, 10, 2], ['CUP', 5, 10, 2]], 30, 1], [28, True]], ['non nesting', [[['BOX', 2, 40, 0]], 80, 1], [80, True]], ['generated mix 43', [[['LID', 2, 4, 0], ['TRY', 5, 25, 5]], 100, 2], [53, True]], ['generated mix 51', [[['LID', 10, 4, 0], ['TRY', 0, 25, 5], ['BWL', 10, 30, 6]], 150, 2], [124, True]], ['generated mix 59', [[['LID', 0, 4, 0], ['BOX', 2, 40, 0], ['LID', 10, 4, 0], ['BWL', 5, 30, 6]], 50, 3], [174, False]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
merged lines nest together[18, True][28, True]Failed
generated mix 1[141, False][191, False]Failed
nesting[28, True][28, True]Passed
zero line[10, True][10, True]Passed
sku limit[14, False][14, False]Passed
capacity equal[30, True][30, True]Passed
non nesting[80, True][80, True]Passed
generated mix 9[374, False][374, False]Passed

SHA-256 / 0bd5d3e25250398df5d55b4c299bb45a88b20079e93be5706b11f6094c720e4c

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(lines, bin_vol, max_skus):
    merged = {}
    for sku, qty, uv, nv in lines:
        if sku in merged:
            merged[sku][0] = max(merged[sku][0], qty)
        else:
            merged[sku] = [qty, uv, nv]
    total = 0
    count = 0
    for sku, (qty, uv, nv) in merged.items():
        if qty <= 0:
            continue
        count += 1
        if nv > 0:
            total += uv + (qty - 1) * nv
        else:
            total += qty * uv
    return [total, total <= bin_vol and count <= max_skus]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['merged lines nest together', [[['CUP', 5, 10, 2], ['CUP', 5, 10, 2]], 30, 1], [28, True]], ['generated mix 1', [[['LID', 0, 4, 0], ['TRY', 10, 25, 5], ['TRY', 5, 25, 5], ['CUP', 2, 10, 2], ['BWL', 10, 30, 6]], 120, 2], [191, False]], ['nesting', [[['CUP', 10, 10, 2]], 30, 1], [28, True]], ['zero line', [[['CUP', 1, 10, 2], ['BOX', 0, 40, 0]], 30, 1], [10, True]], ['sku limit', [[['CUP', 1, 10, 2], ['LID', 1, 4, 0]], 100, 1], [14, False]], ['capacity equal', [[['CUP', 11, 10, 2]], 30, 1], [30, True]], ['non nesting', [[['BOX', 2, 40, 0]], 80, 1], [80, True]], ['generated mix 9', [[['CUP', 10, 10, 2], ['TRY', 10, 25, 5], ['BOX', 5, 40, 0], ['LID', 10, 4, 0], ['BWL', 2, 30, 6]], 80, 1], [374, False]]], [['generated mix 23', [[['TRY', 2, 25, 5], ['CUP', 10, 10, 2], ['TRY', 0, 25, 5]], 150, 2], [58, True]], ['generated mix 22', [[['BOX', 2, 40, 0], ['BOX', 10, 40, 0], ['BOX', 0, 40, 0], ['BOX', 2, 40, 0], ['LID', 1, 4, 0]], 50, 2], [564, False]], ['zero line', [[['CUP', 1, 10, 2], ['BOX', 0, 40, 0]], 30, 1], [10, True]], ['sku limit', [[['CUP', 1, 10, 2], ['LID', 1, 4, 0]], 100, 1], [14, False]], ['capacity equal', [[['CUP', 11, 10, 2]], 30, 1], [30, True]], ['generated mix 9', [[['CUP', 10, 10, 2], ['TRY', 10, 25, 5], ['BOX', 5, 40, 0], ['LID', 10, 4, 0], ['BWL', 2, 30, 6]], 80, 1], [374, False]], ['generated mix 17', [[['CUP', 5, 10, 2]], 50, 2], [18, True]], ['generated mix 27', [[['CUP', 2, 10, 2]], 100, 1], [12, True]]], [['generated mix 42', [[['LID', 5, 4, 0], ['BWL', 1, 30, 6], ['BWL', 1, 30, 6]], 100, 2], [56, True]], ['generated mix 40', [[['BOX', 10, 40, 0], ['CUP', 5, 10, 2], ['CUP', 1, 10, 2], ['BWL', 5, 30, 6], ['BWL', 0, 30, 6]], 100, 2], [474, False]], ['nesting', [[['CUP', 10, 10, 2]], 30, 1], [28, True]], ['merged lines nest together', [[['CUP', 5, 10, 2], ['CUP', 5, 10, 2]], 30, 1], [28, True]], ['non nesting', [[['BOX', 2, 40, 0]], 80, 1], [80, True]], ['generated mix 20', [[['BOX', 5, 40, 0]], 120, 1], [200, False]], ['generated mix 28', [[['TRY', 0, 25, 5]], 120, 1], [0, True]], ['generated mix 36', [[['CUP', 0, 10, 2], ['TRY', 1, 25, 5], ['BOX', 1, 40, 0], ['BWL', 5, 30, 6]], 100, 3], [119, False]]], [['generated mix 67', [[['TRY', 2, 25, 5], ['BOX', 10, 40, 0], ['LID', 0, 4, 0], ['TRY', 0, 25, 5]], 100, 1], [430, False]], ['generated mix 61', [[['TRY', 1, 25, 5], ['TRY', 5, 25, 5], ['TRY', 2, 25, 5]], 100, 1], [60, True]], ['zero line', [[['CUP', 1, 10, 2], ['BOX', 0, 40, 0]], 30, 1], [10, True]], ['sku limit', [[['CUP', 1, 10, 2], ['LID', 1, 4, 0]], 100, 1], [14, False]], ['capacity equal', [[['CUP', 11, 10, 2]], 30, 1], [30, True]], ['generated mix 31', [[['BOX', 2, 40, 0], ['BOX', 5, 40, 0], ['LID', 10, 4, 0], ['LID', 0, 4, 0]], 80, 3], [320, False]], ['generated mix 39', [[['BOX', 10, 40, 0], ['LID', 0, 4, 0]], 120, 3], [400, False]], ['generated mix 47', [[['TRY', 10, 25, 5]], 80, 1], [70, True]]], [['generated mix 1', [[['LID', 0, 4, 0], ['TRY', 10, 25, 5], ['TRY', 5, 25, 5], ['CUP', 2, 10, 2], ['BWL', 10, 30, 6]], 120, 2], [191, False]], ['generated mix 73', [[['LID', 10, 4, 0], ['CUP', 5, 10, 2], ['BOX', 1, 40, 0], ['CUP', 10, 10, 2], ['LID', 10, 4, 0]], 100, 3], [158, False]], ['nesting', [[['CUP', 10, 10, 2]], 30, 1], [28, True]], ['merged lines nest together', [[['CUP', 5, 10, 2], ['CUP', 5, 10, 2]], 30, 1], [28, True]], ['non nesting', [[['BOX', 2, 40, 0]], 80, 1], [80, True]], ['generated mix 43', [[['LID', 2, 4, 0], ['TRY', 5, 25, 5]], 100, 2], [53, True]], ['generated mix 51', [[['LID', 10, 4, 0], ['TRY', 0, 25, 5], ['BWL', 10, 30, 6]], 150, 2], [124, True]], ['generated mix 59', [[['LID', 0, 4, 0], ['BOX', 2, 40, 0], ['LID', 10, 4, 0], ['BWL', 5, 30, 6]], 50, 3], [174, False]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
merged lines nest together[18, True][28, True]Failed
generated mix 1[166, False][191, False]Failed
nesting[28, True][28, True]Passed
zero line[10, True][10, True]Passed
sku limit[14, False][14, False]Passed
capacity equal[30, True][30, True]Passed
non nesting[80, True][80, True]Passed
generated mix 9[374, False][374, False]Passed

SHA-256 / cb46be7ed22ac94367b6822ecd0e6fe87cff09a7ed42454fb9f117ba509e736f

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(lines, bin_vol, max_skus):
    merged = {}
    for sku, qty, uv, nv in lines:
        if sku in merged:
            merged[sku][0] += qty
        else:
            merged[sku] = [qty, uv, nv]
    total = 0
    count = 0
    for sku, (qty, uv, nv) in merged.items():
        if qty <= 0:
            continue
        count += 1
        if nv > 0:
            total += uv + (qty - 1) * nv
        else:
            total += qty * uv
    return [total, total <= bin_vol and count <= max_skus]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['merged lines nest together', [[['CUP', 5, 10, 2], ['CUP', 5, 10, 2]], 30, 1], [28, True]], ['generated mix 1', [[['LID', 0, 4, 0], ['TRY', 10, 25, 5], ['TRY', 5, 25, 5], ['CUP', 2, 10, 2], ['BWL', 10, 30, 6]], 120, 2], [191, False]], ['nesting', [[['CUP', 10, 10, 2]], 30, 1], [28, True]], ['zero line', [[['CUP', 1, 10, 2], ['BOX', 0, 40, 0]], 30, 1], [10, True]], ['sku limit', [[['CUP', 1, 10, 2], ['LID', 1, 4, 0]], 100, 1], [14, False]], ['capacity equal', [[['CUP', 11, 10, 2]], 30, 1], [30, True]], ['non nesting', [[['BOX', 2, 40, 0]], 80, 1], [80, True]], ['generated mix 9', [[['CUP', 10, 10, 2], ['TRY', 10, 25, 5], ['BOX', 5, 40, 0], ['LID', 10, 4, 0], ['BWL', 2, 30, 6]], 80, 1], [374, False]]], [['generated mix 23', [[['TRY', 2, 25, 5], ['CUP', 10, 10, 2], ['TRY', 0, 25, 5]], 150, 2], [58, True]], ['generated mix 22', [[['BOX', 2, 40, 0], ['BOX', 10, 40, 0], ['BOX', 0, 40, 0], ['BOX', 2, 40, 0], ['LID', 1, 4, 0]], 50, 2], [564, False]], ['zero line', [[['CUP', 1, 10, 2], ['BOX', 0, 40, 0]], 30, 1], [10, True]], ['sku limit', [[['CUP', 1, 10, 2], ['LID', 1, 4, 0]], 100, 1], [14, False]], ['capacity equal', [[['CUP', 11, 10, 2]], 30, 1], [30, True]], ['generated mix 9', [[['CUP', 10, 10, 2], ['TRY', 10, 25, 5], ['BOX', 5, 40, 0], ['LID', 10, 4, 0], ['BWL', 2, 30, 6]], 80, 1], [374, False]], ['generated mix 17', [[['CUP', 5, 10, 2]], 50, 2], [18, True]], ['generated mix 27', [[['CUP', 2, 10, 2]], 100, 1], [12, True]]], [['generated mix 42', [[['LID', 5, 4, 0], ['BWL', 1, 30, 6], ['BWL', 1, 30, 6]], 100, 2], [56, True]], ['generated mix 40', [[['BOX', 10, 40, 0], ['CUP', 5, 10, 2], ['CUP', 1, 10, 2], ['BWL', 5, 30, 6], ['BWL', 0, 30, 6]], 100, 2], [474, False]], ['nesting', [[['CUP', 10, 10, 2]], 30, 1], [28, True]], ['merged lines nest together', [[['CUP', 5, 10, 2], ['CUP', 5, 10, 2]], 30, 1], [28, True]], ['non nesting', [[['BOX', 2, 40, 0]], 80, 1], [80, True]], ['generated mix 20', [[['BOX', 5, 40, 0]], 120, 1], [200, False]], ['generated mix 28', [[['TRY', 0, 25, 5]], 120, 1], [0, True]], ['generated mix 36', [[['CUP', 0, 10, 2], ['TRY', 1, 25, 5], ['BOX', 1, 40, 0], ['BWL', 5, 30, 6]], 100, 3], [119, False]]], [['generated mix 67', [[['TRY', 2, 25, 5], ['BOX', 10, 40, 0], ['LID', 0, 4, 0], ['TRY', 0, 25, 5]], 100, 1], [430, False]], ['generated mix 61', [[['TRY', 1, 25, 5], ['TRY', 5, 25, 5], ['TRY', 2, 25, 5]], 100, 1], [60, True]], ['zero line', [[['CUP', 1, 10, 2], ['BOX', 0, 40, 0]], 30, 1], [10, True]], ['sku limit', [[['CUP', 1, 10, 2], ['LID', 1, 4, 0]], 100, 1], [14, False]], ['capacity equal', [[['CUP', 11, 10, 2]], 30, 1], [30, True]], ['generated mix 31', [[['BOX', 2, 40, 0], ['BOX', 5, 40, 0], ['LID', 10, 4, 0], ['LID', 0, 4, 0]], 80, 3], [320, False]], ['generated mix 39', [[['BOX', 10, 40, 0], ['LID', 0, 4, 0]], 120, 3], [400, False]], ['generated mix 47', [[['TRY', 10, 25, 5]], 80, 1], [70, True]]], [['generated mix 1', [[['LID', 0, 4, 0], ['TRY', 10, 25, 5], ['TRY', 5, 25, 5], ['CUP', 2, 10, 2], ['BWL', 10, 30, 6]], 120, 2], [191, False]], ['generated mix 73', [[['LID', 10, 4, 0], ['CUP', 5, 10, 2], ['BOX', 1, 40, 0], ['CUP', 10, 10, 2], ['LID', 10, 4, 0]], 100, 3], [158, False]], ['nesting', [[['CUP', 10, 10, 2]], 30, 1], [28, True]], ['merged lines nest together', [[['CUP', 5, 10, 2], ['CUP', 5, 10, 2]], 30, 1], [28, True]], ['non nesting', [[['BOX', 2, 40, 0]], 80, 1], [80, True]], ['generated mix 43', [[['LID', 2, 4, 0], ['TRY', 5, 25, 5]], 100, 2], [53, True]], ['generated mix 51', [[['LID', 10, 4, 0], ['TRY', 0, 25, 5], ['BWL', 10, 30, 6]], 150, 2], [124, True]], ['generated mix 59', [[['LID', 0, 4, 0], ['BOX', 2, 40, 0], ['LID', 10, 4, 0], ['BWL', 5, 30, 6]], 50, 3], [174, False]]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
merged lines nest together[28, True][28, True]Passed
generated mix 1[191, False][191, False]Passed
nesting[28, True][28, True]Passed
zero line[10, True][10, True]Passed
sku limit[14, False][14, False]Passed
capacity equal[30, True][30, True]Passed
non nesting[80, True][80, True]Passed
generated mix 9[374, False][374, False]Passed

SHA-256 / f834c70b4e19280ffc929adad00923a8e93c365529d1d99df58c8158f495c4f2

Verification & scope

Stipulated linear nesting model; no orientation or partial stacks. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:52:11.169229+00:00.

Case digest / a9f4ff40bc3410a3ac3e13f58cfc883de2614e0861e48313eb753373237137df