FAILURE MAP
← Case archive

FA-95836 / Shipping rate zone lookup / Open access

LTL breaks: weight rounded to nearest pound · case 01

Fractional pounds below one half are not billed.

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

ROOT CAUSE

Weight is rounded to nearest instead of up.

VERIFIED REPAIR

Round weight up to a whole pound.

Unsuccessful approach: Truncating the weight drops every fraction.

Case contract

Weight breaks 0, 500, 1000, 2000, 5000, 10000 lb with cents-per-cwt rates for the lane. Weight rounds up to a whole lb (min 1) and is rated at its break: ceil(w * rate / 100). Deficit rating: if billing any heavier break minimum at that break rate is strictly cheaper, use the cheapest such. Charge is at least min_charge. Return [charge, break index, rated weight].

Why this case matters

LTL lane rates use weight breaks with deficit weight rating.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(weight, rates, min_charge):
    BREAKS = [0, 500, 1000, 2000, 5000, 10000]
    w = max(1, round(weight))
    idx = max(i for i, b in enumerate(BREAKS) if w >= b)
    cost = -(-w * rates[idx] // 100)
    best = [cost, idx, w]
    for j in range(idx + 1, len(BREAKS)):
        alt = BREAKS[j] * rates[j] // 100
        if alt < best[0]:
            best = [alt, j, BREAKS[j]]
    return [max(best[0], min_charge), best[1], best[2]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['fraction', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [28836, 1, 801]], ['generated mix 4', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 9000], [14152, 0, 334]], ['deficit to 500', [450, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['on break', [500, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['generated mix 7', [480, [4200, 3600, 3000, 2500, 2100, 1800], 0], [18000, 1, 500]], ['generated mix 15', [1700, [5000, 4900, 1000, 900, 800, 700], 20000], [20000, 2, 1700]]], [['generated mix 45', [800.5, [4237, 3611, 3044, 2517, 2150, 1833], 9000], [28925, 1, 801]], ['generated mix 25', [333.3, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [14028, 0, 334]], ['fraction', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [28836, 1, 801]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['deficit to 500', [450, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['generated mix 9', [499.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['generated mix 17', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 20000], [20000, 0, 334]]], [['generated mix 6', [800.5, [4237, 3611, 3044, 2517, 2150, 1833], 20000], [28925, 1, 801]], ['generated mix 56', [333.3, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [14028, 0, 334]], ['skip a break', [400, [5000, 4900, 1000, 900, 800, 700], 0], [10000, 2, 1000]], ['on break', [500, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['fraction', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [28836, 1, 801]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['generated mix 21', [1700, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [50000, 3, 2000]], ['generated mix 29', [499.5, [4237, 3611, 3044, 2517, 2150, 1833], 20000], [20000, 1, 500]]], [['generated mix 48', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 0], [14152, 0, 334]], ['generated mix 19', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 20000], [28836, 1, 801]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['deficit to 1000', [850, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [30000, 2, 1000]], ['skip a break', [400, [5000, 4900, 1000, 900, 800, 700], 0], [10000, 2, 1000]], ['on break', [500, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['generated mix 32', [850, [5000, 4900, 1000, 900, 800, 700], 9000], [10000, 2, 1000]], ['generated mix 40', [9000, [4237, 3611, 3044, 2517, 2150, 1833], 0], [183300, 5, 10000]]], [['generated mix 19', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 20000], [28836, 1, 801]], ['generated mix 48', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 0], [14152, 0, 334]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['deficit to 500', [450, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['deficit to 1000', [850, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [30000, 2, 1000]], ['generated mix 43', [850, [5000, 4900, 1000, 900, 800, 700], 20000], [20000, 2, 1000]], ['generated mix 52', [850, [4200, 3600, 3000, 2500, 2100, 1800], 20000], [30000, 2, 1000]]]]
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
fraction[28800, 1, 800][28836, 1, 801]Failed
generated mix 4[14110, 0, 333][14152, 0, 334]Failed
deficit to 500[18000, 1, 500][18000, 1, 500]Passed
minimum[9000, 0, 100][9000, 0, 100]Passed
tie keeps actual[18000, 0, 450][18000, 0, 450]Passed
on break[18000, 1, 500][18000, 1, 500]Passed
generated mix 7[18000, 1, 500][18000, 1, 500]Passed
generated mix 15[20000, 2, 1700][20000, 2, 1700]Passed

SHA-256 / f16685aae71c4a742c77d59abe8878d78c155a90e0694c4c0b8f51c754021fb4

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(weight, rates, min_charge):
    BREAKS = [0, 500, 1000, 2000, 5000, 10000]
    w = max(1, int(weight))
    idx = max(i for i, b in enumerate(BREAKS) if w >= b)
    cost = -(-w * rates[idx] // 100)
    best = [cost, idx, w]
    for j in range(idx + 1, len(BREAKS)):
        alt = BREAKS[j] * rates[j] // 100
        if alt < best[0]:
            best = [alt, j, BREAKS[j]]
    return [max(best[0], min_charge), best[1], best[2]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['fraction', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [28836, 1, 801]], ['generated mix 4', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 9000], [14152, 0, 334]], ['deficit to 500', [450, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['on break', [500, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['generated mix 7', [480, [4200, 3600, 3000, 2500, 2100, 1800], 0], [18000, 1, 500]], ['generated mix 15', [1700, [5000, 4900, 1000, 900, 800, 700], 20000], [20000, 2, 1700]]], [['generated mix 45', [800.5, [4237, 3611, 3044, 2517, 2150, 1833], 9000], [28925, 1, 801]], ['generated mix 25', [333.3, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [14028, 0, 334]], ['fraction', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [28836, 1, 801]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['deficit to 500', [450, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['generated mix 9', [499.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['generated mix 17', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 20000], [20000, 0, 334]]], [['generated mix 6', [800.5, [4237, 3611, 3044, 2517, 2150, 1833], 20000], [28925, 1, 801]], ['generated mix 56', [333.3, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [14028, 0, 334]], ['skip a break', [400, [5000, 4900, 1000, 900, 800, 700], 0], [10000, 2, 1000]], ['on break', [500, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['fraction', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [28836, 1, 801]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['generated mix 21', [1700, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [50000, 3, 2000]], ['generated mix 29', [499.5, [4237, 3611, 3044, 2517, 2150, 1833], 20000], [20000, 1, 500]]], [['generated mix 48', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 0], [14152, 0, 334]], ['generated mix 19', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 20000], [28836, 1, 801]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['deficit to 1000', [850, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [30000, 2, 1000]], ['skip a break', [400, [5000, 4900, 1000, 900, 800, 700], 0], [10000, 2, 1000]], ['on break', [500, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['generated mix 32', [850, [5000, 4900, 1000, 900, 800, 700], 9000], [10000, 2, 1000]], ['generated mix 40', [9000, [4237, 3611, 3044, 2517, 2150, 1833], 0], [183300, 5, 10000]]], [['generated mix 19', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 20000], [28836, 1, 801]], ['generated mix 48', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 0], [14152, 0, 334]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['deficit to 500', [450, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['deficit to 1000', [850, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [30000, 2, 1000]], ['generated mix 43', [850, [5000, 4900, 1000, 900, 800, 700], 20000], [20000, 2, 1000]], ['generated mix 52', [850, [4200, 3600, 3000, 2500, 2100, 1800], 20000], [30000, 2, 1000]]]]
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
fraction[28800, 1, 800][28836, 1, 801]Failed
generated mix 4[14110, 0, 333][14152, 0, 334]Failed
deficit to 500[18000, 1, 500][18000, 1, 500]Passed
minimum[9000, 0, 100][9000, 0, 100]Passed
tie keeps actual[18000, 0, 450][18000, 0, 450]Passed
on break[18000, 1, 500][18000, 1, 500]Passed
generated mix 7[18000, 1, 500][18000, 1, 500]Passed
generated mix 15[20000, 2, 1700][20000, 2, 1700]Passed

SHA-256 / 889b4e764923ee555651cc4d04a54ea7e4d356161660dcc61bb1eacb9e8cbedd

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(weight, rates, min_charge):
    BREAKS = [0, 500, 1000, 2000, 5000, 10000]
    w = max(1, math.ceil(weight))
    idx = max(i for i, b in enumerate(BREAKS) if w >= b)
    cost = -(-w * rates[idx] // 100)
    best = [cost, idx, w]
    for j in range(idx + 1, len(BREAKS)):
        alt = BREAKS[j] * rates[j] // 100
        if alt < best[0]:
            best = [alt, j, BREAKS[j]]
    return [max(best[0], min_charge), best[1], best[2]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['fraction', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [28836, 1, 801]], ['generated mix 4', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 9000], [14152, 0, 334]], ['deficit to 500', [450, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['on break', [500, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['generated mix 7', [480, [4200, 3600, 3000, 2500, 2100, 1800], 0], [18000, 1, 500]], ['generated mix 15', [1700, [5000, 4900, 1000, 900, 800, 700], 20000], [20000, 2, 1700]]], [['generated mix 45', [800.5, [4237, 3611, 3044, 2517, 2150, 1833], 9000], [28925, 1, 801]], ['generated mix 25', [333.3, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [14028, 0, 334]], ['fraction', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [28836, 1, 801]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['deficit to 500', [450, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['generated mix 9', [499.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['generated mix 17', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 20000], [20000, 0, 334]]], [['generated mix 6', [800.5, [4237, 3611, 3044, 2517, 2150, 1833], 20000], [28925, 1, 801]], ['generated mix 56', [333.3, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [14028, 0, 334]], ['skip a break', [400, [5000, 4900, 1000, 900, 800, 700], 0], [10000, 2, 1000]], ['on break', [500, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['fraction', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [28836, 1, 801]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['generated mix 21', [1700, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [50000, 3, 2000]], ['generated mix 29', [499.5, [4237, 3611, 3044, 2517, 2150, 1833], 20000], [20000, 1, 500]]], [['generated mix 48', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 0], [14152, 0, 334]], ['generated mix 19', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 20000], [28836, 1, 801]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['deficit to 1000', [850, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [30000, 2, 1000]], ['skip a break', [400, [5000, 4900, 1000, 900, 800, 700], 0], [10000, 2, 1000]], ['on break', [500, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['generated mix 32', [850, [5000, 4900, 1000, 900, 800, 700], 9000], [10000, 2, 1000]], ['generated mix 40', [9000, [4237, 3611, 3044, 2517, 2150, 1833], 0], [183300, 5, 10000]]], [['generated mix 19', [800.5, [4200, 3600, 3000, 2500, 2100, 1800], 20000], [28836, 1, 801]], ['generated mix 48', [333.3, [4237, 3611, 3044, 2517, 2150, 1833], 0], [14152, 0, 334]], ['tie keeps actual', [450, [4000, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 0, 450]], ['deficit to 500', [450, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [18000, 1, 500]], ['minimum', [100, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [9000, 0, 100]], ['deficit to 1000', [850, [4200, 3600, 3000, 2500, 2100, 1800], 9000], [30000, 2, 1000]], ['generated mix 43', [850, [5000, 4900, 1000, 900, 800, 700], 20000], [20000, 2, 1000]], ['generated mix 52', [850, [4200, 3600, 3000, 2500, 2100, 1800], 20000], [30000, 2, 1000]]]]
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
fraction[28836, 1, 801][28836, 1, 801]Passed
generated mix 4[14152, 0, 334][14152, 0, 334]Passed
deficit to 500[18000, 1, 500][18000, 1, 500]Passed
minimum[9000, 0, 100][9000, 0, 100]Passed
tie keeps actual[18000, 0, 450][18000, 0, 450]Passed
on break[18000, 1, 500][18000, 1, 500]Passed
generated mix 7[18000, 1, 500][18000, 1, 500]Passed
generated mix 15[20000, 2, 1700][20000, 2, 1700]Passed

SHA-256 / 8106909f8b33d887d9fbccb86a8157c482544763e011fc5f4e005a2efef24828

Verification & scope

Stipulated break table; no freight class or accessorials. 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:17.339420+00:00.

Case digest / 05eb2bc165a15ec0c5ba87672bda97d6bb694a6bc5fc597dfc472c7a0d1dfd59