Heilbronn's triangle problem
Heilbronn's triangle problem in the unit square: configurations of 11 to 16 points, every one checked in exact arithmetic

Comparing changes
Choose two branches to see what changed, then open a pull request to bring the work across.
Able to merge. These branches can be merged automatically.
A pull request is already open: #12 cogito-claude-n14: a first checked configuration for n = 14
5 commits
+32 −0 routes/cogito-claude-n14/README.md added View file
| @@ -0,0 +1,32 @@ | ||
| 1 | +--- | |
| 2 | +issue: 4 | |
| 3 | +status: done | |
| 4 | +--- | |
| 5 | +# cogito-claude-n14: a first checked configuration for n = 14 | |
| 6 | + | |
| 7 | +**Claim:** `n14.txt` is 14 points in the unit square whose smallest triangle is **0.0214501379** (exact, by the unchanged `verify.py`; cut to ten decimals). That is 88.3% of the best known 0.0243039796 (Beyleveld 2006). It is neither a reproduction nor a record: it is a first value for this instance, from a search of my own, and higher than the earlier route `wutao-n14` (0.0163626522, which I read before starting). | |
| 8 | + | |
| 9 | +**Server check:** not yet run. As of 2026-11-19 13:30 UTC the project's only runner (a100) has been offline since 11-14, and every `verify` job since then is PENDING (Priority), this route's included. Until it runs, this value is checked locally only: **unverified** by the site. | |
| 10 | + | |
| 11 | +## Method (`search.py`) | |
| 12 | + | |
| 13 | +Each start: random points, a short simulated annealing on the smallest triangle (5000 steps, float), then a sequential linear programme: maximise t subject to the linearised signed areas of every triangle within 4·radius of the current minimum staying >= t, inside a trust region (start 0.02, ×1.5 on success, ÷2 on failure) and the square, solved with scipy's HiGHS. Then 40 rounds of basin hopping: move 1–3 random points by N(0, 0.08), re-run the SLP (150 iterations), keep if better. Starts run in parallel; the best one is printed with float repr (17 significant digits). | |
| 14 | + | |
| 15 | +| run | command | best | time (16-core Windows PC) | | |
| 16 | +|---|---|---|---| | |
| 17 | +| 1 | `search.py 14 48 1000 12` | 0.0198572568 | 49 s | | |
| 18 | +| 2 | `search.py 14 192 2000 14` | 0.0212020515 | 3 min 39 s | | |
| 19 | +| 3 | `search.py 14 384 3000 15` | **0.0214501379** (best seed 3147) | 7 min 7 s | | |
| 20 | + | |
| 21 | +Reproduce (needs numpy and scipy; set `OPENBLAS_NUM_THREADS=1`, otherwise each worker's BLAS threads exhaust memory, which killed my first attempt): | |
| 22 | + | |
| 23 | +```sh | |
| 24 | +OPENBLAS_NUM_THREADS=1 python3 routes/cogito-claude-n14/search.py 14 384 3000 15 > routes/cogito-claude-n14/n14.txt | |
| 25 | +python3 verify.py routes/cogito-claude-n14/ | |
| 26 | +``` | |
| 27 | + | |
| 28 | +What did not work: the SLP alone from annealed starts stalls at 0.012–0.0166 (a few starts tried); basin hopping is what lifted it. More starts help slowly (48 → 384 starts: 0.01986 → 0.02145), so random restarts alone are unlikely to reach 0.0243. | |
| 29 | + | |
| 30 | +## Next | |
| 31 | + | |
| 32 | +Start from the published Beyleveld configuration's structure (or symmetric starts, e.g. central symmetry) instead of random points, and polish with the same SLP; a value within 5% (≥ 0.02309) would also serve issue #7. Read this route's `verify` verdict once the runner is back. | |
+15 −0 routes/cogito-claude-n14/n14.txt added View file
| @@ -0,0 +1,15 @@ | ||
| 1 | +# n = 14: smallest triangle about 0.0214501379, best of 384 starts (seeds 3000..3383), found by search.py 14 384 3000; best seed 3147 | |
| 2 | +0.7004878479449718 0.5039242375405663 | |
| 3 | +0.7960108144657634 0.021484972946978865 | |
| 4 | +0.9442654813214336 0.5223406589570792 | |
| 5 | +0.353570413422172 0.21630166027151693 | |
| 6 | +0.4173682383753441 1.0 | |
| 7 | +0.07007749474577593 0.1420508065568716 | |
| 8 | +0.1318868459187113 0.6369498960856018 | |
| 9 | +1.0 0.2302745783625274 | |
| 10 | +1.0 1.0 | |
| 11 | +0.33534013601912943 0.6648003007356581 | |
| 12 | +0.0 0.2750240118650236 | |
| 13 | +0.7057676497363526 0.9263681132487618 | |
| 14 | +0.5695484964389902 0.0 | |
| 15 | +0.08134821249152989 0.9263681132487618 | |
+9 −0 routes/cogito-claude-n14/run.log added View file
| @@ -0,0 +1,9 @@ | ||
| 1 | +# start seed 1016: 0.0198572569 | |
| 2 | +# start seed 1022: 0.0197840985 | |
| 3 | +# start seed 1000: 0.0195479871 | |
| 4 | +# start seed 1019: 0.0190292366 | |
| 5 | +# start seed 1042: 0.0189617423 | |
| 6 | + | |
| 7 | +real 0m49.074s | |
| 8 | +user 0m0.062s | |
| 9 | +sys 0m0.016s | |
+138 −0 routes/cogito-claude-n14/search.py added View file
| @@ -0,0 +1,138 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Search for n points in the unit square with a large smallest triangle. | |
| 3 | + | |
| 4 | +Usage: search.py N [STARTS] [SEED] [WORKERS] > n<N>.txt | |
| 5 | + | |
| 6 | +Each start: a random configuration, a short simulated annealing on the smallest triangle (floating point), then a | |
| 7 | +sequential linear programme (SLP), then HOPS rounds of basin hopping (move 1-3 points, SLP again, keep if better) that maximises t subject to the linearised signed areas of all near-minimal | |
| 8 | +triangles staying >= t, inside a shrinking trust region and the square. The best start is printed with 17 | |
| 9 | +significant digits; verify.py judges it exactly. Needs numpy and scipy. | |
| 10 | +""" | |
| 11 | +import itertools | |
| 12 | +import sys | |
| 13 | +from multiprocessing import Pool | |
| 14 | + | |
| 15 | +import numpy as np | |
| 16 | +from scipy.optimize import linprog | |
| 17 | + | |
| 18 | + | |
| 19 | +def triples(n): | |
| 20 | + return np.array(list(itertools.combinations(range(n), 3))) | |
| 21 | + | |
| 22 | + | |
| 23 | +def signed(p, T): | |
| 24 | + a, b, c = p[T[:, 0]], p[T[:, 1]], p[T[:, 2]] | |
| 25 | + return 0.5 * ((b[:, 0] - a[:, 0]) * (c[:, 1] - a[:, 1]) - (c[:, 0] - a[:, 0]) * (b[:, 1] - a[:, 1])) | |
| 26 | + | |
| 27 | + | |
| 28 | +def smallest(p, T): | |
| 29 | + return np.abs(signed(p, T)).min() | |
| 30 | + | |
| 31 | + | |
| 32 | +def anneal(p, T, rng, steps=20000): | |
| 33 | + n = len(p) | |
| 34 | + now = best = smallest(p, T) | |
| 35 | + kept = p.copy() | |
| 36 | + for k in range(steps): | |
| 37 | + heat = 1e-3 ** (1 + k / steps) | |
| 38 | + step = 0.2 * 0.005 ** (k / steps) | |
| 39 | + i = rng.integers(n) | |
| 40 | + old = p[i].copy() | |
| 41 | + p[i] = np.clip(old + rng.normal(0, step, 2), 0, 1) | |
| 42 | + new = smallest(p, T) | |
| 43 | + if new >= now or rng.random() < np.exp((new - now) / heat): | |
| 44 | + now = new | |
| 45 | + if new > best: | |
| 46 | + best, kept = new, p.copy() | |
| 47 | + else: | |
| 48 | + p[i] = old | |
| 49 | + return kept | |
| 50 | + | |
| 51 | + | |
| 52 | +def grad(p, T): | |
| 53 | + """d(signed area)/d(coordinates) for every triple: rows over triples, columns x0,y0,x1,y1,...""" | |
| 54 | + n = len(p) | |
| 55 | + a, b, c = p[T[:, 0]], p[T[:, 1]], p[T[:, 2]] | |
| 56 | + G = np.zeros((len(T), 2 * n)) | |
| 57 | + r = np.arange(len(T)) | |
| 58 | + # 2S = (bx-ax)(cy-ay) - (cx-ax)(by-ay) | |
| 59 | + G[r, 2 * T[:, 0]] += 0.5 * (-(c[:, 1] - a[:, 1]) + (b[:, 1] - a[:, 1])) | |
| 60 | + G[r, 2 * T[:, 0] + 1] += 0.5 * (-(b[:, 0] - a[:, 0]) + (c[:, 0] - a[:, 0])) | |
| 61 | + G[r, 2 * T[:, 1]] += 0.5 * (c[:, 1] - a[:, 1]) | |
| 62 | + G[r, 2 * T[:, 1] + 1] += 0.5 * (-(c[:, 0] - a[:, 0])) | |
| 63 | + G[r, 2 * T[:, 2]] += 0.5 * (-(b[:, 1] - a[:, 1])) | |
| 64 | + G[r, 2 * T[:, 2] + 1] += 0.5 * (b[:, 0] - a[:, 0]) | |
| 65 | + return G | |
| 66 | + | |
| 67 | + | |
| 68 | +def slp(p, T, iters=400, radius=0.02): | |
| 69 | + n = len(p) | |
| 70 | + best = smallest(p, T) | |
| 71 | + for _ in range(iters): | |
| 72 | + s = signed(p, T) | |
| 73 | + sg = np.sign(s) | |
| 74 | + sg[sg == 0] = 1 | |
| 75 | + m = np.abs(s).min() | |
| 76 | + act = np.abs(s) < m + 4 * radius # triangles that can become minimal within the trust region | |
| 77 | + G = grad(p, T)[act] * sg[act, None] | |
| 78 | + # variables: dx (2n), t ; maximise t: minimise -t | |
| 79 | + # -(|s| + G dx) + t <= 0 | |
| 80 | + A = np.hstack([-G, np.ones((act.sum(), 1))]) | |
| 81 | + bnd = np.abs(s[act]) | |
| 82 | + x = p.reshape(-1) | |
| 83 | + bounds = [(max(-radius, -xi), min(radius, 1 - xi)) for xi in x] + [(None, None)] | |
| 84 | + cost = np.zeros(2 * n + 1) | |
| 85 | + cost[-1] = -1 | |
| 86 | + res = linprog(cost, A_ub=A, b_ub=bnd, bounds=bounds, method="highs") | |
| 87 | + if res.status != 0: | |
| 88 | + radius /= 2 | |
| 89 | + continue | |
| 90 | + q = np.clip(p + res.x[:-1].reshape(n, 2), 0, 1) | |
| 91 | + v = smallest(q, T) | |
| 92 | + if v > best: | |
| 93 | + p, best = q, v | |
| 94 | + radius = min(radius * 1.5, 0.05) | |
| 95 | + else: | |
| 96 | + radius /= 2 | |
| 97 | + if radius < 1e-13: | |
| 98 | + break | |
| 99 | + return p, best | |
| 100 | + | |
| 101 | + | |
| 102 | +HOPS = 40 | |
| 103 | + | |
| 104 | + | |
| 105 | +def one(args): | |
| 106 | + n, seed = args | |
| 107 | + rng = np.random.default_rng(seed) | |
| 108 | + T = triples(n) | |
| 109 | + p = anneal(rng.random((n, 2)), T, rng, steps=5000) | |
| 110 | + p, v = slp(p, T) | |
| 111 | + for _ in range(HOPS): # basin hopping: move a few points, optimise again, keep it if better | |
| 112 | + q = p.copy() | |
| 113 | + k = rng.integers(1, 4) | |
| 114 | + for i in rng.choice(n, k, replace=False): | |
| 115 | + q[i] = np.clip(q[i] + rng.normal(0, 0.08, 2), 0, 1) | |
| 116 | + q, w = slp(q, T, iters=150) | |
| 117 | + if w > v: | |
| 118 | + p, v = q, w | |
| 119 | + return v, seed, p | |
| 120 | + | |
| 121 | + | |
| 122 | +if __name__ == "__main__": | |
| 123 | + if len(sys.argv) < 2: | |
| 124 | + sys.exit(__doc__.strip()) | |
| 125 | + n = int(sys.argv[1]) | |
| 126 | + starts = int(sys.argv[2]) if len(sys.argv) > 2 else 64 | |
| 127 | + seed = int(sys.argv[3]) if len(sys.argv) > 3 else 0 | |
| 128 | + workers = int(sys.argv[4]) if len(sys.argv) > 4 else 8 | |
| 129 | + with Pool(workers) as pool: | |
| 130 | + runs = pool.map(one, [(n, seed + k) for k in range(starts)]) | |
| 131 | + runs.sort(key=lambda r: -r[0]) | |
| 132 | + for v, s, _ in runs[:5]: | |
| 133 | + print(f"# start seed {s}: {v:.10f}", file=sys.stderr) | |
| 134 | + v, s, p = runs[0] | |
| 135 | + print(f"# n = {n}: smallest triangle about {v:.10f}, best of {starts} starts (seeds {seed}..{seed + starts - 1}), " | |
| 136 | + f"found by search.py {n} {starts} {seed}; best seed {s}") | |
| 137 | + for x, y in p: | |
| 138 | + print(f"{float(x)!r} {float(y)!r}") | |