Skip to content

Gradient optimizers: finish #386 deliverable 6 — convergence-vs-baseline test + becker smoke test #462

Description

@wshlavacek

Summary

#386 deliverable 6 is "Tests: each optimizer recovers known parameters on a small FD-validated model; convergence vs a metaheuristic baseline on the same model; a smoke test mirroring examples/becker_d2d_gradient/." The recovery portion is done; the other two parts remain. This issue tracks them.

Done (for reference):

  • Parameter-recovery tests through the real bngsim backend — tests/test_gradient_optimizer.py (rate/IC, estimated-σ, bound-active, multimodal multi-start).
  • Offline scipy-oracle step-math parity for the runners — tests/test_gradient_runner.py.

Part A — convergence vs a metaheuristic baseline

A test that, on the same model, compares a gradient fit (trf / lbfgs) against a metaheuristic baseline (de) and asserts the gradient method does at least as well — the head-to-head #386 asked for, which the truth-recovery tests don't cover.

  • The recovery harness already exposes all four algorithms, so this can be built on it directly: tests/recovery_harness.py _ALGORITHMS = {'de', 'am', 'trf', 'lbfgs'}, with build() / drive() running any of them on one config.
  • Design choice to settle (the fuzzy part): what "convergence vs baseline" asserts. Candidates: (a) the gradient fit reaches an objective ≤ the metaheuristic's on the same model/budget; (b) it reaches the known optimum in far fewer objective evaluations (the real selling point of a gradient method — count success_count / trajectory length); (c) both. Recommend (b)+(a): same small model, both recover the truth, and the gradient fit uses materially fewer evaluations. Keep it deterministic (fixed random_seed) so it isn't flaky.

Part B — becker smoke test

A smoke test mirroring examples/becker_d2d_gradient/ (the D2D EpoR methodological reference: multi-start → TRF) driven through PyBNF's real scheduler (fit_type = trf, now with multi-start), not the standalone BNGsim-direct path the reference notebooks use.

  • The reference currently lives only on the unmerged branch origin/examples/becker-d2d-gradient (an Antimony model BIOMD0000000271.ant, becker_d2d_data.npz, a README, and two notebooks — all standalone, no scheduler).
  • A scheduler-driven smoke test needs at least the model + data fixtures on main (under tests/), exercising the SBML/Antimony gradient path end-to-end (the measurement-model layer + SBML forward sensitivities the assembly already supports). It does not require merging the notebooks.
  • Scope is a smoke test: it runs the fit to completion without error and lands at a sane objective — not a tight parameter-recovery assertion on the full EpoR model (which would be slow/flaky). A trimmed model or a short iteration budget is fine.

Optional, separate from the test deliverable

Decide whether to merge the examples/becker-d2d-gradient branch as the on-main standalone reference example (the notebooks + data + README #386 points at). This has independent docs/example value but is not required to close deliverable 6 — the smoke test can ship with just its own fixtures. Track/merge it on its own merits.

Done criteria

  • A convergence-vs-baseline test (Part A) on a small model, deterministic, asserting the chosen metric (recommend: gradient fit recovers the truth in materially fewer evaluations than de, and to an at-least-as-good objective).
  • A becker (or becker-derived) smoke test (Part B) driving fit_type = trf multi-start through the scheduler to completion, with the needed model/data fixtures landed under tests/.
  • Gradient-based local optimizers (D2D-style: TRF/Levenberg-Marquardt + L-BFGS-B) in the async Algorithm loop #386 deliverable 6 checkbox flipped once both land.
  • (Optional, separate) becker reference example merged to main, or explicitly deferred.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions