Skip to content
PalletLab
Side by side

Side by side

Claims like "extreme points is better" need evidence. The bench app produces it.

Fair comparison

  • Same inputs: for every seed both packers get the identical carton set.
  • Many seeds: 50 per size, because one lucky seed proves nothing.
  • Mean ± standard deviation: the spread matters as much as the average.
40 cartons, 50 seedsGreedy layerExtreme points
Cartons placed55.0% ± 8.590.5% ± 5.7
Pallet filled37.4% ± 6.164.2% ± 4.2
Density43.0% ± 7.165.9% ± 4.7
Center of mass off-centre193 ± 37 mm73 ± 24 mm
Planning time0.05 ms3.2 ms

Extreme points places more volume on 50 of 50 seeds, and its smaller standard deviation means it is also more consistent.

Welford's algorithm

The benchmark computes mean and variance in one pass without storing samples:

void add(double x) {
    ++n;
    double delta = x - mean;
    mean += delta / n;
    m2 += delta * (x - mean);   // variance = m2 / (n - 1)
}

The textbook "average of squares minus square of average" loses precision badly in floating point; Welford's update is numerically stable.

Timing

std::chrono::steady_clock never jumps (the wall clock can, when it syncs), so it is the right clock for measuring durations. For micro-benchmarks, Google Benchmark adds warm-up, repetitions and Big-O fitting.