Skip to content

Scaffold Bayesian-optimization script with honegumi + customized tensegrity campaign#30

Open
sgbaird-alt with Copilot wants to merge 10 commits into
mainfrom
copilot/scaffold-bayesian-optimization-script
Open

Scaffold Bayesian-optimization script with honegumi + customized tensegrity campaign#30
sgbaird-alt with Copilot wants to merge 10 commits into
mainfrom
copilot/scaffold-bayesian-optimization-script

Conversation

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

Repo had no BO code yet. Added a honegumi-driven scaffold for the multi-material tensegrity energy-absorption campaign so we have a runnable Ax/BoTorch starting point to iterate on, plus a hand-customized companion script that wires up the real design variables and objectives drawn from proposal.tex, idetc-abstract.tex, nasa-space-grant/proposal.tex, and PR #24.

bo/ layout

  • generate_scaffold.py — wraps honegumi.core._honegumi.Honegumi, declares CONFIG, renders tensegrity_bo.py. --smoke-test overrides honegumi's dummy flag for a 5-iter variant (honegumi's public generate() always forces dummy=False).

  • tensegrity_bo.py — generated, black-formatted Ax loop; Branin placeholder objective is intentionally left for replacement per the customization checklist.

  • tensegrity_campaign.py — hand-customized Ax MOO campaign companion to the regenerable scaffold. Flat top-to-bottom script (no main(), no __main__ guard, no CLI) — tune the N_ITERATIONS / BATCH_SIZE / SEED module-level constants in place. Design space now tracks the PETG-strut + TPU-skin recommendations from PR Explore TPU+PLA BO design variables and base structures (Edison literature result + PR #22 design-gaps synthesis, hierarchical search space) #24's Edison literature scoping:

    • Continuous: strut diameter [1.5, 5.0] mm, strut length [15, 50] mm, TPU cable diameter [1.0, 3.0] mm, twist angle [10°, 45°], prestress [0%, 5%], PETG infill [40%, 100%], interface wrap thickness [0.4, 2.0] mm.
    • Integer (ordered choice): struts per unit cell ∈ {3, 4, 6, 8, 12}.
    • Categorical: connectivity topology ∈ {truncated_octahedron, simplex_4_strut, t3_prism, stacked_prism} (the four "defensible seed families" from PR Explore TPU+PLA BO design variables and base structures (Edison literature result + PR #22 design-gaps synthesis, hierarchical search space) #24), tiling ∈ {1×1×1, 1×1×2, 2×2×1, 2×2×2, 3×3×2}, TPU shore ∈ {85A, 95A}, PETG infill pattern ∈ {rectilinear, grid, gyroid}, build orientation ∈ {vertical, horizontal, 45°}.
    • Objectives (MOO / qNEHVI): minimize F_peak_N, maximize SEA_J_per_g, maximize eta.

    Exploration is handled by Ax's default GenerationStrategy (Sobol quasi-random init → model-based MOO acquisition), so no hand-curated pilot designs are baked into the script. Ships a documented analytical simulate_specimen dummy evaluator (PETG mass model, topology stiffness, tiling factor, shore-softness cushion, infill strength scaling, infill-pattern stiffness, twist-angle sweet-spot bonus near 30°, build-orientation force multiplier, heteroscedastic noise) so the BO loop runs end-to-end without experimental data.

  • requirements.txthonegumi==0.4.3, ax-platform==0.4.3, numpy<2, pandas<2.3, matplotlib, black>=24.0. The numpy<2 / pandas<2.3 pins are required: ax 0.4.3 calls np.percentile(..., interpolation=...) (gone in numpy 2) and writes to DataFrame-backed arrays that pandas 3 returns read-only. black is pinned explicitly because generate_scaffold.py imports it to format the rendered scaffold.

  • README.md — config table mapped to honegumi's curriculum tutorials, regen/run instructions, a "Customized campaign" section documenting the PR Explore TPU+PLA BO design variables and base structures (Edison literature result + PR #22 design-gaps synthesis, hierarchical search space) #24-aligned variables/objectives in tensegrity_campaign.py, and a checklist for swapping the dummy evaluator for the experimental data layer.

  • tests/ — pytest smoke tests covering the honegumi engine build, rendered-script structure, and full-vs-smoke iteration count of the scaffold generator. (The previous campaign-script smoke tests were removed once tensegrity_campaign.py became a flat top-level script — importing it would otherwise trigger the BO loop during test collection.)

CONFIG

Multi objective · Default model · Single task · categorical=True · custom_threshold=True · existing_data=True · synchrony=Batch · visualize=True. Constraints (sum/order/linear/composition) off; flip in CONFIG and re-run the generator.

pip install -r bo/requirements.txt
python bo/generate_scaffold.py                       # (re)render bo/tensegrity_bo.py
python bo/generate_scaffold.py --smoke-test -o /tmp/smoke.py
MPLBACKEND=Agg python /tmp/smoke.py                  # fast end-to-end check
MPLBACKEND=Agg python bo/tensegrity_campaign.py      # customized campaign (edit N_ITERATIONS in-place for longer runs)

Repo plumbing

  • Top-level README.md gains a BO section + structure entry.
  • .gitignore ignores __pycache__/, *.py[cod], .pytest_cache/, *.egg-info/, and the generated bo/campaign_pareto.png.
  • bo/__init__.py + bo/tests/__init__.py make bo a real package so tests don't manipulate sys.path.

Verification

  • MPLBACKEND=Agg python bo/tensegrity_campaign.py → 10 BO-selected trials (Sobol-initialized), 4 Pareto-optimal designs, Pareto-front PNG written.
  • pytest bo/tests → generator scaffold smoke tests (3 tests; 2 pre-existing black.report.NothingChanged failures are unrelated to the PETG variable update).

Notes for review

  • Regeneration of tensegrity_bo.py is byte-stable; commit it alongside any CONFIG change rather than editing the generated file by hand. tensegrity_bo.py now also captures the trial_index returned by attach_trial() when seeding existing data (the previous loop-counter assumption was fragile if Ax trial indices ever diverged).
  • The duplicated penalty_lookup blocks and Branin math in tensegrity_bo.py are honegumi template output — the customization lives in tensegrity_campaign.py instead, leaving the scaffold faithful to honegumi's output.
  • tensegrity_campaign.py now uses PETG struts + TPU 85A/95A skin per PR Explore TPU+PLA BO design variables and base structures (Edison literature result + PR #22 design-gaps synthesis, hierarchical search space) #24's Edison literature recommendations (superseding the earlier PLA + TPU placeholder). The dummy evaluator includes a PETG density (1.27 g/cm³) and a shore-softness cushion factor.
  • The dummy evaluator's coefficients are hand-tuned heuristics and are inline-commented as such — replace with experimental data or an FE surrogate once available.

Copilot AI changed the title [WIP] Scaffold Bayesian optimization script using honegumi Scaffold Bayesian-optimization script with honegumi May 8, 2026
Copilot AI requested a review from sgbaird-alt May 8, 2026 17:50
@sgbaird

sgbaird commented May 8, 2026

Copy link
Copy Markdown
Collaborator

@copilot per your best judgement, incorporate #24 and other mentions of specific variables and objectives mentioned in:

The undergraduate mentoring grant proposal: https://github.com/vertical-cloud-lab/tensegrity-optimization/blob/main/proposal.pdf
The abstract that got submitted and accepted to IDETC 2026: https://github.com/vertical-cloud-lab/tensegrity-optimization/blob/copilot/write-draft-abstract/idetc-abstract.pdf
A BYU NASA Space grant application: https://github.com/vertical-cloud-lab/tensegrity-optimization/blob/copilot/create-latex-template-proposal/nasa-space-grant/proposal.pdf

Verify that it runs. If you haven't already, use reasonable assumptions for dummy objective function(s)

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

@copilot per your best judgement, incorporate #24 and other mentions of specific variables and objectives mentioned in...

Done in f6f3af8. Added bo/tensegrity_campaign.py (hand-customized companion to the regenerable honegumi scaffold) wiring up the variables and objectives that converge across proposal.tex, idetc-abstract.tex, nasa-space-grant/proposal.tex, and PR #24:

  • Continuous: strut diameter (1.5–6.0 mm), strut length (15–50 mm), TPU skin thickness (0.4–2.0 mm), TPU skin width (1.0–6.0 mm)
  • Integer (ordered choice): struts per unit cell ∈ {3, 4, 6, 8, 12}
  • Categorical: connectivity topology ∈ {3-bar prism, 4-bar prism, octahedron, icosahedron}, tiling ∈ {1×1×1, 2×2×1, 2×2×2}
  • Objectives (MOO / qNEHVI): minimize F_peak_N, maximize SEA_J_per_g, maximize eta
  • Pilot data: 5 baseline designs (matches the NASA grant's "≥ 5 baseline geometries")

Sticking with PLA + TPU (the spec in all three PDFs); PR #24's PETG variant can be added later as an extra categorical. The dummy simulate_specimen is a closed-form mass + topology-stiffness + saturating-skin model with heteroscedastic noise — documented as a placeholder for the experimental data layer.

Verified: MPLBACKEND=Agg python bo/tensegrity_campaign.py → 5 pilot + 10 BO trials, 3 Pareto-optimal designs, Pareto plot written. 6/6 pytest pass. CodeQL clean.

Copilot AI changed the title Scaffold Bayesian-optimization script with honegumi Scaffold Bayesian-optimization script with honegumi + customized tensegrity campaign May 8, 2026
Copilot finished work on behalf of sgbaird May 8, 2026 18:37
Copilot AI requested a review from sgbaird May 8, 2026 18:37
@sgbaird-alt sgbaird-alt marked this pull request as ready for review May 8, 2026 18:46

@sgbaird-yolo sgbaird-yolo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread bo/tensegrity_campaign.py Outdated
Comment thread bo/tensegrity_campaign.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an initial Bayesian-optimization code path under bo/ using honegumi to generate a regenerable Ax/BoTorch scaffold, plus a hand-written “real campaign” script that encodes the project’s tensegrity design variables/objectives and runs end-to-end with a synthetic evaluator.

Changes:

  • Introduces bo/generate_scaffold.py to render a pinned-version honegumi Ax scaffold (bo/tensegrity_bo.py) and a smoke-test rendering mode.
  • Adds bo/tensegrity_campaign.py, a customized multi-objective Ax campaign with the project’s design space + objectives and a dummy evaluator to enable immediate iteration.
  • Adds BO-focused README/docs, requirements pins, and pytest smoke tests; updates repo README and .gitignore accordingly.

Reviewed changes

Copilot reviewed 8 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
README.md Documents the new bo/ directory and basic usage commands.
.gitignore Ignores Python caches and the generated BO campaign plot artifact.
bo/init.py Marks bo as a package for imports/tests.
bo/generate_scaffold.py Wraps honegumi rendering; adds --smoke-test generation path.
bo/tensegrity_bo.py Generated honegumi Ax scaffold script committed to repo.
bo/tensegrity_campaign.py Customized Ax MOO campaign with real variables/objectives + dummy evaluator + plotting.
bo/requirements.txt Adds pinned dependencies for the BO scaffold/campaign.
bo/README.md Documents scaffold regen, customized campaign, and customization checklist.
bo/tests/init.py Marks tests as a package.
bo/tests/test_generate_scaffold.py Smoke tests for engine build + rendered script structure + iteration count.
bo/tests/test_tensegrity_campaign.py Smoke tests for dummy evaluator, search space, and a short Ax run.

Comment thread bo/requirements.txt
ax-platform==0.4.3
numpy<2
pandas<2.3
matplotlib
Comment thread bo/tensegrity_bo.py Outdated
Comment on lines +85 to +86
ax_client.attach_trial(parameterization)
ax_client.complete_trial(trial_index=i, raw_data=y_train[i])
Comment thread bo/tests/test_tensegrity_campaign.py Outdated
Comment on lines +45 to +49
@pytest.mark.slow
def test_main_short_run_completes(capsys):
# The default (no --full) runs 5 BO iterations with batch size 2 on top of
# the pilot seed. We pass --no-plot to keep the test headless and fast.
exit_code = main(["--no-plot", "--seed", "0", "--batch-size", "2"])
Comment thread bo/README.md Outdated
it exists only so that the BO loop has something to optimize before the first
batch of physical tests lands. Replace it with a call into the experimental
data layer (or an FE surrogate) when ready; the BO loop in `main` does not
does not need to change.
Comment thread bo/generate_scaffold.py Outdated
Comment on lines +32 to +34
python bo/generate_scaffold.py # writes bo/tensegrity_bo.py
SMOKE_TEST=true python bo/tensegrity_bo.py # quick smoke run

Comment thread bo/tensegrity_campaign.py Outdated
Comment on lines +233 to +234
# denominator's `4.0 mm^2` is a reference skin cross-section that gives a
# ~50% cushion at t*w = 4 mm^2 — re-fit against pilot data when available.
@sgbaird-yolo

Copy link
Copy Markdown
Collaborator

@copilot apply changes based on the comments in this thread

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

Applied all six reviewer comments in d6bba70:

  • bo/requirements.txt: added explicit black>=24.0 pin.
  • bo/tensegrity_bo.py: now captures trial_index from attach_trial() (idempotent post-process in render_script) and regenerated.
  • bo/tests/test_tensegrity_campaign.py: removed unregistered @pytest.mark.slow.
  • bo/README.md: fixed "does not does not" typo.
  • bo/generate_scaffold.py: replaced stale SMOKE_TEST=true … docstring with the real --smoke-test workflow.
  • bo/tensegrity_campaign.py: cushion-factor comment now correctly states ~38% reduction at t·w=4 mm² (formula yields 0.625, not 0.5).

pytest bo/tests → 6/6 passing; scaffold regen remains byte-stable.

@sgbaird sgbaird left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot address comments below

Comment thread bo/tensegrity_campaign.py Outdated
Comment thread bo/tensegrity_campaign.py Outdated
Comment thread bo/tensegrity_campaign.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 11 changed files in this pull request and generated 3 comments.

Comment thread bo/generate_scaffold.py Outdated
Comment thread bo/generate_scaffold.py Outdated
Comment thread bo/requirements.txt
Copilot AI requested a review from sgbaird May 20, 2026 16:54
sgbaird-alt and others added 3 commits May 20, 2026 11:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@sgbaird-alt

Copy link
Copy Markdown
Collaborator

@copilot update the variables and design types based on results in #24

Copilot AI commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

@copilot update the variables and design types based on results in #24

Updated the campaign's variables and design types in 834ca15 to track PR #24's PETG+TPU Edison literature table (5ae24eaf-…):

  • Material switch: PLA → PETG struts; TPU shore now a categorical {85A, 95A}.
  • New continuous axes: cable Ø [1.0, 3.0] mm, twist [10°, 45°], prestress [0%, 5%], PETG infill [40%, 100%], interface wrap thickness [0.4, 2.0] mm (replaces tpu_skin_thickness/width).
  • Updated bounds: strut Ø tightened to [1.5, 5.0] mm per PR Explore TPU+PLA BO design variables and base structures (Edison literature result + PR #22 design-gaps synthesis, hierarchical search space) #24's "Recommended Numeric Bounds" table.
  • Topologies: now the four "defensible seed families" — {truncated_octahedron (Pajunen, highest EA), simplex_4_strut, t3_prism, stacked_prism}.
  • Tilings: extended to {1×1×1, 1×1×2, 2×2×1, 2×2×2, 3×3×2}.
  • New categoricals: PETG infill pattern {rectilinear, grid, gyroid}, build orientation {vertical, horizontal, 45°}.
  • Dummy simulator updated to consume the new variables (PETG density 1.27, shore-softness cushion factor, infill strength scaling, twist sweet-spot bonus near 30°, orientation factor) and README synced.

Verified: MPLBACKEND=Agg python bo/tensegrity_campaign.py → 10 Sobol-init trials, 4 Pareto-optimal designs, plot written.

@sgbaird

sgbaird commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Noting that I think we'll start including printer processing parameters (e.g., temperatures) into the design space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scaffold the Bayesian optimization script based on honegumi

5 participants