Documentation, organised by the question you arrived with.
Start, common tasks, understand and reference stay separate, so the contract can be looked up without reading an argument about architecture first.
Docs for Packvium 1.12.x · contract stable since 1.0
I need to…
The reference below is organised by what the engine is. These are organised by what you came to do: each one is a recipe with the smallest snippet that does it, the rule it relies on, and a complete request to run.
- Pick the cheapest box that still fitsObjectivesWeight and payloadRun it →
- Split one SKU across as many cartons as it needsWeight and payloadGeometryRun it →
- Keep a fragile item unstackedStackingTop loadRun it →
- Keep two SKUs from ever sharing a containerCompatibility and policyRun it →
- Model a wheel arch or roof shelfObstacles and clearanceRun it →
- Keep a two-axle load compliantCentre of mass and axle loadWeight and payloadRun it →
- Compute a safe unload sequenceLoad order
- Cap a pallet's stack within its own crush ratingStackingTop loadRun it →
- Let a load overhang the pallet by a set marginGeometrySupportRun it →
- Ship flat goods in a gusseted mailerGeometryRun it →
- Pack bottles into a pouch that stands on its bottom gussetGeometryRun it →
- Keep loaded items where they areGeometryIndependent validationRun it →
- Pack units into cartons, then cartons onto a palletGeometryWeight and payload
- Cut a box to the order instead of choosing oneGeometryObjectivesRun it →
- Cap the search and keep the answer repeatableObjectivesRun it →
- Read why an item was refusedWeight and payloadGeometryIndependent validationRun it →
- Pack in fractional inches without roundingUnits and numericsGeometryRun it →
- Declare an item that does not fill its boxItem shapesGeometry
START
Get one real answer out of it
First packed container
Install one package, send one request on stdin and read the answer in order: the status, the containers, what was left behind and the score.
- Install the engine for your runtime
- Send the smallest useful request
- Read the answer in order
Getting started in Python
Install packvium, build items and containers as Python objects, run Packer.pack(), and read why an item was left out rather than guessing.
- Install
- Build items and containers
- Run pack() and read the result
- Handle items the engine could not place
- What is already checked before you see it
- Check a result yourself
- Next steps
Getting started in PHP
Install packvium/packvium, build items and containers as immutable value objects, call Packer::pack(), and read why an item was left out.
- Install
- Build items and containers
- Run pack() and read the result
- Handle items the engine could not place
- What is already checked before you see it
- Check a result yourself
- Next steps
Getting started in Node
Install @packvium/engine, call pack() with a plain object, and read why an item was left out.
- Install
- Call pack() and read the result
- Handle items the engine could not place
- What is already checked before you see it
- Check a result yourself
- Write a result as JSON
- Next steps
Getting started in Rust
Add packvium, call pack_json() with the request as a string, and read the result back out of the JSON it returns.
- Install
- Call pack_json() and read the result
- Handle items the engine could not place
- What is already checked before you see it
- Check a result yourself
- Next steps
Getting started in the browser
Install @packvium/browser, await pack() with a plain object, and read why an item was left out.
- Install
- Call pack() and read the result
- Handle items the engine could not place
- What is already checked before you see it
- Check a result yourself
- Write a result as JSON
- Next steps
Getting started in Go
Add the Go module, build items and containers from validated specs, call Pack(), and read why an item was left out.
- Install
- Build items and containers
- Run Pack() and read the result
- Handle items the engine could not place
- The same JSON contract, from the command line
- Hand the result to a warehouse system
- Even out the weight across containers
- Where it differs from the reference engine
- Next steps
Getting started in Java
Add com.packvium:packvium, build items and containers with builders, call Packer.pack(), and read why an item was left out.
- Install
- Build items, run pack() and read the result
- Handle items the engine could not place
- Pack a JSON request
- Hand the result to a warehouse system
- Even out the weight across containers
- Where it differs from the reference engine
- Next steps
Getting started in .NET
Add the Packvium NuGet package, build items and containers, call Packer.Pack(), read why an item was left out, and export a work order.
- Install
- Build items, run Pack() and read the result
- Handle items the engine could not place
- Pack a JSON request
- Hand the result to a warehouse system
- Even out the weight across containers
- Where it differs from the reference engine
- Next steps
COMMON TASKS
Solve one specific task
Shipping quotes and policy rules
Price a shipment against your own versioned rate card, decide whether it may ship at all, and keep the exact version every decision used.
- What the commerce layer does
- Publish your rates as one document
- Quote a shipment
- A rejection is an answer, a malformed request is a bug
- May it ship at all? Policy rules
- Which master data was used? Catalog versions
- Next steps
Extending an engine
Five in-process extension points, and the rule that decides when a rule belongs in the request instead of a private application scorer.
- What you can replace
- Extensions are not cross-language features
- When it belongs in the request
UNDERSTAND
Understand why it is built this way
Why a library, not a service
The layer boundary that keeps a solver free of networks, clocks and databases, and why packing ships as a library rather than a service.
- A call in, immutable data out
- Commerce is a leaf, not a dependency
- Determinism is a boundary, not a setting
Building a deterministic packing engine, four times
Why this engine is four independent implementations held to one conformance corpus, not one core with four bindings.
- The problem: a box that fits on paper and not in the truck
- Why floating point is the wrong arithmetic for this decision
- Determinism is a boundary, not a setting
- One request document, four independent implementations
- A validator that shares no code with the solver
- How the benchmark numbers are allowed to be published
- The tradeoffs this makes on purpose
- What this does not do
REFERENCE
Look up the exact contract
Request and result contract
The public fields, what each status means, and the rule a capability must satisfy before it is one: schema, fixture, validator, docs.
- One schema, four engines
- What a capability requires
- Refusals are structured
- A malformed request is refused by name
The objective vector
How results are ranked, why every key is an exact integer, and what an equal score does not imply: what was left over comes first.
- Five keys, compared lexicographically
- What was left over comes first
- A lower bound, and the gap to it
- The formula is universal, the value is not
Execution plans
Turn a validated result into a work order an operator can follow, without letting the layer that explains a decision start making one.
- A view of a result, not a second solver
- Facts and presentation are kept apart
- A placement is named by what the contract promises
- Step order is supplied, never guessed
- Why an alternative lost
- Operator locks, in Python
- Every placement has an id (1.10.0)
Plan revisions and fixed placements
Replan a job already under way: loaded items stay put, and every change is recorded against the plan it changed.
- Items already loaded stay where they are
- A fixed item is a real placement
- A fixed set that cannot hold is refused before any search
- A revision records what happened on the dock
- The replan is an ordinary solve
- An audit that does not stop at the first problem
- One surface per language
Scenarios and recommendations
Compare a catalog or rule change on recorded orders, replay it on unseen history, and publish it only through approval. Python only.
- Python only, supported and not frozen
- A scenario runs against a pin, never against current
- A comparison is never one number
- A proposal cannot publish itself
- Replay on history the proposal did not see
- What history can and cannot prove
Start with one packed container.
Install one package and pack eight cubes into one carton. Once you have read a real status, a real score and a real refusal, the rest of the contract explains itself.