Karyo
Documentation/ Decision records

ADR 0060: The physical hierarchy Area > Zone > Aisle > Bay > Level > Position, with one distance service

Karyo 2.1.1rendered at build time
On this page

Status: Accepted

Context

Proximity putaway, proximity pick, task interleaving and the flow model all need the walking distance between two locations in metres. Before this change Karyo knew only grid steps: Warehouse setup stores x_pos (the step along a run), y_pos (the run, one per aisle face) and z_pos (the level), and put-away candidate ordering compares those steps. Steps are not metres, two zones can share the same steps, and nothing says where a zone stands on the floor.

ADR 0059 renamed the former usage role to Location Class and reserved the name Area for a physical part of a building. Karyo 2.0.0 has not shipped, so the hierarchy and its contracts can be added now without a compatibility alias.

Decision

The hierarchy. A Facility has physical Areas, an Area has zones, and a zone has aisles. A location in an aisle has a bay (the Nth bay from the aisle's front end), a level (level 1 is the floor) and a position (its place across its bay). A location outside aisles, such as a dock door or a staging lane, has an optional floor point: metres along and across its zone, or its Area when it has no zone. Every zone is in exactly one Area. The physical Area is not the Location Class, and not StorageArea, WorkingArea, StorageStrategyArea or ItemDataArea, which stay sets of location clusters.

A place comes from the label. A location's bay, level and position are the values in its own label, never a count from the first label of a range, a run or an earlier setup. So the place does not depend on how setup was split. Labels A-01-1 to A-20-1 and A-01-2 to A-20-5 give A-01-2 bay 1 and level 2, directly above A-01-1. Labels A-01 to A-10 and A-11 to A-20 give A-11 bay 11, ten bays along the aisle from A-01. A later setup that adds levels over existing bays places them above those bays. Letters count as numbers: A is 1, B is 2 and AA is 27. A both-faced range puts the odd bays on one face and the even bays on the other, and bays 2n - 1 and 2n stand opposite each other as bay n. A label with no bay, level or position part is one bay, level 1 or position 1. A label whose bay, level or position is below 1, such as a level 00 or a bay 00, has no place in an aisle and keeps the single-point rule; a position above 1000 has none either. A bay that does not start at 1 keeps its label number, so a run that starts at A-05 begins four bays along the aisle. The grid steps x_pos, y_pos and z_pos are unchanged and still count from each range's first label.

Aisle is a record, not text on each location. It holds its zone, name, order in the zone, positions per bay, whether it is double-sided and its size overrides. A database key on (aisle_id, zone_id) keeps every aisle location in its aisle's zone. Warehouse setup finds or creates one aisle for each (zone, rack), the identity ADR 0035 already uses.

The label and grid fields stay. rack, field, section and x_pos, y_pos, z_pos keep their meaning and their writers. Candidate ordering still reads them for the POSITION_X and POSITION_Y sort keys. The new fields sit beside them, and Warehouse setup writes both.

Sizes. Three sizes turn a place into metres: aisle spacing centre to centre (4.5 m: a 2.3 m walking aisle and two 1.1 m rack depths), bay width (2.7 m) and level height (1.5 m). The Facility values are the runtime settings karyo.layout.aisle-spacing-metres, karyo.layout.bay-width-metres and karyo.layout.level-height-metres. An Area, a zone or an aisle may override each one, and the nearest override wins. A position is bay width / positions per bay wide.

The floor point of a location.

  • An Area without a start of its own stands across from the Area before it, in sequence order. A zone without a start stands across from the zone before it in its Area. A zone is as wide as the spacing of its aisles, one spacing when it has none, and as long as its longest aisle.
  • along = Area start + zone start + (bay - 1) x bay width + (position - 0.5) x position width.
  • across = Area start + zone start + the spacing of every aisle before this one in the zone.
  • height = (level - 1) x level height.
  • Both faces of a double-sided aisle share the aisle's one walking line, so the two faces of one bay are 0 m apart on the floor.
  • A location outside aisles without a floor point stands at its zone's entry, or at its Area's entry when it has no zone. Each entry is the middle of the front edge.

Travel. Travel follows aisles and cross-aisles, never a straight line:

  • Same aisle: the distance along the aisle.
  • Other aisle in the same zone: out to the nearer common end (the front or the back cross-aisle), along it, and into the other aisle. Two open-floor points in one zone walk straight along and then across.
  • Other zone, same Area or another Area: out of the aisle at its front end, to the zone's entry, across to the other zone's entry, and in. A location outside every zone is its own door.
  • Lift is reported apart from the walk: the forks go down from the first height and up to the second, so lift is h1 + h2, or |h1 - h2| when nothing walks.

Distances round to centimetres. The route is reported as SAME_AISLE, SAME_ZONE, SAME_AREA or OTHER_AREA.

One distance service. FloorPlan is the pure model above, and FloorPlanService reads one Facility's rows into it. LocationDistanceLookup in karyo-layout-api is the seam other modules call. The flow model takes an immutable snapshot through this seam, so a simulated day uses the same aisle-based walk metres without reading live rows during the run. Lift metres stay separate. Proximity putaway uses distances (ADR 0061); proximity pick routing shares the snapshot's route with the simulator (ADR 0062); task interleaving measures the walk from the operator's position (ADR 0063).

Upgrade. Layout V1606 creates one Main Area for each Facility that has zones and keeps the zones' creation order. For every location with a zone, a rack, a bay in field and grid steps from 1 (the shape Warehouse setup stores), it creates one aisle for each zone and rack. It reads the bay from field and the level and the position from the tokens of the location's name that follow the rack and the bay, in the default aisle, bay, level, position order, by the rule above. These are the places new setup gives the same labels. The grid steps count from each range's first label, so V1606 does not read them for a place. A location whose name does not carry its rack and bay, or whose bay, level or position is below 1 or not a number, keeps no place, like every other location. Its version is 1606 because it must follow V1605, which freed the areas table name.

Consequences

Defaults alone give sensible distances, so an installation that never sets a size still gets a usable floor. A site that differs sets one value at the level where it differs.

/api/v1/areas changes meaning before 2.0.0: it served the usage role until ADR 0059, and now serves the physical Area. A client written against the old contract gets the new resource, not an error. The HTTP surface lists every changed contract.

The model is one floor. Areas on different floors, lifts between them, one-way aisles, blocked cross-aisles and a zone with more than one entry are not modelled. A zone has a front and a back cross-aisle at the ends of its longest aisle; a shorter aisle still reaches the back one.

Both sets of fields can disagree when someone edits one and not the other through the API, because only Warehouse setup writes both. Proximity putaway ranks by distances: the TRAVEL_DISTANCE sort key and nearPickingLocation measure the walk from the place fields (ADR 0061). The grid fields stay authoritative for the POSITION_X and POSITION_Y sort keys, and for a nearPickingLocation candidate that the walk cannot measure.

Alternatives considered

  • Aisle as text on the location. It would need no table, but positions per bay, the order in the zone and the size overrides would have no home, and a rename would touch every location.
  • Replacing x_pos, y_pos and z_pos. It would remove the duplication, but candidate ordering, the occupancy drawing and ADR 0035's extension rules read them today. Proximity putaway ranks by distances and leaves them in place.
  • Straight-line or plain rectilinear distance. It is cheaper, but it walks through racks: two locations back to back in neighbouring aisles would look one aisle spacing apart.
  • Sizes only on the Facility. Simpler, but a mezzanine or a narrow-aisle zone would then distort every distance through it.
  • Lift folded into the walk. It would give one number, but reach-truck lift and walking have different costs, and the consumers that weigh them are not built yet.

Evidence

  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/FloorPlan.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/FloorPlanService.kt
  • services/warehouse-layout-service/karyo-layout-api/src/main/kotlin/com/karyo/layout/spi/LocationDistanceLookup.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/LocationPlaces.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/service/WarehouseSetupService.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/domain/model/Area.kt
  • services/warehouse-layout-service/karyo-layout-core/src/main/kotlin/com/karyo/layout/domain/model/Aisle.kt
  • services/auth-service/karyo-auth-core/src/main/kotlin/com/karyo/auth/config/SystemPropertyCatalog.kt
  • services/karyo-app/src/main/resources/db/migration/layout/V1606__physical_hierarchy.sql
  • services/karyo-app/src/test/kotlin/com/karyo/layout/service/FloorPlanTest.kt