注文書は客が入れた順序だ。倉庫はラックが置かれた順序だ。
その二つは何の関係もない。 ところが大半のピッキング一覧は注文書の順序のまま印刷される。すると人が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
この検査は問いかけられる記録で最初に使った形だ。画面に出た数値がソースに文字列で埋め込まれていれば、それは計算ではなく絵だ。