Back to Independent Builds

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⁻¹²
Interactive 3D TopoResearch lab showing an evolved uniaxial I-beam topology and P95-normalized P1 strain-energy field
0.5 mm FEM replay.Switch scenarios, toggle Cutaway, or drag to orbit.
Reproduce locally (CPU only)
toporesearch demo --out runs/demo
toporesearch compare --research-run runs/demo --suite heldout --mode both --budget 5 --max-proposals 25 --out runs/compare

TopoResearch · Closed-Loop Architecture

How autonomous discovery works

Outer loop · Agent edits solverSandbox · Geometry checkInner loop · Locked FEAOuter loop · Keep or rollbackLocal · numpy + scipyOUTER LOOP · DISCOVERYINNER LOOP · LOCKED PHYSICS01 · MUTABLE STRATEGYdesign.py · propose_design()Reads load_axes, bc_type & energy02 · SANDBOX + GATEworker.py + problems.pyPads, 4/6-face connectivity, volume03 · 0.5 MM P1 FEMfem.py · checksum-lockedCompliance C + cell strain energy04 · KEEP / ROLLBACKengine.py · Δ < -1e-9Accepts winners, reverts regressionsINDEPENDENT AUDIT LAYERscikit-fem P1 (err ≤ 4.45e-12) · Q1 cross-check · 3,000-call Ablation · Controls
  1. 01 · Proposedesign.py — rewrites propose_design() using load_axes & prior energy.
  2. 02 · Gateproblems.py — checks pads, connectivity & volume cap before FEM calls.
  3. 03 · Solvefem.py — checksum-locked 0.5 mm P1 FEM computes compliance & cell energy.
  4. 04 · Ratchetengine.py — keeps edits only when suite score strictly drops; reverts regressions.
  5. Independent Auditscikit-fem P1 (≤ 4.45e-12) · Q1 ranking cross-check · 3,000-call ablation
Closed-loop algorithm ratchetZero neural training · deterministic CPU physics
Coding agent + program.md

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)

Isolated worker + problems.py

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)

Protected 0.5 mm P1 FEM (fem.py)

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

Ratchet controller (engine.py)

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

  1. 01Locks geometry checks and a 0.5 mm P1 FEM solver behind SHA-256 checksum verification while allowing edits only to design.py
  2. 02Keep-or-rollback ratchet accepts revisions only when 100% feasible and compliance drops (Δ < -1e-9)
  3. 03Conditioned on load_axes and bc_type so strategies adapt between uniaxial I-beams, biaxial box-beams, and bridges
  4. 04Cross-verified against independent scikit-fem P1/Q1 solvers and 82 passing tests with optional fail-closed Docker isolation

How it works

  1. 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.

  2. 02Gate geometry

    An isolated worker enforces intact support/load pads, single face-connected topology, and the volume cap before any FEM call runs.

  3. 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.

  4. 04Ratchet edits

    Revisions survive only when every dev episode stays feasible and normalized compliance drops strictly (Δ < -1e-9); regressions revert at once.

Build notes

Note 01

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.
Note 02

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.
Note 03

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).
Note 04

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.

Cross-solver verification4.45 × 10⁻¹²Max P1 compliance error
Baseline
Internal fem.py vs. scikit-fem 12.0.2 P1
Evaluation
3,000 ablation solves & 27 held-out masks
Phase 6 ratchet1.913 → 1.5790.5 mm dev score (-17.4%)
Baseline
Random search + 480-solve random control (1.798)
Variant
Phase 6 load-aware prior + BESO (5 rounds)
Phase 9 ablation-41.8%Holed cantilever gain
Baseline
Call 1 analytic prior alone
Variant
Call 100 strain-energy BESO feedback
Phase 9 outer-loop controls+7.18% / 15.6×Peak gain vs. wall time
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.
Next project08AgentSCADPersonal / AI Agents / Parametric CAD

Project image

Interactive demo