Skip to content

Order picking (C++)

The C++ lives in optimaru/order_picking/cpp/; the paths below are relative to it, and its C++ tests are in tests/order_picking/cpp/.

Derived from the Timefold Quickstarts order-picking example (Apache-2.0; see the repository NOTICE). Only the domain and constraints are implemented here, on top of the generic engine (core/optimaru, header-only).

  • op/model/domain.hpp — warehouse layout (5 shelf columns x 3 rows, left/right sides, rows 0-10), calculateDistance, domain structs, the sequence-shape SolutionTraits specialization (the trolley's pickTaskIndices is the decision: the ordered list of pick tasks it visits).
  • op/score/score_calculator.hpp — full recompute + derived values (trolleyIndex/previousPickTask/nextPickTask) recalculation + per-constraint totals (ConstraintTotals, members named after the registry names, at the components' kDefaultWeight).
  • op/constraints/ — one component per constraint: trolley_capacity_cost.hpp (TrolleyCapacityCost, hard 1), distance_from_previous_pick_task_cost.hpp (DistanceFromPreviousPickTaskCost, soft 1), distance_from_last_pick_task_to_path_origin_cost.hpp (DistanceFromLastPickTaskToPathOriginCost, soft 1), order_split_by_trolley_cost.hpp (OrderSplitByTrolleyCost, soft 1000) (+ common.hpp); op/constraints.hpp assembles the default set (defaultConstraints(), also the constraint_info() catalog).
  • op/score/incremental_calculator.hpp — before/after_list_edit hooks for per-trolley O(list) incremental scoring (checked against full recompute under ScoreChecks::Full).
  • op/solver.hpp — engine wrapper (sequence move mix + ALNS + warehouse-distance nearby).
  • op/model/demo_data.cpp — the demo warehouse, drawn from a seeded std::mt19937_64 (seed 37): 37-product catalog, 8 orders, 5 trolleys x 4 buckets x 48000 cm3).

Build / run

cmake -B build -DCMAKE_BUILD_TYPE=Release -DOPTIMARU_USE_CASES=order_picking
cmake --build build -j4
./build/order_picking/op_test         # per-constraint hand checks + incremental==full + ScoreChecks::Full solve
./build/order_picking/op_plugin_test  # plugin assembly == monolith, raw costs by hand, catalog, overrides
./build/order_picking/op_demo         # 10 s solve of the demo warehouse, reaches feasible (hard 0)