Skip to content

tolerance table: rows for #1002's jump-mend constants, with measured pins, and the ratchet reads them (#2150) - #2153

Merged
wshlavacek merged 3 commits into
mainfrom
docs/2150-fd-jump-rows
Dec 4, 2026
Merged

wshlavacek merged 3 commits into
mainfrom
docs/2150-fd-jump-rows

Conversation

@wshlavacek

Copy link
Copy Markdown
Collaborator

Closes #2150. Part of #1781's phase 1. Docs and tests only: no src/ or include/ change.

What changes

The integrator's two difference-quotient Jacobians (dq_jacobian.hpp, sparse_jacobian.hpp) read three constants of include/bngsim/fd_jacobian.hpp that set #1002's mend of a column whose step crosses a jump in a rate law. None of the three had a row in docs/development/tolerance-table.md, and the ratchet from #2045 listed the whole file as outside the integrator, so a fourth constant added to the mend would have needed no row.

  • Three rows in "Named constants outside the count", beside kClampNoiseAtols: kFdJumpRatio, kFdJumpNoise and kFdJumpParked. Each gives the constant's value and scale, what it guards, how it was set, the commit that first needed it, its measured pin, and phase 3: goes, with the mend (G1).
  • The ratchet reads the mend. INTEGRATOR_PARTS maps fd_jacobian.hpp to the mend's banner: every constexpr k… from there to the file's end needs a row, whatever its name. A kFdJump… declared above the banner fails too (INTEGRATOR_PART_NAMES). The file's seven step-rule constants above it, which only the steady-state solver and Model.jacobian() read, stay outside. If the banner is reworded, the ratchet fails and says so. As agreed on tolerance table: the integrator's difference-quotient Jacobians read three tuning constants of fd_jacobian.hpp with no rows #2150, the header is not split.
  • integrator-contract.md: British spellings made American (judgement, neighbouring, behaviour ×9, modelling).

The pins, measured

Each constant was moved in the header, the core rebuilt, and the mend's tests run: seven files with 1,277 tests (test_difference_quotient_jump.py, test_differenced_jacobian_agreement.py, test_colored_fd_jacobian_steps.py, test_differential_shapes.py, and the three that PR #1302 ran its variants against: test_jacobian_discontinuous_fallback.py, test_net_state_switch_stepping.py, test_steady_state_stagnation_escape.py). The extreme values were run first, to show the trial builds take effect.

constant (shipped) values tried where every test passes first failures
kFdJumpRatio (16) 1.5, 2, 4, 8, 32, 128, 1e4, 1e5, 1e6, 1e7 3 tests at 1; 13 at 1e8 and at 1e300 (14)
kFdJumpNoise (1024) 0, 64, 512, 2048, 1e5, 1e6, 1e7 14 at 1e8, 1e12 and 1e300 (15)
kFdJumpParked (1e-6) 0, 1e-8, 5e-7, 2e-6, 1e-4, 1e-2, 0.1 3 at 0.5; 14 at 1 and at 1e300

So the ratio is pinned both ways, loosely, to (1, 1e8). The noise floor and the parked share are pinned only against a rise, past 1e7 and past 0.1. Nothing holds either from below: with the floor at 0, or the parked rule off, every test passes. That agrees with PR #1302's own variants, where both "survive" because the own-row rule added later also undoes the false mends that first set them. The rows say so. That is a gap in the tests' coverage, not a wrong result: no known case comes out wrong at either value.

The last trial rebuilt the core at the shipped values, and the header is byte-identical to main's.

Review

By AI models, two independent reviews of the whole branch.

  1. /code-review (Claude Opus 5.5) at high effort, one round, at 3a7f5bd. Three nits, no blocking findings. All three were fixed in 201b44f:

    • The ratio row gave a cause for its failures at 1 that the sweep never showed. The row now says only which tests fail.
    • The prose's passing range implied the values between those tried. It now says "at each value tried".
    • A kFdJump… constant declared above the banner passed with no row. It now fails, with a test.
  2. Fable 5.2 at medium effort, one round, at 201b44f. It was given the diff, the issue and CONTRIBUTING's review prompt, not my conclusions. No blocking findings. Two factual errors in the kFdJumpNoise row, both fixed in f3c36d8:

    • The row cited 27e990a, but the constant and its terms scale came in ea1bcbc.
    • The row said the value-floor case (BIOMD0000000091) is in no test. Since b7a5d31 it is in test_difference_quotient_jump.py::test_a_model_with_no_jump_has_nothing_mended, on MODEL1812040006. The test passes at 0 because the own-row rule also undoes those mends.

    From its notes, also fixed in f3c36d8:

    • 0.5 is exactly a decaying fixture's own share of its row's terms (0.1 of 0.2), so which tests fail at 0.5 rides on rounding and may differ by platform. The row says so; the 14 failures at 1 do not depend on it.
    • The section's opening sentence said none of its rows are constexpr k…. It now says they are outside the 107 of cvode_simulator.cpp.

    It also probed the ratchet against seven realistic edits, and each failed or passed as it should. It checked the measured bounds against the mend's arithmetic on the threshold fixture: a jump-to-slope ratio near 3.4e7, and a floor of 0.015 at 1e7 against a jump of 0.1.

Commits after the last round of either review: f3c36d8 (the Fable fixes above; docs only).

Left alone

  • A mend constant not named kFdJump…, declared above the banner, needs no row. The banner and the name rule are the ratchet's two ways in.
  • The mend's bare numbers (2.0 in fd_jump_testable, 0.5 in fd_jump_came_across) are not named constants, so neither the table nor the ratchet counts them. That is the table's rule for every bare number ("Numbers written inline").
  • The noise floor and the parked share have no test from below. No known case is wrong at 0 (PR Difference quotients that step across a jump in a rate law (#1002) #1302's variants), so there is nothing to write a test for. The rows record it for phase 3.
  • "Zeno behaviour" in the shipped message. The contract now paraphrases the cascade guard's error as naming "Zeno behavior", while the message itself (src/cvode_simulator.cpp) and test_event_zeno_refusal.py still spell it "behaviour". Respelling a user-facing message is a src/ change, outside this docs PR.

Testing

  • test_tolerance_table_ratchet.py: 40 passed. Each new case was checked to fail without its change: on main's ratchet, a constant added to the mend draws no problem at all.
  • test_skip_audit.py, test_ci_run_list_coverage.py, pre-commit run on the changed files, and sphinx -W on the docs all pass.
  • The pre-push suite (ci/pre_push_pytest.py) passed at f3c36d8.
  • No perf_ab.py run: nothing in src/, include/, the code generator, the loaders or Simulator changes. No changelog fragment either: CI asks for one only for python/bngsim/, src/ or include/.

The integrator's dense and colored difference-quotient Jacobians read
kFdJumpRatio, kFdJumpNoise and kFdJumpParked from fd_jacobian.hpp, and
none had a row. Each now has one, with its pin measured by moving it,
rebuilding and running the mend's 1,277 tests: the ratio is pinned both
ways, loosely, to (1, 1e8); the floor against a rise past 1e7 and the
parked share against a rise past 0.1, with nothing holding either from
below, as PR #1302's variants found.

The ratchet reads fd_jacobian.hpp from the mend's banner on
(INTEGRATOR_PARTS), so a constant added to the mend, whatever its name,
needs its row, while the steady-state step rule above it stays outside.
The contract's British spellings become American.
The ratio row says which tests fail at 1 and 1e8, not why; the prose's
passing range is the values tried. A constant named kFdJump... declared
above the mend's banner fails the ratchet as well (INTEGRATOR_PART_NAMES).
kFdJumpNoise and its terms scale came in ea1bcbc, not 27e990a, and
the value-floor case is in a test after all, on MODEL1812040006 since
b7a5d31. The parked row says 0.5 is a decaying fixture's own share,
where rounding decides; the section's lead-in no longer says every row
is outside the constexpr form.
@wshlavacek
wshlavacek merged commit ce66711 into main Dec 4, 2026
17 checks passed
@wshlavacek
wshlavacek deleted the docs/2150-fd-jump-rows branch December 4, 2026 18:24
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.

tolerance table: the integrator's difference-quotient Jacobians read three tuning constants of fd_jacobian.hpp with no rows

1 participant