07
TopoResearch
Personal / Scientific AI / Structural Optimization
An AI agent that writes and tests its own structural optimization algorithms against real CPU finite-element physics.
- Normalized suite score in 5 rounds
- -17.4%
- Max relative error vs. scikit-fem P1
- 4.45 × 10⁻¹²

toporesearch demo --out runs/demo
toporesearch compare --research-run runs/demo --suite heldout --mode both --budget 5 --max-proposals 25 --out runs/compareTopoResearch · Closed-Loop Architecture
How autonomous discovery works
- 01 · Propose
design.py— rewritespropose_design()using load_axes & prior energy. - 02 · Gate
problems.py— checks pads, connectivity & volume cap before FEM calls. - 03 · Solve
fem.py— checksum-locked 0.5 mm P1 FEM computes compliance & cell energy. - 04 · Ratchet
engine.py— keeps edits only when suite score strictly drops; reverts regressions. - Independent Auditscikit-fem P1 (≤ 4.45e-12) · Q1 ranking cross-check · 3,000-call ablation
Rewrite the algorithm
Instead of generating one shape, the agent edits design.py to write reusable structural rules from domain, pads, and load axes.
- Only file edited: design.py
- Reads load_axes, bc_type & best['energy']
- Proposes binary voxel masks per step
design.py → propose_design(request)
Enforce physical validity
Every proposed mask runs inside a sandboxed worker and passes strict support, pad, connectivity, and volume checks before solving.
- Support & load pads 100% preserved
- Single 4/6-face connected solid
- Total mass <= target volume fraction
Invalid mask → rejected (0 FEM solves)
Measure real structural stiffness
A checksum-protected 0.5 mm solver computes linear-elastic compliance and per-voxel strain energy.
- Checksum-verified read-only physics
- 0.5 mm refinement fixes coarse-mesh tricks
- Matches scikit-fem P1 within 4.45e-12
Feasible mask → scalar C + strain energy
Keep only proven gains
A code edit survives only if 100% of dev tasks pass and normalized compliance strictly drops. Any regression rolls back automatically.
- Strict keep rule: Δ < -1e-9
- Auto-rollback on worse edits (e.g. exp_004)
- Archives accepted.py & checksum manifest
Strict drop → new baseline; else rollback
- Coarse-mesh overfitting?
1.0 mm grids let agents exploit shear locking and lose on blind tests; 0.5 mm refinement restores true rankings.
- Where AI priors fail?
Cantilever priors regressed +23.0% on unseen bridges, and Codex search cost ~15.6× wall time over evolution.
In brief
Inspired by autonomous research loops, TopoResearch locks the physics evaluator and lets an AI coding agent iteratively rewrite the optimization algorithm under fixed CPU finite-element budgets—keeping changes only when stiffness strictly improves.
Pure NumPy + SciPy on a standard processor (CPU), zero neural training, and checksum-verified against independent scikit-fem solvers.
Most AI-for-engineering demos ask a model to output one final 3D part. TopoResearch flips the question: can an autonomous coding agent iteratively discover better general-purpose structural optimization algorithms when tested against real finite-element physics?
Instead of training neural networks or hiding behind coarse surrogates, every edit is evaluated by a pure-CPU linear-elastic P1 solver under fixed solve budgets—measuring where autonomous discovery genuinely works, where priors overfit, and how compute costs compare with classical search.
Autonomous code search is easy to fool: on coarse 1.0 mm grids, agents learn to exploit shear locking and diagonal artifacts that invert rankings on fine meshes. Without strict physical gates, explicit load-axis inputs, and matched classical search controls, it is impossible to tell true algorithmic insight from overfitting.
What it includes
- 01Locks geometry checks and a 0.5 mm P1 FEM solver behind SHA-256 checksum verification while allowing edits only to design.py
- 02Keep-or-rollback ratchet accepts revisions only when 100% feasible and compliance drops (Δ < -1e-9)
- 03Conditioned on load_axes and bc_type so strategies adapt between uniaxial I-beams, biaxial box-beams, and bridges
- 04Cross-verified against independent scikit-fem P1/Q1 solvers and 82 passing tests with optional fail-closed Docker isolation
How it works
- 01Edit design.py
The coding agent or search loop modifies only propose_design(request), mapping domain, pads, load_axes, and prior energy fields into a candidate layout.
- 02Gate geometry
An isolated worker enforces intact support/load pads, single face-connected topology, and the volume cap before any FEM call runs.
- 03Solve 0.5 mm FEA
A checksum-locked P1 finite-element solver computes linear-elastic compliance and per-voxel strain energy on a 0.5 mm refined mesh.
- 04Ratchet edits
Revisions survive only when every dev episode stays feasible and normalized compliance drops strictly (Δ < -1e-9); regressions revert at once.
Build notes
Fix coarse-mesh overfitting with 0.5 mm refinement
evaluator fidelity- Context
- On 1.0 mm coarse grids, autonomous edits gained 8.1%–10.4% on dev benchmarks while performing worse than initial random heuristics on fine-mesh blind tests.
- Approach
- Subdivide each design voxel into 2^d sub-elements (--refinement 2, 0.5 mm) inside fem.py and cross-verify against independent scikit-fem P1 and Q1 solvers.
- What it enables
- Eliminated ranking inversion across runs and verified internal P1 compliance to within 4.45e-12 relative error against scikit-fem.
Expose load_axes so geometry adapts by loading
physical priors- Context
- Without load direction metadata, strategies optimized for biaxial bending formed hollow box beams that regressed +33.3% on uniaxial bending.
- Approach
- Pass explicit load_axes and bc_type in the read-only problem payload alongside per-voxel strain energy feedback.
- What it enables
- In 5 rounds (174 FEM calls), the model-agnostic exchange agent discovered a deterministic I-beam / box-beam prior + BESO solver beating SIMP-100.
Separate prior initialization from strain-energy feedback
causal ablation- Context
- Headline benchmark gains alone do not tell you whether the agent improved initialization or iterative gradient-free search.
- Approach
- Run a 3,000-call component ablation across 6 variants and 5 geometries, auditing duplicate mask saturation and staleness counters.
- What it enables
- Proved analytic priors capture ~98% of regular cantilever gains at Call 1, while L-brackets and holed domains require BESO feedback (-41.8% by Call 100).
Measure boundary transfer and compute cost honestly
scientific honesty- Context
- Agents tuned only on cantilevers can bake in boundary assumptions that fail on unseen bridge domains.
- Approach
- Test cantilever priors on unseen bridges and run matched 144-call comparisons against evolution and random genome search.
- What it enables
- Exposed a +23.0% bridge regression; peak Codex gains (+7.18% dev) cost ~15.6x wall time (623 s vs 40 s).
Results
These results come from separate experiments and model configurations. They should be interpreted individually, not as the performance of one combined final model.
- Baseline
- Internal fem.py vs. scikit-fem 12.0.2 P1
- Evaluation
- 3,000 ablation solves & 27 held-out masks
- Baseline
- Random search + 480-solve random control (1.798)
- Variant
- Phase 6 load-aware prior + BESO (5 rounds)
- Baseline
- Call 1 analytic prior alone
- Variant
- Call 100 strain-energy BESO feedback
- Baseline
- Evolutionary genome search (39.9 s mean, 0 tokens)
- Variant
- Codex coding agent (623.4 s mean, 145k–199k tokens)
Note: Phase 9 outer-loop controls include 2 independent trajectories per family on small linear-elastic voxel benchmarks (< 500 cells) and report peak gains alongside single-run variance rather than claiming universal coding-agent superiority.
Compatibility
- Exploratory benchmark for small static linear-elastic voxel domains (< 500 cells); does not certify structural safety, yielding, buckling, fatigue, or manufacturability.
- High-budget runs (>24 FEM calls) can saturate due to staleness decay producing 42–67 duplicate proposals per 100 calls on regular domains.
- Default process sandbox isolates accidental interference on trusted machines; untrusted model-generated code requires explicit --sandbox docker isolation.