# Experimental Results Benchmarks ran on a Linux desktop (AMD Ryzen 7 5700G, 62 GB RAM; single-threaded unless noted). * **Graphs:** [polygons (k = 3..12)](graphs/polygons_small.png) · [single-query runtime](graphs/single_query_time.png) · [batch table work](graphs/batch_work.png) · [polygon structure](graphs/polygon_structure.png) * **Raw data:** [k_1_10000.csv](results/k_1_10000.csv) · [polys_1_10000.tar.gz](results/polys_1_10000.tar.gz) · [scaling.csv](results/scaling.csv) · [spread_7_13.csv](results/spread_7_13.csv) · [spread_14.csv](results/spread_14.csv) · [rowmax_compare.csv](results/rowmax_compare.csv) ## All counts k = 1..10000 [`results/k_1_10000.csv`](results/k_1_10000.csv) (perimeter, bounding box, vertex count, checks) and [`results/polys_1_10000.tar.gz`](results/polys_1_10000.tar.gz) (one vertex file per $k$). `kgrid range 1 10000` takes 0.1 s (1.9 s when writing the 10,000 polygon files). Validation: * vs. the unrestricted knapsack (`kgrid oracle`, no windows, no certificate): identical for every $k \le 10^6$ (max relative difference $2.3\cdot 10^{-15}$); * vs. an independent exact solver: identical for all 10,024 tested counts ($3\le k\le 10{,}000$ and 26 counts up to $2\cdot 10^6$; max relative difference $5.4\cdot 10^{-15}$); * every polygon: integer vertices, strictly convex, exactly $k$ lattice points by Pick's theorem, perimeter from the vertices matches the table value. ## Batch runs (`range`, one table per radius, 3 worker threads) | range | time | peak RSS | failures | |---|---|---|---| | 1..10^5 | 0.29 s | 12 MB | 0 | | 1..10^6 | 4.3 s (1.2 s with --no-poly) | 57 MB | 0 | | 1..10^7 | 75.6 s (11.6 s with --no-poly) | 381 MB | 0 | All 1784 radii of the 10^7 run were certified in two passes; max Delta* = 2.78. Every polygon was reconstructed and checked by Pick's theorem. ## Single queries (`results/scaling.csv`, polygon reconstructed and checked) | k | perimeter | vertices | time | peak RSS | |---|---|---|---|---| | 10^8 | 35448.8099865197 | 1128 | 0.02 s | 4 MB | | 10^10 | 354490.641436474 | 5232 | 0.28 s | 18 MB | | 10^12 | 3544907.64065238 | 24248 | 2.9 s | 70 MB | | 10^13 | 11209982.3907354 | 52232 | 11.7 s | 214 MB | | 10^14 | 35449076.9892694 | 112608 | 119 s | 1.2 GB | | 10^15 | 112099824.308192 | 241947 | 269 s | 2.0 GB | | 10^16 | 354490770.167571 | 522128 | 80 min | 11.8 GB | Cost varies with k (with Delta*, the number of feasible side sums, and the position of k within its radius), so one sample per decade is not enough. `results/spread_7_13.csv` has, per decade, the first and last count of a radius and 3 random counts. Each was solved normally and again with the certified windows inflated (`--inflate 2`: Delta* + 2, side sums ± 2). All 39 agree exactly (35 for 10^6..10^13 in `results/spread_7_13.csv`, 4 for 10^14), and all polygons check: | decade | runs | max time | median | max RSS | max Delta* | |---|---|---|---|---|---| | 10^7 | 5 | 0.03 s | 0.03 s | 4 MB | 0.90 | | 10^8 | 5 | 0.10 s | 0.09 s | 7 MB | 0.69 | | 10^9 | 5 | 0.36 s | 0.18 s | 25 MB | 0.93 | | 10^10 | 5 | 1.6 s | 0.53 s | 134 MB | 1.68 | | 10^11 | 5 | 6.1 s | 3.4 s | 495 MB | 1.21 | | 10^12 | 5 | 13.6 s | 5.6 s | 983 MB | 0.93 | | 10^13 | 4 | 184 s (k≈8·10^13) | 47 s | 2.3 GB | 1.35 | | 10^14 (`results/spread_14.csv`) | 4 | 187 s | 170 s | 3.8 GB | 0.97 | Other exercised paths: `--h1 -1` (forces the "no affordable candidate" reset, 3 passes) and `KGRID_Z_FACTOR=3` (forces re-enumeration of the trees) both reproduce the oracle on 1..20000. ## Reliability envelope * Up to about 10^13 a query takes under a minute (worst seen 28 s), up to 10^14 about 3 minutes (≤ 3.8 GB), 10^15 4.5 minutes (2 GB), and 10^16 80 minutes (11.8 GB peak; the polygon there used the divide-and-conquer reconstruction). Two passes of ~2·10^11 table updates dominate at 10^16. Without `--no-poly`, choice tables above `--mem-limit` (default 4 GB) switch to the divide-and-conquer reconstruction. * Precision: the optimal choice is decided on fixed-point savings (resolution ~1e-12 absolute, independent of k), but the reported perimeter is an f64 (about 1e-16 relative, i.e. ~1e-8 absolute at 10^15). The vertex-perimeter check tolerance is 1e-9 relative (~0.1 absolute at 10^15). The lattice count check is exact. * Hard limits: k < 9.2·10^18 (i64); table indices are usize; the real limit is time (~m^{6/5} growth with a large constant) and RAM for the table (8 bytes per budget, ~16·m·(window width) entries). ## Group-update comparison (`results/rowmax_compare.csv`) Single-query table timings (seconds, perimeter only) comparing SMAWK, divide-and-conquer row maxima (`dc`), and direct sweeps (`plain`): | $k$ | SMAWK updates | direct ops | direct | D&C | SMAWK | |---|---|---|---|---|---| | $10^{8}$ | $1.1\cdot 10^{6}$ | $2.3\cdot 10^{7}$ | 0.021 s | 0.007 s | 0.008 s | | $10^{9}$ | $5.2\cdot 10^{6}$ | $1.2\cdot 10^{8}$ | 0.103 s | 0.031 s | 0.030 s | | $10^{10}$ | $2.3\cdot 10^{7}$ | $6.1\cdot 10^{8}$ | 0.513 s | 0.129 s | 0.127 s | | $10^{11}$ | $1.9\cdot 10^{8}$ | $5.6\cdot 10^{9}$ | 4.331 s | 1.119 s | 1.090 s | | $10^{12}$ | $4.2\cdot 10^{8}$ | $1.5\cdot 10^{10}$ | 12.068 s | 2.479 s | 2.384 s | | $10^{13}$ | $1.8\cdot 10^{9}$ | $7.3\cdot 10^{10}$ | 59.381 s | 11.272 s | 10.685 s | ## Notes * The certified windows derive exact bounds for every $k$ from the duality-gap identities and exchange arguments, replacing unspecified asymptotic constants. * Cross-radius table sharing (for $O(X)$ theoretical all-counts amortization) is not implemented; batch mode builds one table per radius ($O(X^{11/10})$ asymptotically).