订单是客人放进购物车的顺序。仓库是货架摆放的顺序。
这两者毫无关系。 可大多数拣货清单就照订单顺序打印出来。于是人跑到 1 号通道,再跑到 4 号通道,再折回 1 号通道。
不主张,去量
「排个序就快了」谁都会说。这个样例把两条路线都算出来,一起摆到画面上。

as typed 106 steps · walking order 82 steps · saved 24 steps
按订单走是 106 步,按货架顺序走是 82 步。一张五行的订单就拉开了 24 步。
步数的计算是故意做得粗糙的。
/// Crude on purpose: moving along an aisle costs one per bay, and changing
/// aisle costs the walk to the end and back. It does not need to be a real
/// floor plan to show that the two sequences are not the same length.
哪怕不是真实的仓库平面图,「两个顺序的长度不一样」这件事也看得见。那就是这一篇主张的全部;再多主张就需要平面图了。
排序不是数据
订单里不该有「顺序」这个字段。顺序是从位置里生出来的,不是被送进来的。
/// The same lines, in the sequence a person actually walks.
List<Line> get _walkOrder => List.of(_lines)
..sort((a, b) {
final byAisle = a.slot.aisle.compareTo(b.slot.aisle);
if (byAisle != 0) return byAisle;
return a.slot.bay.compareTo(b.slot.bay);
});
东西被挪到别的货架,从下一次拣货开始顺序就自己变了。要是顺序被存了下来,就得有人把它们全部重算,而因为没人去做,清单就一点点错下去。
验证会确认那个顺序。
grep -q "walking order: A1-03-L1 -> A1-14-L2 -> A2-09-L1 -> A4-02-L3 -> A4-12-L2" captures/run.log \
|| { echo " the route changed — check whether it is still a walk"; exit 1; }
而且测试装置自己也检查排序。
final sorted = List.of(slots)..sort();
expect(slots, sorted, reason: 'the route must be in walking order');
省下的步数不能出现在源码里
24 这个数字是从哪来的,就是这篇文章全部的可信度。 所以只要源码里有这个数字,验证就失败。
SAVED=$(grep -o "saved [0-9]* steps" captures/run.log | head -1 | awk '{print $2}')
[ "$SAVED" -gt 0 ] || { echo " walking order saved nothing — the claim fails"; exit 1; }
if grep -RIn --exclude-dir=captures -F "$SAVED steps" pick_server/bin pick.mbd >/dev/null 2>&1; then
echo " the saving $SAVED is written literally in the source — it must be measured"
exit 1
fi
walking order saved 24 steps, and that number is nowhere in the source
这个检查最早出现在可以追问的记录。画面上的数值如果在源码里被写成字符串,那它不是计算,是画上去的。