Dangerous Goods Segregation in Container Packing: What a Plan Must Respect
Most packing plans are judged on one number: fill percentage. Dangerous goods plans are judged on a different question entirely — can this container be sealed at all?
Segregation rules decide that. If two risk types must not travel together, it doesn’t matter that the solver found a 91% fill; the load is wrong. If a container’s risk point ceiling is exceeded, the plan is wrong. And because a packing plan is generated by a heuristic engine working under a time budget, the only responsible posture is to check the output against the rules you declared.
This article is about that check. Not how the optimiser works — see The 3D Bin Packing Problem, Explained Without the Math for that — but what a dangerous goods plan has to contain for you to be able to prove it is compliant, and how to run that proof using the RSJ 3D Packer API.
Why Verification Matters for Dangerous Goods Segregation
Segregation is a hard constraint in a way that fill percentage never is. A mediocre fill wastes money. A missed segregation rule produces a container that a carrier can reject, a terminal can refuse, or a surveyor can flag long after the doors are closed — and the cost of unwinding that is measured in days, not in cubic metres.
There is a second reason verification matters here specifically: the solver returns a heuristically optimised plan for the static 3D bin packing problem within a 240-second budget per request. Heuristic means good, not provably optimal. The responsible workflow is therefore not “trust the plan” but “read the plan.”
RSJ 3D Packer builds segregation into the optimisation itself — risk types, risk points and incompatible pairs are inputs to the solve, not a post-processing filter. The plan that comes back already respects them. But “already respects them” is a claim, and claims about dangerous goods should be confirmable from the returned data.
That’s what verification means here: confirming, from packedItems, unpackedItems and the container summaries, that every risk constraint you declared is visible in the result.
What a Verifiable Dangerous Goods Packing Plan Contains
A plan you can actually check has to answer five questions without guesswork.
- Where did each item go? Every packed item must come back with its container index (
c) and itsx/y/zposition. Without coordinates, a placement is an assertion rather than a fact. - What didn’t fit, and how much of it?
unpackedItemscarries the item dimensions and a remainingcount. A plan that silently drops items is not a plan. - How full is each container? The container summary includes
used(how many of the declaredcountwere opened) andfilled(percentage), so you can see the whole picture rather than one aggregate number. - Are risk points within limits? For every container, the sum of
riskPointsacross the items placed in it must stay at or below that container’sallowedRiskPoints. - Are incompatible risk types co-loaded? No container may contain two risk types that appear as a pair in your
risksarray.
RSJ 3D Packer’s POST /solve response gives you all five. A trimmed example:
{
"containers": [
{ "width": 48, "height": 47, "depth": 46, "count": 1, "used": 1, "filled": 76.77, "first": 0 }
],
"items": [
{ "width": 11, "height": 6, "depth": 6, "count": 51, "vertical": true, "remaining": 0 }
],
"packedItems": [
{ "id": 0, "c": 0, "width": 11, "height": 6, "depth": 6, "x": 0, "y": 0, "z": 0 }
],
"unpackedItems": [
{ "id": 2, "width": 8, "height": 9, "depth": 10, "weight": 0, "itemClass": 0, "count": 17 }
]
}
Note that packedItems references items by id. That is why you should assign your own id values in the request — it makes the mapping from a placement back to its declared risk profile unambiguous.
Step-by-Step Verification Using RSJ 3D Packer
1. Declare the constraints you intend to verify
Verification can only confirm what you declared. Risk types and risk points are the dangerous goods fields on an item; allowedRiskPoints is the ceiling on a container; risks declares the incompatible pairs.
{
"containers": [
{ "width": 48, "height": 47, "depth": 46, "count": 2, "weight": 2000, "allowedRiskPoints": 1000 }
],
"items": [
{ "id": 0, "width": 11, "height": 6, "depth": 6, "count": 51 },
{
"id": 1,
"width": 7, "height": 8, "depth": 9, "count": 53,
"vertical": false,
"itemClass": 1,
"weight": 12
},
{
"id": 2,
"width": 8, "height": 9, "depth": 10, "count": 57,
"riskTypes": [1, 2],
"riskPoints": 10
}
],
"risks": [{ "type1": 1, "type2": 2 }]
}
Two details worth pausing on. "vertical": false means the item may not be rotated out of its upright position — relevant for anything that must stay upright in transit. And itemClass controls stacking: an item is only ever placed on items of a lower or equal class.
Dangerous goods handling — risk types and risk points — is a Pro feature. The free 30-day test exposes the full Pro feature set, so you can build and validate this workflow before committing.
2. Submit the problem
curl -s -X POST https://3dpacker.rsj.de/solve \
-H "Authorization: Bearer session-1bc90169-1c83-443e-8ed7-b0328aaf78a5" \
-H "Content-Type: application/json" \
-d @problem.json
The session comes from GET /user/{email}?hmac={hmac} and is valid for roughly a day — fetch a fresh one rather than storing it. The same request works interactively in the API sandbox, which pairs a live request playground with a 3D preview, and the schema is published as OpenAPI 3.0.
If you’d rather click than curl, the browser application runs the same solve with an interactive 3D view of the result.
3. Recompute the risk arithmetic yourself
This is the core of the check. Walk packedItems, join each id back to the declared item, and accumulate risk points and risk types per container key c.
import requests
from collections import defaultdict
BASE = "https://3dpacker.rsj.de"
HEADERS = {"Authorization": "Bearer session-1bc90169-1c83-443e-8ed7-b0328aaf78a5"}
problem = {
"containers": [{"width": 48, "height": 47, "depth": 46, "count": 2,
"weight": 2000, "allowedRiskPoints": 1000}],
"items": [
{"id": 0, "width": 11, "height": 6, "depth": 6, "count": 51},
{"id": 2, "width": 8, "height": 9, "depth": 10, "count": 57,
"riskTypes": [1, 2], "riskPoints": 10},
],
"risks": [{"type1": 1, "type2": 2}],
}
# 240 s solver budget -> allow a little more on the client side
plan = requests.post(f"{BASE}/solve", json=problem, headers=HEADERS, timeout=300).json()
declared = {item["id"]: item for item in problem["items"]}
limit = problem["containers"][0].get("allowedRiskPoints")
forbidden = {(r["type1"], r["type2"]) for r in problem.get("risks", [])}
points = defaultdict(float)
types = defaultdict(set)
for placement in plan["packedItems"]:
src = declared[placement["id"]]
points[placement["c"]] += src.get("riskPoints", 0)
types[placement["c"]].update(src.get("riskTypes", []))
problems = []
for c, used_points in sorted(points.items()):
if limit is not None and used_points > limit:
problems.append(f"container {c}: {used_points} risk points > limit {limit}")
for a, b in forbidden:
if a in types[c] and b in types[c]:
problems.append(f"container {c}: risk types {a} and {b} co-loaded")
print("\n".join(problems) if problems else "all declared risk constraints hold")
print("containers used:", sum(c["used"] for c in plan["containers"]))
print("unpacked:", [(u["id"], u["count"]) for u in plan["unpackedItems"]])
Run it, keep it next to your solve call, and re-run it whenever the input problem changes. It’s a few dozen lines and it turns “the solver said so” into “we checked.”
4. Inspect the geometry, not just the totals
Aggregate checks catch risk point and incompatibility breaches. They don’t catch a placement that looks wrong to a human. For that, open the viewer URL returned with the result: an interactive 3D rendering of the plan you can rotate, zoom and inspect, embeddable in an IFRAME if you want the same view inside your own tooling. The solution can also be downloaded as a GLB 3D model for use in other viewers.
The geometry is sound by construction — every packed item is supported by the item below it, so there are no floating placements — but a visual pass is the fastest way to catch a modelling mistake in your own input.
Interpreting Results and Handling Edge Cases
Items in unpackedItems. This list tells you what the plan could not place and in what quantity. If the excluded items are dangerous goods, the cause is usually one of three things: the container’s allowedRiskPoints is too low for the quantities involved, the risks pairs are mutually exclusive for this mix, or there simply isn’t enough physical volume. Adjust the ceiling, add containers, or split the shipment — then re-solve and re-verify.
Risk types without risk points. An item can carry riskTypes and no riskPoints. It still counts for the incompatibility check, because risks pairs are evaluated on types. If you’re relying on risk points as your only ceiling, an item like this passes the arithmetic without being constrained at all — so declare points wherever they’re meaningful, and keep the risks array current.
Distribution across containers. When you declare a count greater than one for a container type, the solver may spread dangerous goods across containers to keep each one under its ceiling. That’s legitimate segregation, but it changes your container count. Always read used and usedContainers before you quote a shipment.
Heuristic, not proof. The solver runs a neural network optimised through neuro-evolution within a 240-second budget per request, on every plan. That produces strong solutions to the static problem — items may be packed in any order — but it is not an optimality guarantee. Verify the final output against the regulations that apply to your cargo and lane.
Fixed order requirements. If your process needs a fixed packing order or a required unpacking order, the algorithm can be adapted for that dynamic case. That’s a conversation with RSJ rather than an API flag.
Common Pitfalls in Dangerous Goods Segregation
- Treating risk points as the whole story. Points are a per-container budget; risk types plus the
risksarray are the incompatibility layer. You need both declared. - Omitting
allowedRiskPoints. If you don’t declare a ceiling on a container, you haven’t given the solver a limit to hold the plan against. Declare it explicitly on every container that will hold dangerous goods. - Forgetting
vertical: false. A load that’s segregated correctly but arrives on its side is still a failed shipment. - Ignoring
itemClass. Segregation interacts with stacking: an item is only ever placed on items of a lower or equal class. Wrong classes produce a plan that’s compliant on paper and impossible in the trailer. - Leaving
risksempty. The solver cannot avoid a pairing you never declared. An emptyrisksarray is a statement that nothing is incompatible — make sure that’s true.
How RSJ 3D Packer Simplifies Verification
The workflow above is short because segregation is native to the solve. There’s no reconciliation step, no patching a generic packer’s output, no third-party rule engine bolted on afterwards.
- The optimiser consumes
riskTypes,riskPoints,allowedRiskPointsandrisksdirectly, so the returned plan is already a segregated plan. - The API returns per-item placements with container index and
x/y/z, plusunpackedItemsand container summaries — everything a verification script needs, in structured JSON. - The web UI gives you an interactive 3D view of the same result, and the GLB export lets you inspect it elsewhere.
- The cloud version integrates with Google Sheets through its own add-on, so spreadsheet-driven workflows can run and inspect plans without leaving the sheet — see Automate Container Loading Plans Straight From Google Sheets.
- For on-premises requirements, RSJ 3D Packer runs on Windows 10/11 64-bit or Ubuntu Linux 64-bit with 16 GB RAM and 4 GB disk.
If you’re wiring this into a larger integration, Packing Optimisation API for Developers: What to Check covers the surrounding API concerns.
FAQ
Can RSJ 3D Packer handle multiple risk types per item?
Yes. Each item can have an array of riskTypes (integers) and a riskPoints value. The solver ensures that no container exceeds its allowedRiskPoints and that incompatible risk type pairs — declared in the risks array — are not loaded together.
What happens if an item cannot be packed due to segregation rules?
The item appears in the unpackedItems list with its count. You can then adjust container risk limits, add more containers, or split the shipment. The solver always returns a complete plan showing what was packed and what was not.
Is the 240-second time budget enough for complex dangerous goods problems?
The solver uses a neural network optimised through neuro-evolution and works within a 240-second budget per request. For most problems this yields a good heuristic solution. If you need a different approach, consider the on-premises option or contact RSJ about adapting the algorithm.
Can I verify the plan programmatically without manual inspection?
Yes. The API response includes packedItems with container index and coordinates, unpackedItems, and container summaries. You can write a script to check that risk points per container do not exceed limits and that no incompatible risk types share a container — the Python snippet above is a working starting point.
Conclusion
Dangerous goods segregation turns a packing plan into a document you may have to defend. The engine does the hard part: it treats risk types, risk points and incompatible pairs as inputs to the optimisation, so the plan it returns is built around them rather than corrected afterwards. Your job is the last mile — read packedItems, sum the risk points per container, cross-check the risks pairs, look at the geometry in the viewer, and keep that check in version control next to the problem definition.
You can run the whole loop today: start a free 30-day test — it exposes the full Pro feature set, including dangerous goods handling — or review plans and checkout when you’re ready to move beyond the trial.
Related posts
- Automate Container Loading Plans Straight From Google Sheets
- Packing Optimisation API for Developers: What to Check
- The 3D Bin Packing Problem, Explained Without the Math