Separating groups along the carrier

A job can ask for its cargo to be loaded as contiguous blocks along the carrier, one block per group, in an order you choose. Each group then loads and unloads as one physically contiguous section.

When to use this

  • A load that is unloaded in stages, where each stage's cargo has to come off as one block and the cargo needed last is loaded first. This API has no notion of routes or stops: you decide which group comes off when, and express that as the order the sections are packed in.
  • A load shared between customers, where each customer's cargo has to come off as one block.
  • Any load where a group has to be reachable without moving another group first.

It is not free. A section's leftover space cannot be filled by another group's cargo, so a separated job may need more carriers than the same cargo would without it, and it takes longer to solve because every section is solved separately. Leave it off unless the contiguity is worth that.

Walkthrough

By default cargo[].groups is a free label array: you can hang a route, a customer and a handling note on the same line and none of them moves a box. To make one of those labels decide where cargo sits, you do two things, and they are deliberately separate.

Declare the group. The top-level groups block names the groups this job knows about and gives each one a packingOrder. Declaring a name is what promotes it from a label into a claim on a section of the carrier. A label you do not declare here stays inert, which is what makes this additive: a request that declares nothing behaves exactly as it always has.

Activate the separation. configuration.groupSeparation says how strictly to keep the declared groups apart. Today it takes one mode, segmented. Omit the block and there is no separation, whatever the groups block contains. That is on purpose: you can leave your declarations in the request permanently and turn the behaviour on and off with one field, without restructuring your cargo.

{
  "groups": {
    "route-a": { "packingOrder": 1 },
    "route-b": { "packingOrder": 2 }
  },
  "cargo": [
    { "groups": ["route-a", "fragile"], ... },       // section route-a; "fragile" does nothing
    { "groups": ["route-b"], ... },                    // section route-b
    { "groups": ["fragile"], ... }                     // no declared group: the trailing section
  ],
  "configuration": { "groupSeparation": { "mode": "segmented" } }
}

Sections follow the unloading order in reverse, because the section nearest the doors comes off first. With the default -X consolidation, take three stops unloaded in the order A, B, C: give them packingOrder 3, 2 and 1, so C sits at the front wall (x = 0) and A at the doors.

{
  "groups": {
    "stop-a": { "packingOrder": 3 },
    "stop-b": { "packingOrder": 2 },
    "stop-c": { "packingOrder": 1 }
  }
}

What segmented guarantees

Each declared group gets its own contiguous stretch of the carrier along the packing axis, in packingOrder order, with 1 nearest the front wall (x = 0) under the default -X consolidation, which packs toward it, and nearest the y = 0 side under -Y. The sections sit end to end along whichever horizontal axis you consolidate on, -X or -Y. Within a carrier they are never interleaved: a later section is never placed in front of an earlier one.

Cargo that matches no declared group is not scattered and does not jump the queue. It shares a single section that follows every declared one, wherever those lines happen to sit in cargo[].

Across carriers, each declared group stays on one carrier by default. When a group does not fit entirely, the carrier closes at that group: the group and everything packed behind it, including cargo that matches no declared group, continue on the next carrier, so the sections keep their packingOrder from one carrier to the next. A group too large for the empty carrier it would start on goes to the first later entry in carriers[] whose empty carrier takes it whole, for that carrier only. Before the last carrier, only a group no entry can take whole is split, and every carrier it spans starts with it. Each of those carriers is chosen the same way: what is left of the group goes to the first entry whose empty carrier takes it whole or, while none does, to the first entry whose empty carrier takes each of its units on its own. A unit that fits no carrier at all is left unplaced on its own and never holds its group back. A unit fits a carrier when it fits its size and, if the carrier has a maxWeight, its own weight is within it. The last carrier is the exception: when there is no next carrier, because every entry has a fixed quantity and this is the only carrier left, it does not close at a group. As much of the group as fits is loaded, the sections behind it get the room it leaves (often none, since a group that does not fit runs to the end of the carrier), and what does not fit comes back in unplacedItems. An entry that was tried and loaded none of the remaining cargo no longer counts as left. Set keepTogether to false on a group to let it split instead; its remainder can then land on a carrier after one that already holds the group behind it.

Each group kept together (packingOrder: group-a 1, group-b 2, group-c 3); group-b does not fit behind group-a:
  carrier 1: [ group-a ]
  carrier 2: [ group-b ][ group-c ]

group-b is too large for any entry's empty carrier:
  carrier 1: [ group-a ]
  carrier 2: [ group-b, part 1       ]
  carrier 3: [ group-b, part 2 ][ group-c ]

One carrier (quantity 1); group-b does not fit whole behind group-a:
  carrier 1: [ group-a ][ group-b, part ]
  unplacedItems: the rest of group-b, and group-c (no room left behind group-b)

In every case, packing a group can leave less usable room than its volume alone suggests, and a carrier that closes early leaves the room behind the cut empty, so a separated job may need more carriers than the same cargo would without it.

One job, three ways

The diagram shows one job's cargo loaded three ways: three declared groups, group-a, group-b and group-c, with packingOrder 1, 2 and 3, where group-b does not fit entirely behind group-a.

Three rows, each with the same cargo of group-a, group-b and group-c in two carriers seen from the side. Without group separation, the boxes of the three groups are shown mixed through both carriers. With keepTogether false on group-b, carrier 1 holds group-a and the first part of group-b, and carrier 2 holds the rest of group-b and then group-c. With keepTogether at its default, carrier 1 holds only group-a and the room behind it stays empty, and carrier 2 holds group-b and then group-c.
  • Top row. The request has no configuration.groupSeparation, so the group names are only labels and the cargo of the three groups can end up mixed on both carriers.
  • Middle row. The request sets configuration.groupSeparation and sends "keepTogether": false on group-b, so group-b fills the rest of carrier 1 behind group-a and continues on carrier 2.
  • Bottom row. The request sets configuration.groupSeparation and leaves keepTogether at its default, so carrier 1 closes behind group-a and group-b starts carrier 2 whole.

Reading the result

To find which section a placement belongs to, intersect its groups array with the names the job declared. At most one can match, because while configuration.groupSeparation is set a cargo line may name only one declared group. A placement that matches none belongs to the section that follows all declared groups.

The rules

RuleWhy
packingOrder is required on every declared group while groupSeparation is set, and the values must be distinct.A group with no order has nowhere to sit, and a tie has no answer that is not arbitrary. Gaps are fine: 10, 20, 30 leaves room to insert a group later without renumbering. A missing, repeated or below-1 value is rejected with 400 against that group's packingOrder, e.g. /groups/route-b/packingOrder.
A cargo line may name at most one declared group while groupSeparation is set.One unit cannot occupy two sections. Naming two is rejected with 400 against that line's groups (/cargo/{i}/groups). To split a line between groups, send one cargo line per group. Without groupSeparation, declared groups stay inert and a line may name several.
A line may still carry undeclared labels too, up to 10 labels in all.["route-a", "fragile"] keeps working: only route-a is declared, so it decides the section and fragile stays a label.
Matching is case-sensitive.The result echoes your labels back verbatim, so folding case here would merge two groups you see as distinct. Route-A does not match a declared route-a; it falls into the trailing section.
At most 20 declared groups, and a name is at most 64 characters.Each section costs its own solve and they share one time budget, which is what makes 20 the ceiling. Both limits apply whether or not groupSeparation is set, so switching it on never turns a body the API accepted into one it rejects. Rejected with 400 against /groups.
A declared group nobody references is allowed.It simply produces no section, so a fixed set of routes can live in a request template.
groupSeparation with no declared group is rejected.You asked for a discipline with nothing to govern. The 400 points at /configuration/groupSeparation.
groupSeparation cannot be combined with a Z consolidation direction.A section is a slice of the carrier taken along the packing axis. Sliced vertically, every section above the first would start at the highest point of the one below it, leaving its cargo hanging over empty space. Consolidate on -X or -Y instead; the pair is rejected with 400 rather than solved into a load that cannot be built.
A declared group stays on one carrier unless its keepTogether is false.A group usually stands for one customer's cargo, and splitting it over two vehicles is the case this prevents. When it does not fit entirely the carrier closes at that group, which keeps packingOrder intact across carriers at the cost of the room behind it. A group too large for the empty carrier it would start on goes to a later entry that takes it whole; before the last carrier, only a group no entry can take whole is still split. A unit that fits no carrier at all is left unplaced on its own and never holds its group back. A unit fits a carrier when it fits its size and, if the carrier has a maxWeight, its own weight is within it. The last carrier the job can use does not close at a group: it loads as much of the group as fits, and the rest is left unplaced. Like packingOrder, it has no effect without groupSeparation.

Key fields

FieldWhereTypeNotes
groups job object The groups this job declares, keyed by the name a cargo line opts into. At most 20; a name is 1-64 characters. Declaring a group nobody references is allowed and produces no section.
groups[name].packingOrder declared group integer Where the section sits along the packing axis; 1 is nearest the front wall (x = 0) under the default -X consolidation, and the y = 0 side under -Y. Required on every declared group once groupSeparation is set, distinct across groups, gaps allowed.
groups[name].keepTogether declared group boolean Optional, default true; null is the same as leaving it out. Keeps the group on one carrier: if it does not fit entirely, the carrier closes at this group. Set false to allow a split across carriers. No effect without groupSeparation.
cargo[].groups cargo entry string[] Free labels. While configuration.groupSeparation is set, at most one of them may be a declared group; the rest stay inert. Echoed back as groups on placements and unplaced items (and under the deprecated name group).
configuration.groupSeparation.mode job string Only segmented today. Required whenever the groupSeparation object is present; omit the whole object to switch the feature off.