USE CASE / BOX-SELECTION

Box selection: choose the cheapest box that still fits

An order has several item types and more than one box size. You want the packer to say what fits, and name exactly why anything did not.

WHEN YOU NEED THIS

Whenever more than one container size is genuinely eligible and cost, not just fit, should decide between them - a fulfilment system picking from a rate card of box sizes, or a quoting tool comparing candidate crates.

Every container carries its own cost, so a lowest-cost objective (or, here, a single candidate box) picks between them on price rather than a heuristic guess. Each item that does not fit comes back with a reason instead of a silent drop.

SHOWN IN Node / JavaScript
import { pack } from '@packvium/engine';

const request = {
  configuration: { objective: 'lowest_cost' },
  items: [
    { id: 'mug', quantity: 6, weight: '400 g',
      dimensions: { length: '120', width: '120', height: '100' } },
    { id: 'plate', quantity: 8, weight: '600 g',
      dimensions: { length: '260', width: '260', height: '20' } },
    // Too long for the box in every orientation.
    { id: 'ladder', quantity: 1, weight: '6 kg',
      dimensions: { length: '1800', width: '300', height: '100' } },
  ],
  containers: [
    { id: 'box', cost_minor: 180, max_payload: '15 kg',
      inner_dimensions: { length: '400', width: '400', height: '400' } },
  ],
};

const result = pack(request);
console.log(result.status, result.containers.length, 'opened');

for (const unpacked of result.unpacked_items) {
  // e.g. "ladder#1 no_compatible_container_dimensions"
  console.log(unpacked.item_id, unpacked.reason);
}
WHAT COMES BACK

The status comes back as best_found rather than feasible: the mugs and plates place, and the ladder comes back among the unplaced items. Its reason is that no container here has dimensions that hold it in any orientation - not that the box filled up, which is a different refusal with a different fix. An answer, not an exception to catch.

THE PACKED RESULT, IN 3D
20×20×20 · 12.5% used
cube × 1
WHAT A REFUSAL LOOKS LIKE HERE
box-selectionProven

Too large for every container on offer no_compatible_container_dimensions

The ladder is 1800 mm long against a 400 mm container in every dimension. Cost never enters the decision for this item - it is refused on geometry before the objective gets a vote.

WHAT CHANGES IN YOUR PROCESS
TODAY
  • The default is the box that is surely big enough, so most parcels ship with air in them.
  • Carriers bill that air as dimensional weight, and the charge only shows up on the invoice.
  • Nobody can say which box size earns its shelf space.
WITH PACKVIUM
  • Every order is packed into the cheapest box that actually holds it, with box prices you set.
  • The box's outside size is known before the label is printed, so dimensional weight is no surprise.
  • The box sizes the engine never picks across a month of orders are the ones to stop stocking.
WHAT TO MEASURE
  • Dimensional-weight surcharges per month
  • Average empty volume per parcel
  • How often each stocked box size is used

Run a month of past orders through the same request and compare these numbers with what you actually shipped. That comparison, on your own data, is the only figure worth quoting.

WHY PACKVIUM

A lowest-cost objective that silently drops the one item that doesn't fit is worse than no objective at all. Packvium ranks by cost only among arrangements that are actually feasible, and names the exception.

Open this request
INSTALL
npm install @packvium/engine