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

n = 16: 0.0191939724 from a C4-symmetric search
Browse files+50 −0 routes/cogito-claude-n16/hop.py added View file
| @@ -0,0 +1,50 @@ | ||
| 1 | +#!/usr/bin/env python3 | |
| 2 | +"""Basin hopping without symmetry from a given configuration. | |
| 3 | + | |
| 4 | +Usage: hop.py FILE ROUNDS SEED WORKERS > out.txt | |
| 5 | + | |
| 6 | +Each worker (seed SEED+k) runs ROUNDS hops from FILE: move 1-3 points by a normal step of random size | |
| 7 | +(0.01-0.1), run search.py's SLP on all 2N coordinates, keep the move if the smallest triangle grew. | |
| 8 | +Prints the best configuration with 17 significant digits. Needs numpy, scipy and search.py beside it. | |
| 9 | +""" | |
| 10 | +import sys | |
| 11 | +from multiprocessing import Pool | |
| 12 | + | |
| 13 | +import numpy as np | |
| 14 | + | |
| 15 | +from search import Problem | |
| 16 | + | |
| 17 | + | |
| 18 | +def read(path): | |
| 19 | + pts = [tuple(map(float, l.split())) for l in open(path) if l.strip() and not l.startswith("#")] | |
| 20 | + return np.array(pts) | |
| 21 | + | |
| 22 | + | |
| 23 | +def run(args): | |
| 24 | + path, rounds, seed = args | |
| 25 | + rng = np.random.default_rng(seed) | |
| 26 | + p = read(path) | |
| 27 | + P = Problem(len(p), "none") | |
| 28 | + z, v = P.slp(p.reshape(-1).copy(), iters=200, radius=1e-3) | |
| 29 | + for _ in range(rounds): | |
| 30 | + q = z.copy() | |
| 31 | + s = 10 ** rng.uniform(-2, -1) | |
| 32 | + for i in rng.choice(P.n, rng.integers(1, 4), replace=False): | |
| 33 | + q[2 * i:2 * i + 2] = np.clip(q[2 * i:2 * i + 2] + rng.normal(0, s, 2), 0, 1) | |
| 34 | + q, w = P.slp(q, iters=150) | |
| 35 | + if w > v: | |
| 36 | + z, v = q, w | |
| 37 | + return v, seed, P.full(z) | |
| 38 | + | |
| 39 | + | |
| 40 | +if __name__ == "__main__": | |
| 41 | + path, rounds, seed, workers = sys.argv[1], int(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4]) | |
| 42 | + with Pool(workers) as pool: | |
| 43 | + runs = pool.map(run, [(path, rounds, seed + k) for k in range(workers)]) | |
| 44 | + runs.sort(key=lambda r: -r[0]) | |
| 45 | + for v, s, _ in runs: | |
| 46 | + print(f"# hop seed {s}: {v:.10f}", file=sys.stderr) | |
| 47 | + v, s, p = runs[0] | |
| 48 | + print(f"# n = {len(p)}: smallest triangle about {v:.10f}, by hop.py {path} {rounds} {seed} {workers}; best seed {s}") | |
| 49 | + for x, y in p: | |
| 50 | + print(f"{float(x)!r} {float(y)!r}") | |
+17 −17 routes/cogito-claude-n16/n16.txt View file
| @@ -1,17 +1,17 @@ | ||
| 1 | -# n = 16: smallest triangle about 0.0190899648, best of 4 starts under symmetry c4 (seeds 0..3), found by search.py 16 c4 4 0 4 5; best seed 1 | |
| 2 | -0.2557127965954414 1.0 | |
| 3 | -0.0 0.938092417237879 | |
| 4 | -0.30456116491467533 0.34146673138657063 | |
| 5 | -0.9380924172378788 0.38327539300124347 | |
| 6 | -0.0 0.2557127965954414 | |
| 7 | -0.06190758276212105 0.0 | |
| 8 | -0.6585332686134293 0.30456116491467533 | |
| 9 | -0.6167246069987565 0.9380924172378788 | |
| 10 | -0.7442872034045587 0.0 | |
| 11 | -1.0 0.06190758276212105 | |
| 12 | -0.6954388350853247 0.6585332686134293 | |
| 13 | -0.06190758276212116 0.6167246069987565 | |
| 14 | -1.0 0.7442872034045587 | |
| 15 | -0.938092417237879 1.0 | |
| 16 | -0.34146673138657063 0.6954388350853247 | |
| 17 | -0.38327539300124347 0.06190758276212116 | |
| 1 | +# n = 16: smallest triangle about 0.0191939724, best of 300 starts under symmetry c4 (seeds 1000..1299), found by search.py 16 c4 300 1000 15 40; best seed 1133 | |
| 2 | +0.39699433520835103 0.9363389981249824 | |
| 3 | +0.0 0.06366100187501753 | |
| 4 | +0.6666666666666669 1.0 | |
| 5 | +0.6666666666666666 0.3969943352083508 | |
| 6 | +0.06366100187501755 0.39699433520835103 | |
| 7 | +0.9363389981249824 0.0 | |
| 8 | +0.0 0.6666666666666669 | |
| 9 | +0.6030056647916492 0.6666666666666666 | |
| 10 | +0.603005664791649 0.06366100187501755 | |
| 11 | +1.0 0.9363389981249824 | |
| 12 | +0.33333333333333315 0.0 | |
| 13 | +0.33333333333333337 0.6030056647916492 | |
| 14 | +0.9363389981249824 0.603005664791649 | |
| 15 | +0.06366100187501753 1.0 | |
| 16 | +1.0 0.33333333333333315 | |
| 17 | +0.3969943352083508 0.33333333333333337 | |